3rd degree Bezier curve and its control polygon
Bézier curves of degrees 1, 2 and 3 (red) and the associated control polygons (gray). Another control point (blue) was added from left to right. You can see how the curve varies its direction and / or curvature when inserting / changing a control point.
The Bézier curve [ be'zje… ] is a parametrically modeled curve that is an important tool when describing free-form curves and surfaces .
In computer graphics , Bézier curves are often used because of their optical elegance and relatively easy mathematical manageability. They are used to define curves and surfaces in vector graphics . Possible applications are e.g. B. in Computer Aided Design , when creating illustrations (see e.g. SVG ) or describing fonts (e.g. Postscript , Type1 , TrueType and CFF- OpenType ).
The Bézier curve was developed independently by Pierre Bézier at Renault and Paul de Casteljau at Citroën in the early 1960s for computer-aided design . Paul de Casteljau made the discovery earlier, but Citroën withheld its research as a trade secret until the end of the 1960s.
Generalizations of the concept of the Bézier curves lead to the Bézier surfaces.
Motivation, definition
Numerically simple curves in the plane are those that are described using a parametric representation , where and are polynomials in . Is
-
,
and if you bet, the curve can be cleared through
-
describe.
In general, the coefficient points don't say much about the shape of the curve. Only (point of the curve) and (tangent vector) have concrete geometric meanings. This changes if the polynomials are not represented in the monomial basis but in the following Bernstein basis:
It is now fixed and the vectors describe a plane or spatial polygon. Then is called
a Bezier curve of (maximum) degree . The points
are called the control points of the Bezier curve.
Properties of the Bernstein polynomials:
-
for for
- The Bernstein polynomial has exactly one maximum, namely at the point D. h. a slight change in the point only results in a substantial change in the curve in the vicinity of .
Properties of a Bézier curve:
-
is the starting point, the end point
-
is the direction of the tangent in the point is the direction of the tangent in the point
- The polygon indicates an approximate course of the curve.
Other properties of the amber base
The following properties are useful for studying Bezier curves:
- Relationship between the amber and monomial bases
-
(MB)
- Recursion
-
(R)
- Scaling
-
(S)
- Derivation
-
(A)
- (Note that is.)
- product
-
(P)
Further properties of a Bézier curve
Further properties of a Bézier curve are listed in the literature:
- The first summands of the Taylor polynomial at or at are for :
- A straight line intersects a Bézier curve at most as often as it intersects its control polygon (the curve is variation-reducing or has a limited fluctuation ).
- An affine transformation (displacement, scaling, rotation, shear) can be applied to the Bézier curve by transforming the control polygon (" affine invariance ").
- If all control points lie on a straight line, the Bézier curve becomes a segment (advantage over polynomial interpolation ).
- The influence of a control point on the curve is global. That means: If you move a point, the entire curve changes. Therefore, in practice, one mostly uses splines , compound curves of a fixed degree that continuously merge into one another.
- A Bézier curve can always be divided into two Bézier curves of the same order, whereby the new control points result from the old ones with the help of the De Casteljau algorithm (see section Dividing a Bezier curve ).
The De Casteljau algorithm
Calculating higher powers of is numerically unstable. The following algorithm therefore traces the calculation of a curve point back to repeated linear interpolation. In each step, a new polygon that is 1 shorter is calculated using linear interpolation (see figure). With the last interpolation, the curve point is finally created:
De Casteljau algorithm for a 3rd degree Bezier curve
For the polygon in (or
) and one , the polygon is
defined recursively for each
-
generated. Be there .
The polygon of the step is identical to the starting polygon, the polygon of the step is a point, the curve point.
From the recursion property (R) of the Bernstein polynomials follows
- For
(Proof with the help of complete induction on r.) So is
the Bezier curve with the control polygon . This method of determining a point on the Bezier curve using linear interpolations is called the De Casteljau algorithm .
The figure for shows how the intermediate polygons and finally the point of the Bezier curve are created from the control polygon with the help of the Casteljau algorithm . The new points always share the old routes on which they are located in the same ratio .
Bezier curves up to the third degree
Linear Bézier curves (n = 1):
Two control points and determine a straight line between these two points. The course of this linear Bézier "curve" is described by
Quadratic Bézier curves (n = 2):
quadratic Bezier curve with Casteljau algorithm
A quadratic Bézier curve is the path described by the function for the points , and :
The last line shows: A quadratic Bézier curve is a parabola .
Expressed using the De Casteljau algorithm:
Cubic Bézier curves (n = 3):
cubic Bézier curve with Casteljau algorithm
Cubic Bézier curves are of great importance in practice, as both B-spline curves and NURBS are converted piece by piece into cubic Bézier curves in order to be drawn efficiently using the De Casteljau algorithm . The same applies to Hermitian splines, which in their cubic form are mainly used in computer animation for interpolation between keyframes .
Expressed using the De Casteljau algorithm:
Comparison of the curve displays
Comparison between curve representations
Polynomial curves (i.e. the coordinates are polynomials with respect to ) can be described in the monomial basis , the Bernstein basis , and with the aid of the De Casteljau algorithm (continued linear interpolation). Since the coefficient points of the monomial base do not say much about the course of the curve, the representations were made with the Bernstein base (Bezier curves) and with the De Casteljau algorithm. However, the last two also have advantages and disadvantages. The De Casteljau algorithm has advantages over the Bezier representation when calculating the points (numerics). Bezier curves can be more easily examined theoretically (e.g. curvature) due to the many formal properties (see above) of the Bernstein polynomials. The numerical disadvantage of the Bezier curves (evaluation of the Bernstein polynomials) can be compensated for by a method similar to the Horner scheme :
function bezier_comp(degree: integer; coeff : r_array; t: real) : real;
{Berechnet eine Komponente einer Bezier-Kurve. (Aus FARIN: Curves and Surfaces...)}
var i,n_choose_i : integer; fact,t1,aux : real;
begin
t1:= 1-t; fact:=1; n_choose_i:= 1;
aux:= coeff[0]*t1;
for i:= 1 to degree-1 do
begin
fact:= fact*t;
n_choose_i:= n_choose_i*(degree-i+1) div i;
aux:= (aux + fact*n_choose_i*coeff[i])*t1;
end;
aux:= aux + fact*t*coeff[degree] ;
bezier_comp:= aux;
end; {bezier_comp}
Derivatives of a Bézier curve
With the help of the derivatives of the Bernstein polynomials, the 1st derivative of the Bézier curve results
:
If the tangent vectors are all started at the zero point of the coordinate system, they describe another Bézier curve with the control points .
The following applies in particular:
-
and
In order to be able to write higher derivatives clearly, one introduces the following difference operator:
It is
The -th derivative of the Bézier curve
can now be written as follows:
Especially for and you get
-
and
Elevation of a Bézier curve
An important manipulation of the representation of a given Bézier curve is the so-called degree increase. It is similar to adding terms to a polynomial
. The polynomial does not change and the (apparent) degree is increased. In the same way, a fixed Bézier curve is represented in the form
with suitable new control points. To determine the new control points, the original representation is multiplied by the factor :
So the new control points are:
Degree increases of a Bezier curve:
control polygons with one, two and 10-fold degree increase}
The main characteristics of the grade increase are:
- Repeatedly increasing the degree leads to an approximation of the Bézier curve by the control polygon.
- The greater number of control points allows more degrees of freedom to manipulate the curve.
- Several Bézier curves can be brought to a uniform degree. This is important for tensor product bezier surfaces.
- This allows quadratic Bezier curves to be displayed as cubic even if a vector drawing program (e.g. Inkscape ) or a graphics library (e.g. Cairo ) only supports cubic ones.
Division of a Bézier curve
Decomposition of a Bezier curve
A Bezier curve is usually defined for
. Be now . Then with is part of the given Bézier curve. The partial curve should now be displayed as a Bézier curve with the (same) degree with suitable control points. If one sets , the following equation must be fulfilled:
-
For
This applies to
-
(see Casteljau-Alg. and illustration)
Because
-
-
because of
-
(see property (S) of the Bernst.-Pol.)
The remaining arc is the Bézier curve with the control points
-
(see illustration)
Rational Bezier curves
Rational curves and projective curves
Bézier curves are parameterized curves whose parametric representations only use polynomials. Unfortunately, such important and geometrically simple curves as circles cannot be described by polynomial parametric representations. This disadvantage is u. a. the motive for extending the functions admissible as parameter functions to rational functions. Because every conic section has a rational representation. Because a curve with a rational representation
where the functions and polynomials are, in homogeneous coordinates the polynomial representation
possesses, plane curves with rational coefficient functions can be understood as the central projection of a Bézier curve on the embedding
plane
.
The same statement applies to curves in
. They can be understood as the central projection of a Bézier curve in
the embedding space. This means that the advantages of the Bézier representation of a polynomial curve can also be used for rational curves.
Plane rational Bezier curves
It is now fixed and the vectors describe a polygon in
. Then
a (spatial) Bézier curve of degree . The points
are the control points of the (spatial) Bézier curve. If one grasps the 1-dimensional subspaces
as points of the real projective plane with the distance line
, the affine part (projection from the zero point onto the plane ) of this projective curve is called a rational Bézier curve .
The control points of the Bézier curve can be described as follows:
-
if not on the long-distance straight and
-
if lies on the distant straight.
In the transition to inhomogeneous coordinates, a control point is mapped either to the affine point or to the far point in the direction . The point is called the actual or improper
control point of the rational Bezier curve and the number is called the
weight of the control point . A rational Bézier curve has the following affine description:
setting for actual and improper control points.
The rational Bezier curves have (among others) the following properties:
If there are actual control points or the weights of a rational Bezier curve , then the following applies
- The curve contains the control points (first or last point of the control polygon).
- The tangent in the point or has the direction or .
- Increasing the weight causes the curve to change towards the control point . (see illustration)
Summary: In
addition to the control polygon, a plane, rational Bezier curve also has the weights as design parameters. If you want to create a curve, you first define the control points and the weights . This then also defines a spatial (ordinary) Bezier curve with the control points. The projection of this curve (from the zero point) onto the xy plane ( ) then provides the plane, rational Bezier curve. A variation of the weights does not change the control points , but the (spatial) control points and thus the associated spatial Bezier curve and finally also the (planar) rational Bezier curve. If you increase a weight , the associated control point moves away from the zero point and pulls the spatial Bezier curve with it. The associated control point, however, remains unchanged. The rational Bezier curve moves towards him (see picture). If you decrease the weight, the curve moves away from the control point. If all weights are 1, the rational Bézier curve is an ordinary Bézier curve with the control points .
Conic sections as rational Bézier curves
Parable:
A Bezier curve of degree two with non-collinear checkpoints
in
is always a parabola (see above.). To represent a parabola as a (fully) rational Bezier curve, choose three non-collinear control points and set and . The latter means: The control points are actually all.
Ellipses and hyperbolas can be generated by central projection of parabolas in , whose planes do not contain the zero point, onto the embedding plane .
Hyperbola:
For the control points
describes
-
a parabola that lies on the cone with the equation (see picture). The control points and weights of the associated (plane) rational Bezier curve are:
-
or: .
are improper checkpoints. So is
and is the denominator (see above) of the rational components .
So is the associated rational Bezier curve
-
This is a rational parametric representation of a branch of the hyperbola with the equation .
The change provides a rational Bezier representation of the hyperbola .
Circle:
In the following example, the control points are the (spatial) parabola:
-
.
The Bézier curve
-
in this case lies on the cone with the equation (see illustration). The control points and weights of the corresponding rational Bezier curve are:
-
or .
is improper control point. So is
and is the denominator (see above) of the rational components .
So is the associated rational Bezier curve
-
For this is a rational parametric representation of half a unit circle.
If one sets one obtains a rational Bézier representation of the ellipse with the equation .
Application: circle approximation using cubic Bézier curves
Circles or arcs cannot be represented precisely by Bézier curves, only approximated. Such an approximation is e.g. B. necessary for the design of a Type 1 PostScript font , since only third-degree lines and Bézier curves are allowed. (However, even for larger ones, no Bézier curve -th degree runs in an arc, however small, with a radius to the center point , because it lies on the arc if the zero of the polynomial function is of degree , which occurs at most times - see error analysis .)
If you divide a circle into just two (equally large) segments and approach the semicircles using cubic Bézier curves, you will see greater deviations from the circular shape . A circle can be more closely subdivided into more segments. The smaller the swept angular range of the circle segment, the more precise the approximation by the Bézier curve. An often used, simple realization of a circle uses four quadrant arcs , which are represented as cubic Bézier curves. In order to demonstrate the improvement of the approximation by refining the subdivision, the errors of the semicircle approximation and the quarter circle approximation are compared with one another.
Notation: We investigate approximations of a circle with the following parameters:
-
is the radius of
-
is the center of
- the control points and are at a distance from the center point (i.e. on the circular line of )
-
is a real number between 0 and 1 ( would correspond to a quadratic Bézier approximation).
The additional control points and are chosen in such a way that to and to has the distance .
Example coordinates quarter circle:
As a simple example of a quarter circle approximation we choose:
- the center of the circle as ,
- the control point on the circle line as ,
- the control point on the circular line as - the line is vertical so that both lines form a quarter of a circle -,
- the control point as (on the route ),
- the control point as (on the route ).
The four control points are therefore on the edge of the square with vertices , , and . This ensures after all that the approximate line and the circle in and the same tangent have. So the curve composed of the quarter circle approximations is "smooth" in the nodes .
The cubic Bézier curve ( ) has the following shape with these control points:
A very good approximation of the upper right quadrant is obtained with , as the following consideration shows.
Failure analysis:
The deviation of the Bézier curve just given from the circle to be displayed can be quantified as follows:
A point on the Bézier curve lies on the specified circular line with a radius around the center point if ( "coordinate equation" ) applies. One defines
so that's equivalent to . is a measure of the deviation of the approximation from the circular shape.
If one then demands that the Bézier curve agrees with the circle at the bisector, one obtains
The error is zero at , otherwise everywhere positive, i.e. H. the Bézier curve is always on or outside the arc. The maximum error is at and at .
If one demands that the accumulated errors disappear over the entire curve ( can be positive as well as negative - the Bézier curve runs partly outside, partly inside the circular line - and the integral above it can result in zero), one obtains
The largest deviations are around and around . Both approximations are therefore sufficient for many areas of application.
Example coordinates semicircle:
In a Halbkreisnäherung with , , , and , with the maximum deviation . With regard to the maximum deviation, this is about 50 times worse than the quarter circle approximation.
literature
- Gerald Farin: Curves and Surfaces for CAGD. A practical guide. 5th edition. Academic Press, San Diego 2002, ISBN 1-55860-737-4
- J. Hoschek, D. Lasser: Fundamentals of geometric data processing . Vieweg + Teubner Verlag, 1989, ISBN 978-3-519-02962-5
- David Salomon: Curves and Surfaces for Computer Graphics . Springer Science + Business Media, 2006, ISBN 0-387-24196-5
- Boaswan Dzung Wong: Bézier curves: drawn and calculated . Orell Füssli Verlag, Zurich 2003, ISBN 3-280-04021-3
- Wolfgang Boehm, Gerald Farin, Jürgen Kahmann: A survey of curve and surface methods in CAGD . In: Comput. Aided Geom. Des. , 1, pp. 1-60, 1984
Web links
Four bases
More than four bases
-
TinySpline. Open source C program library for NURBS, B-splines and Bézier splines with bindings for different languages
Individual evidence
-
↑ Farin, p. 37
-
↑ Hoschek & Lasser, p. 120
-
↑ Farin p. 38
-
↑ Farin p. 40
-
^ Farin: p. 48
-
↑ Farin: p. 44
-
↑ Farin: p. 51
-
↑ Farin, p. 87
-
↑ Hoschek & Lasser p. 128
-
↑ Farin p. 231
-
↑ Hoschek & Lasser p. 143