You are on page 1of 13

AML710 CAD

LECTURE 13

Bezier Curves
Bernstein Basis Matrix formulation Conversion to Cubic De Casteljaus Geometric Construction

Bezier Curve
P(t) is a continuous function in 3 space defining the curve with N discrete control points Bi. t=0 at the first control point (i=0) and t=1 at the last control point (i=N).

t=1 P(t) t=0

Bezier Curve
A Bezier Curve is obtained by a defining polygon.

Application:
Where aesthetic appeal is more important than accuracy. Sometimes functional requirements demand such a curve. Ab initio designs may need such curves
B1

B2

P(t ) = Bi J n ,i (t )
i =0

B0

B3

n! 6 and J n ,i (t ) = t i (1 t ) n i = t i (1 t ) n i i!(n i )! i!(3 i )! J


3, 0

(t ) = (1 t ) 3 ; J (t ) = 3t(1 t ) 2 ; J
3,1 3, 2

(t ) = 3t 2 (1 t ); J
3, 3

(t ) = t 3

P (t ) = B0 J 3, 0 (t ) + B1 J 3,1 (t ) + B2 J 3, 2 (t ) + B3 J 3,3 (t )
2 3 = (1 t ) 3 P0 + 3t (1 t ) 2 P 1 + 3t (1 t ) P 2 +t P 3

Blending functions
P(t ) = Bi J n ,i (t ) and J n ,i (t ) =
i =0 n

n! 6 t i (1 t ) n i = t i (1 t ) n i i!(n i )! i!(3 i )!

J 3,0 (t ) = (1 t ) 3 ; J 3,1 (t ) = 3t (1 t ) 2 ; J 3, 2 (t ) = 3t 2 (1 t ); J 3,3 (t ) = t 3


1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 j3,0 j3,1 j3,2 j3,3

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Blending functions
B1

For

n = 2,3,4.....
1

0.5

B0 B1 B2 B1 B0

B2 B3

0.5

1 0.5

0.5

B3 B0

B2
0.5

0.5

Properties of the basis function

The curve in general does not pass through any of the control
points except the first and last. From the formula P(0) = B0 and P(1) = Bn.

n!(1)(1 0) n 0 =1 J n , 0 ( 0) = n! n!(0)i (1 0) n i J n ,i (0) = =0 i!(n i )!

i=0 i0
1 0.5

P(0) = B0 J n , 0 (0) = B0

0 1

0.5

Properties of the basis function

The curve in general does not pass through any of the control
points except the first and last. From the formula P(0) = B0 and P(1) = Bn.

J n ,n (1) =

n!(1)(0) n n =1 n!(1)

i=n in
1 0.5

n!(1) i (0) n i J n ,i (1) = =0 i!(n i )!

P(1) = Bn J n ,n (1) = Bn

0 1

0.5

Maximum value of Blending functions

It is observed that the blending functions are quite symmetric in nature The maximum value occurs at:
max( J n ,i (t )) = d ( J n ,i (t )) dt = 0; t = ? i i ( n i ) n i nn
i max( J n ,i (t )) = J n ,i ( n )= n ci

1 0.5

E.g .

J 3,1( 1 )=? 3 J 3, 2( 2 3) = ? J 3,1( 1 )= 3 J 3, 2( 2 3) =


4 9 4 9

0 1

0.5

Ans

Properties of the basis function

For any given value of the parameter t, the summation of the


basis functions is exactly equal to 1 i.e.,

J
i =0

n ,i

(t ) = 1

1 0.5

0 1

0.5

Properties of the basis function

The curve is always contained within the convex hull of the


control points, it never oscillates wildly away from the control points. If there is only one control point B0, ie: n=0 then P(t) = B0 for all t. If there are only two control points P0 and P1, ie: n=1 then the formula reduces to a line segment between the two control points.

Properties of the basis function


less than the number of control points.

J n ,i (t ) =

n! t i (1 t ) n i i!(n i )!

The blending function is always a polynomial of degree one Thus 3 control points result in a parabola, 4 control points a
cubic curve etc. Closed curves can be generated by making the last control point the same as the first control point. First order continuity can be achieved by ensuring the tangent between the first two points and the last two points are the same. Adding multiple control points at a single position in space will add more weight to that point "pulling" the Bzier curve towards it.

Example
% Bezier curve for n=3. Example 5.7 R&A t=0:.01:1; x=[1 2 4 3]; y=[1 3 3 1]; px=(1-t).^3*x(1)+3*t.*(1-t).^2*x(2)+3*t.^2.*(1-t)*x(3)+t.^3*x(4); py=(1-t).^3*y(1)+3*t.*(1-t).^2*y(2)+3*t.^2.*(1-t)*y(3)+t.^3*y(4); plot(x,y); hold 3 plot(px,py,'r'); axis([0 4.2 0 3.2]); 2.5
2

1.5

0.5

0.5

1.5

2.5

3.5

X(t) Y(t)

1.0 1.0

1.326 1.54

1.688 1.96

2.062 2.26

2.424 2.44

2.75 2.5

3.016 2.44

3.198 2.26

3.272 1.96

3.214 1.54

3.0 1.0

Example
% Bezier curve for n=3. Example 5.7 R&A, one data pt altered t=0:.01:1; x=[1 2 4 3]; y=[1 1 3 1]; px=(1-t).^3*x(1)+3*t.*(1-t).^2*x(2)+3*t.^2.*(1-t)*x(3)+t.^3*x(4); py=(1-t).^3*y(1)+3*t.*(1-t).^2*y(2)+3*t.^2.*(1-t)*y(3)+t.^3*y(4); plot(x,y); hold 3 plot(px,py,'r'); 2.5 axis([0 4.2 0 3.2]);
2

1.5

0.5

0.5

1.5

2.5

3.5

1.326 1.688 1.192

2.062 1.378

2.424 1.576

2.75 1.75

3.016 1.864

3.198 1.882

3.272 1.768

3.214 1.486

3 1

1 1.054

Example
% Bezier curve for n=3. Example 5.7 R&A, repeat 2 points t=0:.01:1; x=[1 2 2 3]; y=[1 3 3 1]; px=(1-t).^3*x(1)+3*t.*(1-t).^2*x(2)+3*t.^2.*(1-t)*x(3)+t.^3*x(4); py=(1-t).^3*y(1)+3*t.*(1-t).^2*y(2)+3*t.^2.*(1-t)*y(3)+t.^3*y(4); plot(x,y); hold plot(px,py,'r'); 3 axis([0 4.2 0 3.2]);
2.5
3

2
2.5

1.5
2

1
1.5

x=[1 2 2,2 3]; y=[1 3 3 1];


0 0.5 1 1.5 2 2.5 3 3.5 4

0.5

0.5

0.5

1.5

2.5

3.5

Example
% Bezier curve for n=3. Example 5.7 R&A, closed curve, 1st and 4th pts same t=0:.01:1; x=[1 2 4 1]; y=[1 3 3 1]; px=(1-t).^3*x(1)+3*t.*(1-t).^2*x(2)+3*t.^2.*(1-t)*x(3)+t.^3*x(4); py=(1-t).^3*y(1)+3*t.*(1-t).^2*y(2)+3*t.^2.*(1-t)*y(3)+t.^3*y(4); plot(x,y); hold plot(px,py,'r'); 3 axis([0 4.2 0 3.2]);
2.5

1.5

0.5

0.5

1.5

2.5

3.5

Matrix formulation of Bezier Curve


We can think of a matrix formulation now for Bezier curve. Consider a cubic Bezier curve

P(t ) = [F ][G ] = [T ][N ][G ]


J n ,1 ... J n ,n 1
3t (1 t ) 2

Where [F] is the blending function matrix given by

[F ] = [J n,0

J n ,n ]

[F ] = [(1 t )3

3t 2 (1 t ) t 3 [B0
1 3 3 3 6 3 t 1 3 3 0 0 0 1

B1

B2

B3 ]

P(t ) = [T ][N ][G ] = t 3 t 2

1 B0 B 0 1 0 B2 0 B3

Matrix formulation of Bezier Curve


We can extend this now to a quartic, for n=4, Bezier curve

P(t ) = [F ][G ] = [T ][N ][G ]

P(t ) = [T ][N ][G ] = t 4

t3 t2

6 4 1 4 4 12 12 4 t 1 6 12 6 0 0 0 4 4 0 0 0 1

1 B0 0 B1 0 B2 0 B3 0 B4

Derivatives of Bezier Curve


We require the derivatives of a Bezier curve : For determining slope and curvature continuities while joining segments For surface normal calculations needed in lighting and numerical tool path calculations etc

,i (t ) J n ,i (t )= n ci {it i 1 (1 t ) n i (n i )t i (1 t ) n i 1} P(t ) = Bi J n
i =0 n i ) ( n i ) i = n ci t i (1 t ) n i { ti ((1 t ) } = { t (1t ) }J n ,i (t ) = ( i nt ) t (1t )

J n ,i (t )

,i (t ) P(t ) = J n
i =0

,i (t ) = Jn

( i nt ) 2 nt 2 i (1 2 t ) t 2 (1t ) 2

)J

n ,i

(t )

Numerical evaluation of the above derivatives have problems at t=0,n

Derivatives of Bezier Curve


An alternate way for obtaining rth derivative at t=0 and t=1 i,e at the ends of the segment is respectively given as:

P(0) = P(1) =

n! ( n r )!

(1)
i =0 r i =0

r i r

ci Bi

n! ( n r )!

(1)

ir

ci Bn i

Thus the first derivatives for the ends are respectively given as:

P(0) = n( B1 B0 ) ;

P(1) = n( Bn Bn 1 )

Also, the second derivatives for the ends are respectively given as:

P(0) = n(n 1)( B0 2 B1 + B2 ) ; P(1) = n(n 1)( Bn 2 Bn 1 + Bn 2 )

Converting Bezier to/from Cubic spline


The derivatives defined earlier will be used to approximate the tangent vectors at the ends. Thus the first derivatives for the ends for cubic Bezier curve are respectively given as:

P(0) = 3( B1 B0 ) ;

P(1) = 3( B3 B2 )

Substituting these values for the tangent vectors we get the equivalent cubic spline Geometry matrix as :

[G ] = [B0
[G ] = 1 P

B3 3( B1 B0 ) 3( B3 B2 )]
1 1 ' (P ( P2 P2' ) P2 1+P 1) 3 3

In a similar way we can convert a cubic spline back to Bezier by appropriately using the end tanget vectors to define Bi:
T

10

Multi-segment curve
As the number of control points increases it is necessary to have higher order polynomials and hence higher factorials. It is common therefore to piece together small sections of Bzier curves to form a longer curve. This also helps control local conditions, normally changing the position of one control point will affect the whole curve. Of course since the curve starts and ends at the first and last control point it is easy to physically match the sections. It is also possible to match the first derivative since the tangent at the ends is along the line between the two points at the end. Second order continuity is generally not possible.

Direction of Parameterization
The curve is symmetric with respect to t and (1-t)

P (t ) = Bi J n ,i (t ) = Q( s ) = Bn i J n i ,i ( s )
i =0 i =0

where s = (1 t )

0 t 1

Note that when we have t as parameter then the curve is drawn from P0 to P4 while considering s as parameter we draw it form P4 to P0. Both produce the same curve. Hence direction of parameterization does not change the curve

11

Example : Closed Bezier curves

The curve always lies within the convex hull of the control points. Thus the curve is always "well behaved" and does not oscillate erratically.

Closed curves are generated by specifying the first point the same as the last point. If the tangents at the first and last points match then the curve will be closed with first order continuity.. In addition, the curve may be pulled towards a control point by specifying it multiple times.

Example
The pink line shows the polygon formed by the control points, the black line is the Bezier curve. Note that the curve lies within the convex hull of the points. Note also that the tangent of the curve at the endpoints is the same as the slope of the line between the first two or last two control points. This makes for convenient matching of the curve between sections.

12

Geometric Construction by De Casteljau


Casteljaus algorithm provides a method for geometrically constructing the Bezier curve. In th following example construction of a cubic Bezier is demonstrated. b
h e g a d f j i c

For the case of a cubic Bezier, we consider the three limbs of the open control polygon ab, bc, and cd. Next create the intermediate points e, f and g in the ratios ae/ab=bf/bc=cg/cd=t (given value of the parameter). Continuing iteratively we obtain the point j on the curve. Similarly a series of values of t give rise to the corresponding ratios and hence the points on the Bezier curve.

13

You might also like