ArticleslgStudy

computer science

De Casteljau's algorithm

De Casteljau's algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand De Casteljau's algorithm rather than just read about it. In short: 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.

De Casteljau's algorithm — main illustration
De Casteljau's algorithm — illustration

Key takeaways

  • De Casteljau's algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect De Casteljau's algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of De Casteljau's algorithm from memory before moving on to harder problems.

Reference excerpt

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. The algorithm is numerically stable when compared to direct evaluation of polynomials. The computational complexity of this algorithm is O(dn2), where d is the number of dimensions, and n is the number of control points. There exist faster alternatives.

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=0nβibi,n(t), where b is a Bernstein basis polynomial bi,n(t)=(ni)(1−t)n−iti. The curve at point t0 can be evaluated with the recurrence relation βi(0):=βi,i=0,…,nβi(j):=βi(j−1)(1−t0)+βi+1(j−1)t0,i=0,…,n−j, j=1,…,n Then, the evaluation of B at point t0 can be evaluated in (n2) operations. The result B(t0) is given by B(t0)=β0(n). Moreover, the Bézier curve B can be split at point t0 into two curves with respective control points: β0(0),β0(1),…,β0(n)β0(n),β1(n−1),…,βn(0)

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

Consider a Bézier curve with control points P0,…,Pn. Connecting the consecutive points we create the control polygon of the curve. Now, subdivide 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 𝐑n, we may project the point into 𝐑n+1; for example, a curve in three dimensions may have its control points {(xi,yi,zi)} and weights {wi} projected to the weighted control points {(wixi,wiyi,wizi,wi)}. The algorithm then proceeds as usual, interpolating in 𝐑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.

Notation When doing the calculation by hand it is useful to write down the coefficients in a triangle scheme as β0=β0(0)β0(1)β1=β1(0)⋱⋮⋮β0(n)βn−1=βn−1(0)βn−1(1)βn=βn(0) When choosing a point t0 to evaluate a Bernstein polynomial we can use the two diagonals of the triangle scheme to construct a division of the polynomial B(t)=∑i=0nβi(0)bi,n(t),t∈[0,1] into B1(t)=∑i=0nβ0(i)bi,n(tt0),t∈[0,t0] and B2(t)=∑i=0nβi(n−i)bi,n(t−t01−t0),t∈[t0,1].

Bézier curve

When evaluating a Bézier curve of degree n in 3-dimensional space with n + 1 control points Pi 𝐁(t)=∑i=0n𝐏ibi,n(t), t∈[0,1] with 𝐏i:=(xiyizi), we split the Bézier curve into three separate equations B1(t)=∑i=0nxibi,n(t),t∈[0,1]B2(t)=∑i=0nyibi,n(t),t∈[0,1]B3(t)=∑i=0nzibi,n(t),t∈[0,1] which we evaluate individually using De Casteljau's algorithm.

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−t0)+β1(0)t0=β0(1−t0)+β1t0β1(1)=β1(0)(1−t0)+β2(0)t0=β1(1−t0)+β2t0 and with the second iteration the recursion stops with β0(2)=β0(1)(1−t0)+β1(1)t0 =β0(1−t0)(1−t0)+β1t0(1−t0)+β1(1−t0)t0+β2t0t0 =β0(1−t0)2+β12t0(1−t0)+β2t02 which is the expected Bernstein polynomial of degree 2.

Implementations Here are example implementations of De Casteljau's algorithm in various programming languages.

Haskell

Python

Java

Code example in JavaScript The following JavaScript function applies De Casteljau's algorithm to an array of control points or poles as originally named by De Casteljau to reduce them one by one until reaching a point in the curve for a given t between 0 for the first point of the curve and 1 for the last one

For example,

returns the array

which yields the points and segments plotted below:

See also Bézier curve De Boor's algorithm Horner scheme to evaluate polynomials in monomial form Clenshaw algorithm to evaluate polynomials in Chebyshev form

References

Farin, Gerald E.; Hansford, Dianne (2000). The Essentials of CAGD. Natick, MA: A.K. Peters. ISBN 978-1-56881-123-9.

External links Piecewise linear approximation of Bézier curves – description of De Casteljau's algorithm, including a criterion to determine when to stop the recursion Bézier Curves and Picasso – description and illustration of De Casteljau's algorithm applied to cubic Bézier curves de Casteljau's algorithm – implementation help and interactive demonstration of the algorithm

Illustrations

De Casteljau's algorithm illustration
De Casteljau's algorithm illustration
De Casteljau's algorithm illustration
De Casteljau's algorithm: Intermediate line segments obtained by recursively applying linear interpolation to adjacent points
Intermediate line segments obtained by recursively applying linear interpolation to adjacent points

Worked examples

Example 1 — a first encounter with De Casteljau's algorithm

Start with the simplest possible case. Write down what De Casteljau's algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to De Casteljau's algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about De Casteljau's algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of De Casteljau's algorithm

In research
De Casteljau's algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses De Casteljau's algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
De Casteljau's algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Numerical analysis, Splines (mathematics), so understanding it makes those chapters shorter.
In everyday life
Look for De Casteljau's algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “De Casteljau's algorithm” →

How to study De Casteljau's algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what De Casteljau's algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain De Casteljau's algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is De Casteljau's algorithm in simple terms?

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…

Why does De Casteljau's algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study De Casteljau's algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on De Casteljau's algorithm.

Tags

  • Numerical analysis
  • Splines (mathematics)

Keep exploring