HOME

TheInfoList



OR:

In the
mathematical Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
field of
numerical analysis Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic computation, symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). It is the study of ...
, De Casteljau's algorithm is a
recursive Recursion (adjective: ''recursive'') occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics ...
method to evaluate polynomials in Bernstein form or
Bézier curve A Bézier curve ( ) is a parametric curve used in computer graphics and related fields. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. Usually the curve is intended to approximate a real-world shape t ...
s, named after its inventor
Paul de Casteljau Paul de Casteljau (19 November 1930 – 24 March 2022) was a French physicist and mathematician. In 1959, while working at Citroën, he developed an algorithm for evaluating calculations on a certain family of curves, which would later be formal ...
. 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. Although the algorithm is slower for most architectures when compared with the direct approach, it is more
numerically stable In the mathematical subfield of numerical analysis, numerical stability is a generally desirable property of numerical algorithms. The precise definition of stability depends on the context. One is numerical linear algebra and the other is algorit ...
.


Definition

A Bézier curve B (of degree n, with control points \beta_0, \ldots, \beta_n) can be written in Bernstein form as follows :B(t) = \sum_^\beta_b_(t), where b is a Bernstein basis polynomial :b_(t) = (1-t)^t^i. The curve at point t_0 can be evaluated with the
recurrence relation In mathematics, a recurrence relation is an equation according to which the nth term of a sequence of numbers is equal to some combination of the previous terms. Often, only k previous terms of the sequence appear in the equation, for a parameter ...
:\beta_i^ := \beta_i,\ \ i=0,\ldots,n :\beta_i^ := \beta_i^ (1-t_0) + \beta_^ t_0,\ \ i = 0,\ldots,n-j,\ \ j= 1,\ldots,n Then, the evaluation of B at point t_0 can be evaluated in \binom operations. The result B(t_0) is given by :B(t_0) = \beta_0^. Moreover, the Bézier curve B can be split at point t_0 into two curves with respective control points: :\beta_0^,\beta_0^,\ldots,\beta_0^ :\beta_0^,\beta_1^,\ldots,\beta_n^


Example implementation

Here is an example implementation of De Casteljau's algorithm in
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
: deCasteljau :: Double -> Double, Double)-> (Double, Double) deCasteljau t = b deCasteljau t coefs = deCasteljau t reduced where reduced = zipWith (lerpP t) coefs (tail coefs) lerpP t (x0, y0) (x1, y1) = (lerp t x0 x1, lerp t y0 y1) lerp t a b = t * b + (1 - t) * a An example implementation of De Casteljau's algorithm in
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
: def de_casteljau(t, coefs): beta = for c in coefs# values in this list are overridden n = len(beta) for j in range(1, n): for k in range(n - j): beta = beta * (1 - t) + beta + 1* t return beta An example implementation of De Casteljau's algorithm in
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
: // Example: lerp(0.5, 0.0, 1.0)

0.5 let lerp = (t, p1, p2) => (1 - t) * p1 + t * p2; // Example: reduce(0.5, ... .0, 1.0, 2.0, 3.0

.5, 1.5, 2.5let reduce = (t, p1, p2, ...ps) => ps.length > 0 ? erp(t, p1, p2), ...reduce(t, p2, ...ps) : erp(t, p1, p2) // Example: deCasteljau(0.5, .0, 1.0, 2.0, 3.0

1.5 let deCasteljau = (t, ps) => ps.length > 1 ? deCasteljau(t, reduce(t, ...ps)) : ps


Notes

When doing the calculation by hand it is useful to write down the coefficients in a triangle scheme as : \begin \beta_0 & = \beta_0^ & & & \\ & & \beta_0^ & & \\ \beta_1 & = \beta_1^ & & & \\ & & & \ddots & \\ \vdots & & \vdots & & \beta_0^ \\ & & & & \\ \beta_ & = \beta_^ & & & \\ & & \beta_^ & & \\ \beta_n & = \beta_n^ & & & \\ \end When choosing a point ''t''0 to evaluate a Bernstein polynomial we can use the two diagonals of the triangle scheme to construct a division of the polynomial :B(t) = \sum_^n \beta_i^ b_(t), \quad t \in ,1/math> into :B_1(t) = \sum_^n \beta_0^ b_\left(\frac\right)\!, \quad t \in ,t_0/math> and :B_2(t) = \sum_^n \beta_i^ b_\left(\frac\right)\!, \quad t \in _0,1


Example

We want to evaluate the Bernstein polynomial of degree 2 with the Bernstein coefficients :\beta_0^ = \beta_0 :\beta_1^ = \beta_1 :\beta_2^ = \beta_2 at the point ''t''0. We start the recursion with :\beta_0^ = \beta_0^ (1-t_0) + \beta_1^t_0 = \beta_0(1-t_0) + \beta_1 t_0 :\beta_1^ = \beta_1^ (1-t_0) + \beta_2^t_0 = \beta_1(1-t_0) + \beta_2 t_0 and with the second iteration the recursion stops with : \begin \beta_0^ & = \beta_0^ (1-t_0) + \beta_1^ t_0 \\ \ & = \beta_0(1-t_0) (1-t_0) + \beta_1 t_0 (1-t_0) + \beta_1(1-t_0)t_0 + \beta_2 t_0 t_0 \\ \ & = \beta_0 (1-t_0)^2 + \beta_1 2t_0(1-t_0) + \beta_2 t_0^2 \end 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 P''i'' :\mathbf(t) = \sum_^ \mathbf_i b_(t),\ t \in ,1/math> with :\mathbf_i := \begin x_i \\ y_i \\ z_i \end, we split the Bézier curve into three separate equations :B_1(t) = \sum_^ x_i b_(t),\ t \in ,1/math> :B_2(t) = \sum_^ y_i b_(t),\ t \in ,1/math> :B_3(t) = \sum_^ z_i b_(t),\ t \in ,1/math> 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 \mathbf^n, we may project the point into \mathbf^; for example, a curve in three dimensions may have its control points \ and weights \ projected to the weighted control points \. The algorithm then proceeds as usual, interpolating in \mathbf^4. The resulting four-dimensional points may be projected back into three-space with a
perspective divide In linear algebra, linear transformations can be represented by matrices. If T is a linear transformation mapping \mathbb^n to \mathbb^m and \mathbf x is a column vector with n entries, then T( \mathbf x ) = A \mathbf x for some m \times n matrix ...
. In general, operations on a rational curve (or surface) are equivalent to operations on a nonrational curve in a
projective space In mathematics, the concept of a projective space originated from the visual effect of perspective, where parallel lines seem to meet ''at infinity''. A projective space may thus be viewed as the extension of a Euclidean space, or, more generally ...
. This representation as the "weighted control points" and weights is often convenient when evaluating rational curves.


See also

*
Bézier curve A Bézier curve ( ) is a parametric curve used in computer graphics and related fields. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. Usually the curve is intended to approximate a real-world shape t ...
s *
De Boor's algorithm In the mathematical subfield of numerical analysis de Boor's algorithmC. de Boor 971 "Subroutine package for calculating with B-splines", Techn.Rep. LA-4728-MS, Los Alamos Sci.Lab, Los Alamos NM; p. 109, 121. is a polynomial-time and numerically sta ...
*
Horner scheme In mathematics and computer science, Horner's method (or Horner's scheme) is an algorithm for polynomial evaluation. Although named after William George Horner, this method is much older, as it has been attributed to Joseph-Louis Lagrange by Hor ...
to evaluate polynomials in
monomial form In mathematics the monomial basis of a polynomial ring is its basis (as a vector space or free module over the field or ring of coefficients) that consists of all monomials. The monomials form a basis because every polynomial may be uniquely wr ...
*
Clenshaw algorithm In numerical analysis, the Clenshaw algorithm, also called Clenshaw summation, is a recursive method to evaluate a linear combination of Chebyshev polynomials. Note that this paper is written in terms of the ''Shifted'' Chebyshev polynomials of th ...
to evaluate polynomials in
Chebyshev form The Chebyshev polynomials are two sequences of polynomials related to the cosine and sine functions, notated as T_n(x) and U_n(x). They can be defined in several equivalent ways, one of which starts with trigonometric functions: The Chebyshe ...


References

*Farin, Gerald & Hansford, Dianne (2000). ''The Essentials of CAGD''. Natic, MA: A K Peters, Ltd. {{ISBN, 1-56881-123-3


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
Bezier 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. Splines (mathematics) Numerical analysis Articles with example Haskell code