Skip to main content

De Casteljau Algorithm for Bézier Curves

·242 words·2 mins·
De Casteljau Bezier Curves Computer Graphics
Tarik Abu Mukh
Author
Tarik Abu Mukh
I am a 23 year old software engineer from Germany. I am passionate about Astrophotography, Software Developement, and Physics. The crossroads where these three meet, is where I feel most at home.
Table of Contents

Explanation of De Casteljau Algorithm for Bézier Curves
#

The De Casteljau algorithm is a method for evaluating points on a Bézier curve, which is widely used in computer graphics and animation due to its smoothness and flexibility.

Mathematical Basis
#

A Bézier curve with \( n + 1 ) control points \( P_0, P_1, \ldots, P_n \) is defined by the parameter \( t \in [0, 1] \):

\( B(t) = \sum_{i=0}^{n} {n \choose i} (1-t)^{n-i} t^i P_i \)

The De Casteljau algorithm provides a recursive way to compute points on this curve by interpolating between control points.

Algorithm Steps
#

  1. Initialization: Start with the given set of control points \( P_0, P_1, \ldots, P_n \).

  2. Recursive Interpolation:

    • For each iteration, interpolate between pairs of adjacent control points based on the parameter \( t \).
    • Compute new points until only one point remains, which gives the point on the Bézier curve at parameter \( t \).
  3. Visualization:

    • Draw the initial control points as red circles on a canvas.
    • Draw lines connecting these points in gray to show intermediate steps of the algorithm.
    • Calculate the Bézier curve up to the current frame and draw it in white, emphasizing its construction from the control points.

Example Animation
#

Below is an interactive animation using the De Casteljau algorithm with 5 control points. Each frame of the animation shows the current state of interpolation, highlighting how the Bézier curve is constructed step by step.