39
1 Bézier and B-spline curves for CAD Kenjiro T. Miura Shizuoka University Based on Prof. Ohtake’s ppt : http://www.den.rcast.u-tokyo.ac.jp/~yu-ohtake/GeomPro/

Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

1

Bézier and B-spline curvesfor CAD

Kenjiro T. MiuraShizuoka University

Based on Prof. Ohtake’s ppt :http://www.den.rcast.u-tokyo.ac.jp/~yu-ohtake/GeomPro/

Page 2: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

2

Objectives• Learn basics of the curves frequently used in

CG and CAD.• Learn offset and curvature of the parametric

curve.

Page 3: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

3

Outlines• What is a parametric curve?

• Bézier curve

• Tangent and normal

• Curvature

• B-spline curve

• Space curve

Page 4: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

4

Representation of plane curve• Explicit :

– Limited d.o.f.

• Parametric :– Easy to use, high d.o.f.– Easy to extend to space curves

• Implicit : – Also called iso-lines

)(xfy =

( ))(),()( tytxt =c

0),( =yxf

21 xy −=

)sin,(cos)( ttt =c

01 22 =−− yx

Page 5: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

5

Parametric

• Explicit representation for each coordinate

( ))(),()( tytxt =c

x

y

t

t

y

x

t

)(tx

)(ty

Page 6: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

6

Rendering of parametric curve• Use polyline

( ) ( )( )sec0,sec0 yx

( ) ( )( ) sec10sec0,, ≤≤ ttytx  

( ) ( )( )sec5,sec5 yx

( ) ( )( )sec10,sec10 yx Points for 0.5 sec interval

Page 7: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

7

Outlines• What is a parametric curve?

• Bézier curve

• Tangent and normal

• Curvature

• B-spline curve

• Space curve

Page 8: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

8

Frequently used for CAD• Bézier curve• B-spline curve

Bézier curve B-spline closed curve

Page 9: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

99

Practical example

• Outline font– Always smooth with any zooming

Outline font(vector image)

Dot font(raster imags)

Page 10: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

10

Problem dealt by Bézier(For car design)

• Generate a curve based on a sequence of points in a plane.

• Change the shape according to the move of the points

Change of the design

Move “control points”

Page 11: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

11

Bézier’s idea• Add smooth functions to represent the whole

shape!Given data

Multiply

Add!

Page 12: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

12

Bernstein basis function• Probability of “Repeated trial”

– Probability for t trial, n times, get i times.

iniin ttC −− )1(

)(tBni0 < t < 1 と書く

)}(),(),(),({ 33

32

31

30 tBtBtBtB

100% lottry three times

Three wins: 100%

A lot : win a time among three tries,

Win one time.t

)(3 tBi

Page 13: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

13

∑=

=n

ii

ni xtBtx

0)()(

)(tBni i

ni xtB )(

∑=

n

i 0

=

=

=

=

i

n

i

ni

i

n

i

ni

ytBty

xtBtx

0

0

)()(

)()(

Same for y

Page 14: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

14

Cubic Bézier curve• The most frequently used curve

– # of control points = 4– Convenient for spedifying the start and end

points and tangent vectors there.– Cubic polynomials → Next page

),(:pointstart 00 yx ),(:point end 33 yx

),( 11 yx

),( 22 yxDirection of the curve

at the start point

Direction of the curveat the end point

Page 15: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

15

Cubic Bézier curve(x coordinate)

3332

321

310

30

3

0

3

)()()()(

)()(

xtBxtBxtBxtB

xtBtxi

ii

+++=

=∑=

2

13113

31

)1(3)1()(

ttttCtB

−=

−= − cubic polynomial of t• t = 0 , 0• t = 1 , double roots• t = 1/3, max

t

)(3 tBi

),( 00 yx ),( 33 yx

),( 11 yx

),( 22 yx

Page 16: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

16

Properties of Bézier curve• Remains the same shape with a

coordinate system translation.• Inside the Convex hull

Translate coordinatesystem

Reason : point on the curve is a positive weighted sum of the control points

Origin

Origin

Page 17: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

17

Outlines• What is a parametric curve?

• Bézier curve

• Tangent and normal

• Curvature

• B-spline curve

• Space curve

Page 18: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

18

Tangent and normal vectors• Tangent vector : direction of the curve• Normal vector : perpendicular to tangent

forwardside※ look at the carfrom the top

Page 19: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

19

Tangent vector of the parametric curve

• Differentiate with respect to the parameter

=

dttdy

dttdxt )(,)()(t

timeelapsedlocationcurrent locationNext

timeelapsedntvectordisplacemeectorvelocity v

−=

=

slow

fasterPoints of the

same time interval

If the parameter is time, velocity vector

Make e-time to infinitesimal= differentiate

Page 20: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

20

Tangent vector of Bézier curve• Differentiate the basis functions

– Control points are coefficients

==

==

∑∑

∑∑

==

==

i

n

i

ni

i

n

i

ni

i

n

i

ni

i

n

i

ni

ydt

tdBytBdtd

dttdy

xdt

tdBxtBdtd

dttdx

00

00

)()()(

)()()(

)(tt

)31)(1(3)1(3)( 231 tttt

dtd

dttdB

−−=−=

First derivative of B1

Page 21: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

21

Bézier spline curve• Connect Bézier curves of low degree

(usually cubic)– Locate control points to be parallel at joints.

jointjoint

※ At the end points of a Bezier curve, tangent to the polylines made of the control points.

Make control points locate on the same line

Page 22: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

22

Normal vector• Rotate tangent vector by 90 degrees.

– Usually use a unit normal vector whose length=122 )()()(,)()(

+

−=

dttdy

dttdx

dttdx

dttdytn

Normal vectorTangent vector

),(vectoriseanticlockw degrees 90 rotate

),(vector

xy

yx

−↓

),(1vector

lengthunit ),(vector

22yx

yx

yx

+

Page 23: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

23

Offset curve• Trajectory made by translating points on the curve

in the direction of norma vector– When machine with a ball-end mill

the path of its center is on the offset curve

Work’s shape

tool

)()( trt nc + r : radius of the machining tooln : unit normal vector

Page 24: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

24

Outlines• What is a parametric curve?

• Bezier curve

• Tangent and normal

• Curvature

• B-spline curve

• Space curve

Page 25: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

25

Curvature and radius of curvature• ROC : radius of the best fit circle

– If positive, the same direction of the normal vector• Curvature : reciprocal of ROC (0 if straight)

ROC (positive)

Normal vectorROC (negative)

Page 26: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

26

Application of radius of curvature• Cannot machine with a tool with a radius

llaeger the ROC.– Useful for tool selection

Tool

Work’ s shape Cannot machine(Self-intersection of

the offset curve)

Page 27: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

27

Calculation of curvature

ROC×rotation of tangent vector [radian] = length of the approximate arc

( ))(),()( tytxt =cκ1

=Rθd

ds

Consider small change

dsdθκ =

• Approximate the curve with a circle

: change of the angle

Page 28: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

28

Calculation of curvature

reference line for angle

Tangent line θ ( ) ( )∫ +=

=

t

ttdtdtdytdtdxts

dttdxdttdyt

0

ˆˆ)ˆ(ˆ)ˆ()(:length arc

)()()(tan:line tangent of slope

22

θ

1)()()()()(

==

dttds

dttd

tdstdt θθκ

( ) ( )( ) 23

22

2222

)()(

)()()()(

)(dttdydttdx

dttyddttxddttdydttdx

t+

Use the equations below

※ need second derivative

Page 29: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

29

Evolute curve• Trajectory of the best fit circle circle

– Translate in the normal direction by the ROC. – Pass through points where the offset line breaks.

)()( vectornormalunit ROC

ttR n×

)(:curve tc

)()()(:Evolue

tntRtc +

Points where the offset curve breaks

Page 30: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

30

Approximate ROC with a polyline• Radius of the circle which passes through

3 points– Remind the sine theorem

c

bS

aCalculate ROC

at point Owith the side lengths

and area of triangle OAB

O

A B

Page 31: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

31

Outlines• What is a parametric curve?

• Bezier curve

• Tangent and normal

• Curvature

• B-spline curve

• Space curve

Page 32: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

32

Problems on Bezier curve• Degree increases with the number of control

points.• One movement will change the whole shape.点の移動

Of degree 30!

Change around here, too.

Page 33: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

33

B-spline curve(different from Bézier spline)

• Example of quadratic B-spline curve– The curve is tangent at the middle point of the

control point polyline.

( )∑ −= iitNt pc 2)(

Format is the sum of (basis func.×pos. of c.p.)

Page 34: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

34

B-spline basis function

otherwise1||

01||

)(1 ≤

+−

=tt

tN

≤≤

+−+−

=otherwise

2/3|| if else2/1|| if

08/)912||4(

4/3||)( 2

2

2 tt

ttt

tN

( )∑ −= ixitNtx 2)(

Page 35: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

35

How to make B-spline basis func.• Recursively defined by the following

convolution

otherwise1/2|t| if

01

)(0 ≤

=tN

∫ −=+ dsstNsNtN nn )()()( 01

s1/2-1/2

Area here is

t

( ))(1 tsN −−Reverse right and left

( )tN 2

1

-t

Page 36: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

36

Outlines• What is a parametric curve?

• Bezier curve

• Tangent and normal

• Curvature

• B-spline curve

• Space curve

Page 37: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

37

Space curve in parametric form

• Only add z coordinate.

Herical curve : ),sin,cos()( thtrtrt =c

( ))(),(),()( tztytxt =c

Page 38: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

38

Binormal and torsion (space curve)

• Drive a car on a space curve– tangent t : ongoing direciton– normal n : curve direction(cannot defined for

straight line )– binormal b : top direction for the driver

• Curvature κ : degree of curve

• Torsion τ: Vibration of head

tb

n

Page 39: Bézier and B-spline curves for CADTangent vector of the parametric curve • Differentiate with respect to the parameter = dt dy t dt dx t t (), ( ) t( ) elapsed time Next location

39

Frenet-Serret formula (space curve)

)()()()()()()()(

)()()(

sskssssss

sss

tbnnb

nt

−=′−=′

=′

ττ

κ

tb

n

tb

n

κ

τ

Match the origins of the two frames.