Puneet Varma (Editor)

De Casteljau's algorithm

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
De Casteljau's algorithm

In the mathematical field of numerical analysis, De Casteljau's algorithm is a recursive method to evaluate polynomials in Bernstein form or Bézier curves, named after its inventor Paul de Casteljau. De Casteljau's algorithm can also be used to split a single Bézier curve into two Bézier curves at an arbitrary parameter value.

Contents

Although the algorithm is slower for most architectures when compared with the direct approach, it is more numerically stable.

Definition

A Bézier curve B (of degree n, with control points β 0 , , β n ) can be written in Bernstein form as follows

B ( t ) = i = 0 n β i b i , n ( t ) ,

where b is a Bernstein basis polynomial

b i , n ( t ) = ( n i ) ( 1 t ) n i t i .

The curve at point t0 can be evaluated with the recurrence relation

β i ( 0 ) := β i  ,  i = 0 , , n β i ( j ) := β i ( j 1 ) ( 1 t 0 ) + β i + 1 ( j 1 ) t 0  ,  i = 0 , , n j  ,  j = 1 , , n

Then, the evaluation of B at point t 0 can be evaluated in n steps of the algorithm. The result B ( t 0 ) is given by :

B ( t 0 ) = β 0 ( n ) .

Moreover, the Bézier curve B can be split at point t 0 into two curves with respective control points :

β 0 ( 0 ) , β 0 ( 1 ) , , β 0 ( n ) β 0 ( n ) , β 1 ( n 1 ) , , β n ( 0 )

Example implementation

Here is an example implementation of De Casteljau's algorithm in Haskell:

Example

We want to evaluate the Bernstein polynomial of degree 2 with the Bernstein coefficients

β 0 ( 0 ) = β 0 β 1 ( 0 ) = β 1 β 2 ( 0 ) = β 2

at the point t0.

We start the recursion with

β 0 ( 1 ) = β 0 ( 0 ) ( 1 t 0 ) + β 1 ( 0 ) t 0 = β 0 ( 1 t 0 ) + β 1 t 0 β 1 ( 1 ) = β 1 ( 0 ) ( 1 t 0 ) + β 2 ( 0 ) t 0 = β 1 ( 1 t 0 ) + β 2 t 0

and with the second iteration the recursion stops with

β 0 ( 2 ) = β 0 ( 1 ) ( 1 t 0 ) + β 1 ( 1 ) t 0   = β 0 ( 1 t 0 ) ( 1 t 0 ) + β 1 t 0 ( 1 t 0 ) + β 1 ( 1 t 0 ) t 0 + β 2 t 0 t 0   = β 0 ( 1 t 0 ) 2 + β 1 2 t 0 ( 1 t 0 ) + β 2 t 0 2

which is the expected Bernstein polynomial of degree 2.

Bézier curve

When evaluating a Bézier curve of degree n in 3-dimensional space with n+1 control points Pi

B ( t ) = i = 0 n P i b i , n ( t )  ,  t [ 0 , 1 ]

with

P i := ( x i y i z i ) .

we split the Bézier curve into three separate equations

B 1 ( t ) = i = 0 n x i b i , n ( t )  ,  t [ 0 , 1 ] B 2 ( t ) = i = 0 n y i b i , n ( t )  ,  t [ 0 , 1 ] B 3 ( t ) = i = 0 n z i b i , n ( t )  ,  t [ 0 , 1 ]

which we evaluate individually using De Casteljau's algorithm.

Geometric interpretation

The geometric interpretation of De Casteljau's algorithm is straightforward.

  • Consider a Bézier curve with control points P 0 , . . . , P n . Connecting the consecutive points we create the control polygon of the curve.
  • Subdivide now each line segment of this polygon with the ratio t : ( 1 t ) and connect the points you get. This way you arrive at the new polygon having one fewer segment.
  • Repeat the process until you arrive at the single point - this is the point of the curve corresponding to the parameter t .
  • The following picture shows this process for a cubic Bézier curve:

    Note that the intermediate points that were constructed are in fact the control points for two new Bézier curves, both exactly coincident with the old one. This algorithm not only evaluates the curve at t , but splits the curve into two pieces at t , and provides the equations of the two sub-curves in Bézier form.

    The interpretation given above is valid for a nonrational Bézier curve. To evaluate a rational Bézier curve in R n , we may project the point into R n + 1 ; for example, a curve in three dimensions may have its control points { ( x i , y i , z i ) } and weights { w i } projected to the weighted control points { ( w i x i , w i y i , w i z i , w i ) } . The algorithm then proceeds as usual, interpolating in R 4 . The resulting four-dimensional points may be projected back into three-space with a perspective divide.

    In general, operations on a rational curve (or surface) are equivalent to operations on a nonrational curve in a projective space. This representation as the "weighted control points" and weights is often convenient when evaluating rational curves.

    References

    De Casteljau's algorithm Wikipedia