A Bézier curve [1] is a parametric curve used in computer graphics and related fields.[2] 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 that otherwise has no mathematical representation or whose representation is unknown or too complicated. The Bézier curve is named after French engineer Pierre Bézier (1910–1999), who used it in the 1960s for designing curves for the bodywork of Renault cars.[3] Other uses include the design of computer fonts and animation. Bézier curves can be combined to form a Bézier spline, or generalized to higher dimensions to form Bézier surfaces. The Bézier triangle is a special case of the latter.
In vector graphics, Bézier curves are used to model smooth curves that can be scaled indefinitely. "Paths", as they are commonly referred to in image manipulation programs, are combinations of linked Bézier curves. Paths are not bound by the limits of rasterized images and are intuitive to modify.
Bézier curves are also used in the time domain, particularly in animation,[4] user interface design and smoothing cursor trajectory in eye gaze controlled interfaces.[5] For example, a Bézier curve can be used to specify the velocity over time of an object such as an icon moving from A to B, rather than simply moving at a fixed number of pixels per step. When animators or interface designers talk about the "physics" or "feel" of an operation, they may be referring to the particular Bézier curve used to control the velocity over time of the move in question.
This also applies to robotics where the motion of a welding arm, for example, should be smooth to avoid unnecessary wear.
The mathematical basis for Bézier curves—the Bernstein polynomials—was established in 1912, but the polynomials were not applied to graphics until some 50 years later when mathematician Paul de Casteljau in 1959 developed de Casteljau's algorithm, a numerically stable method for evaluating the curves, and became the first to apply them to computer-aided design at French automaker Citroën.[6] De Casteljau's method was patented in France but not published until the 1980s[7] while the Bézier polynomials were widely publicised in the 1960s by the French engineer Pierre Bézier, who discovered them independently and used them to design automobile bodies at Renault.
A Bézier curve is defined by a set of control points P0 through Pn, where n is called the order of the curve (n = 1 for linear, 2 for quadratic, 3 for cubic, etc.). The first and last control points are always the endpoints of the curve; however, the intermediate control points generally do not lie on the curve. The sums in the following sections are to be understood as affine combinations – that is, the coefficients sum to 1.
Given distinct points P0 and P1, a linear Bézier curve is simply a line between those two points. The curve is given by
B(t)=P0+t(P1-P0)=(1-t)P0+tP1, 0\let\le1
This is the simplest and is equivalent to linear interpolation.[8] The quantity
P1-P0
A quadratic Bézier curve is the path traced by the function B(t), given points P0, P1, and P2,
B(t)=(1-t)[(1-t)P0+tP1]+t[(1-t)P1+tP2], 0\let\le1
which can be interpreted as the linear interpolant of corresponding points on the linear Bézier curves from P0 to P1 and from P1 to P2 respectively. Rearranging the preceding equation yields:
B(t)=(1-t)2P0+2(1-t)tP1+t2P2, 0\let\le1.
This can be written in a way that highlights the symmetry with respect to P1:
B(t)=P1+(1-t)2(P0-P1)+t2(P2-P1), 0\let\le1.
Which immediately gives the derivative of the Bézier curve with respect to t:
B'(t)=2(1-t)(P1-P0)+2t(P2-P1),
from which it can be concluded that the tangents to the curve at P0 and P2 intersect at P1. As t increases from 0 to 1, the curve departs from P0 in the direction of P1, then bends to arrive at P2 from the direction of P1.
The second derivative of the Bézier curve with respect to t is
B''(t)=2(P2-2P1+P0).
Four points P0, P1, P2 and P3 in the plane or in higher-dimensional space define a cubic Bézier curve.The curve starts at P0 going toward P1 and arrives at P3 coming from the direction of P2. Usually, it will not pass through P1 or P2; these points are only there to provide directional information. The distance between P1 and P2 determines "how far" and "how fast" the curve moves towards P1 before turning towards P2.
Writing BPi,Pj,Pk(t) for the quadratic Bézier curve defined by points Pi, Pj, and Pk, the cubic Bézier curve can be defined as an affine combination of two quadratic Bézier curves:
B(t)=
(1-t)B | |
P0,P1,P2 |
(t)+t
B | |
P1,P2,P3 |
(t), 0\let\le1.
The explicit form of the curve is:
B(t)=
3P | |
(1-t) | |
3, 0 |
\let\le1.
For some choices of P1 and P2 the curve may intersect itself, or contain a cusp.
Any series of 4 distinct points can be converted to a cubic Bézier curve that goes through all 4 points in order.Given the starting and ending point of some cubic Bézier curve, and the points along the curve corresponding to t = 1/3 and t = 2/3, the control points for the original Bézier curve can be recovered.[9]
The derivative of the cubic Bézier curve with respect to t is
B'(t)=
2(P | |
3(1-t) | |
1 |
-P0)+6(1-t)t(P2-P1)+
2(P | |
3t | |
3 |
-P2).
The second derivative of the Bézier curve with respect to t is
B''(t)=6(1-t)(P2-2P1+P0)+6t(P3-2P2+P1).
Bézier curves can be defined for any degree n.
A recursive definition for the Bézier curve of degree n expresses it as a point-to-point linear combination (linear interpolation) of a pair of corresponding points in two Bézier curves of degree n − 1.
Let
B | |
P0P1\ldotsPk |
B | |
P0 |
(t)=P0,and
B(t)=
B | |
P0P1\ldotsPn |
(t)=
(1-t)B | |
P0P1\ldotsPn-1 |
(t)+
tB | |
P1P2\ldotsPn |
(t)
This recursion is elucidated in the animations below.
The formula can be expressed explicitly as follows (where t0 and (1-t)0 are extended continuously to be 1 throughout [0,1]):
\begin{align} B(t)&=
n | |
\sum | |
i=0 |
{n\choosei}(1-t)n
iP | |
t | |
i |
\\ &=(1-
nP | |
t) | |
0 |
+{n\choose1}(1-t)ntP1+ … +{n\choosen-1}(1-t)tnPn+
nP | |
t | |
n, |
&&0\leqslantt\leqslant1 \end{align}
where
\scriptstyle{n\choosei}
For example, when n = 5:
\begin{align} B(t)&=(1-
5P | |
t) | |
0 |
+5t(1-
4P | |
t) | |
1 |
+10t2(1-t)3P2+10t3(1-t)2P3+5t4(1-t)P4+t5P5,&&0\leqslantt\leqslant1. \end{align}
Some terminology is associated with these parametric curves. We have
B(t)=
n | |
\sum | |
i=0 |
bi,(t)Pi, 0\let\le1
where the polynomials
bi,n(t)={n\choosei}ti(1-t)n, i=0,\ldots,n
are known as Bernstein basis polynomials of degree n.
t0 = 1, (1 − t)0 = 1, and the binomial coefficient,
\scriptstyle{n\choosei}
{n\choosei}=
n! | |
i!(n-i)! |
.
The points Pi are called control points for the Bézier curve. The polygon formed by connecting the Bézier points with lines, starting with P0 and finishing with Pn, is called the Bézier polygon (or control polygon). The convex hull of the Bézier polygon contains the Bézier curve.
Sometimes it is desirable to express the Bézier curve as a polynomial instead of a sum of less straightforward Bernstein polynomials. Application of the binomial theorem to the definition of the curve followed by some rearrangement will yield
B(t)=
n | |
\sum | |
j=0 |
{tjCj}
Cj=
n! | |
(n-j)! |
j | |
\sum | |
i=0 |
(-1)iPi | |
i!(j-i)! |
j-1 | |
= \prod | |
m=0 |
(n-m)
j | |
\sum | |
i=0 |
(-1)iPi | |
i!(j-i)! |
.
This could be practical if
Cj
B(t)
P0
Pn
|
|
t=360\circ/n
n>2
P0,...,Pn
P'0,...,P'n+1
P'k=\tfrac{k}{n+1}Pk-1+\left(1-\tfrac{k}{n+1}\right)Pk
\forallk=0,1,...,n,n+1
Pn+1:=P0
P-1:=Pn
A quadratic Bézier curve is also a segment of a parabola. As a parabola is a conic section, some sources refer to quadratic Béziers as "conic arcs". With reference to the figure on the right, the important features of the parabola can be derived as follows:[12]
The derivative for a curve of order n is
B'(t)=n
n-1 | |
\sum | |
i=0 |
bi,n-1(t)(Pi+1-Pi).
For quadratic Bézier curves one can construct intermediate points Q0 and Q1 such that as t varies from 0 to 1:
For higher-order curves one needs correspondingly more intermediate points. For cubic curves one can construct intermediate points Q0, Q1, and Q2 that describe linear Bézier curves, and points R0 and R1 that describe quadratic Bézier curves:
For fourth-order curves one can construct intermediate points Q0, Q1, Q2 and Q3 that describe linear Bézier curves, points R0, R1 and R2 that describe quadratic Bézier curves, and points S0 and S1 that describe cubic Bézier curves:
For fifth-order curves, one can construct similar intermediate points.
These representations rest on the process used in De Casteljau's algorithm to calculate Bézier curves.[13]
The curve at a fixed offset from a given Bézier curve, called an offset or parallel curve in mathematics (lying "parallel" to the original curve, like the offset between rails in a railroad track), cannot be exactly formed by a Bézier curve (except in some trivial cases). In general, the two-sided offset curve of a cubic Bézier is a 10th-order algebraic curve[14] and more generally for a Bézier of degree n the two-sided offset curve is an algebraic curve of degree 4n − 2.[15] However, there are heuristic methods that usually give an adequate approximation for practical purposes.[16]
In the field of vector graphics, painting two symmetrically distanced offset curves is called stroking (the Bézier curve or in general a path of several Bézier segments).[14] The conversion from offset curves to filled Bézier contours is of practical importance in converting fonts defined in Metafont, which require stroking of Bézier curves, to the more widely used PostScript type 1 fonts, which only require (for efficiency purposes) the mathematically simpler operation of filling a contour defined by (non-self-intersecting) Bézier curves.[17]
A Bézier curve of degree n can be converted into a Bézier curve of degree n + 1 with the same shape. This is useful if software supports Bézier curves only of specific degree. For example, systems that can only work with cubic Bézier curves can implicitly work with quadratic curves by using their equivalent cubic representation.
To do degree elevation, we use the equality
B(t)=(1-t)B(t)+tB(t).
bi,n(t)Pi
\begin{align} (1-t)2P0+2(1-t)tP1+t2P2&=(1-t)3P0+2(1-t)2tP1+(1-t)t2P2+(1-t)2tP0+2(1-t)t2P1+t3P2\\ &=(1-t)3P0+(1-t)2t\left(P0+2P1\right)+(1-t)t2\left(2P1+P2\right)+t3P2\\ &=(1-t)3P0+3(1-t)2t\tfrac{1}{3}\left(P0+2P1\right)+3(1-t)t2\tfrac{1}{3}\left(2P1+P2\right)+t3P2 \end{align}
In other words, the original start and end points are unchanged. The new control points are
P'1=\tfrac{1}{3}\left(P0+2P1\right)
P'2=\tfrac{1}{3}\left(2P1+P2\right)
For arbitrary n we use equalities
\begin{cases}{n+1\choosei}(1-t)bi,={n\choosei}bi,\ {n+1\choosei+1}tbi,={n\choosei}bi\end{cases} \implies \begin{cases}(1-t)bi,=
n+1-i | |
n+1 |
bi,\ tbi,=
i+1 | |
n+1 |
bi\end{cases}
Therefore:
\begin{align} B(t)&=(1-
n | |
t)\sum | |
i=0 |
bi,(t)Pi+
n | |
t\sum | |
i=0 |
bi,(t)Pi\\ &=
n | |
\sum | |
i=0 |
n+1-i | |
n+1 |
bi,(t)Pi+
n | |
\sum | |
i=0 |
i+1 | |
n+1 |
bi(t)Pi\\ &=
n+1 | ||
\sum | \left( | |
i=0 |
i | |
n+1 |
Pi+
n+1-i | |
n+1 |
Pi\right)bi,(t)\\ &=
n+1 | |
\sum | |
i=0 |
bi,(t)P'i \end{align}
introducing arbitrary
P-1
Pn
Therefore, new control points are[18]
P'i=
i | |
n+1 |
Pi+
n+1-i | |
n+1 |
Pi, i=0,\ldots,n+1.
The concept of degree elevation can be repeated on a control polygon R to get a sequence of control polygons R, R1, R2, and so on. After r degree elevations, the polygon Rr has the vertices P0,r, P1,r, P2,r, ..., Pn+r,r given by [18]
Pi,r=
n | |
\sum | |
j=0 |
Pj\tbinomnj
\tbinom{r | |
i-j |
It can also be shown that for the underlying Bézier curve B,
\limrRr |
=B.
Degree reduction can only be done exactly when the curve in question is originally elevated from a lower degree.[19] A number of approximation algorithms have been proposed and used in practice.[20] [21]
The rational Bézier curve adds adjustable weights to provide closer approximations to arbitrary shapes. The numerator is a weighted Bernstein-form Bézier curve and the denominator is a weighted sum of Bernstein polynomials. Rational Bézier curves can, among other uses, be used to represent segments of conic sections exactly, including circular arcs.[22]
Given n + 1 control points P0, ..., Pn, the rational Bézier curve can be described by
B(t)=
| ||||||||||
|
,
B(t)=
| ||||||||||
t |
i(1-t)n-iPiwi } { \sum
n | |
i=0 |
{n\choosei}ti(1-t)n-iwi }.
Bézier curves are widely used in computer graphics to model smooth curves. As the curve is completely contained in the convex hull of its control points, the points can be graphically displayed and used to manipulate the curve intuitively. Affine transformations such as translation and rotation can be applied on the curve by applying the respective transform on the control points of the curve.
Quadratic and cubic Bézier curves are most common. Higher degree curves are more computationally expensive to evaluate. When more complex shapes are needed, low order Bézier curves are patched together, producing a composite Bézier curve. A composite Bézier curve is commonly referred to as a "path" in vector graphics languages (like PostScript), vector graphics standards (like SVG) and vector graphics programs (like Artline, Timeworks Publisher, Adobe Illustrator, CorelDraw, Inkscape, and Allegro). In order to join Bézier curves into a composite Bézier curve without kinks, a property called G1 continuity suffices to force the control point at which two constituent Bézier curves meet to lie on the line defined by the two control points on either side.
The simplest method for scan converting (rasterizing) a Bézier curve is to evaluate it at many closely spaced points and scan convert the approximating sequence of line segments. However, this does not guarantee that the rasterized output looks sufficiently smooth, because the points may be spaced too far apart. Conversely it may generate too many points in areas where the curve is close to linear. A common adaptive method is recursive subdivision, in which a curve's control points are checked to see if the curve approximates a line to within a small tolerance. If not, the curve is subdivided parametrically into two segments, 0 ≤ t ≤ 0.5 and 0.5 ≤ t ≤ 1, and the same procedure is applied recursively to each half. There are also forward differencing methods, but great care must be taken to analyse error propagation.
Analytical methods where a Bézier is intersected with each scan line involve finding roots of cubic polynomials (for cubic Béziers) and dealing with multiple roots, so they are not often used in practice.[24]
The rasterisation algorithm used in Metafont is based on discretising the curve, so that it is approximated by a sequence of "rook moves" that are purely vertical or purely horizontal, along the pixel boundaries. To that end, the plane is first split into eight 45° sectors (by the coordinate axes and the two lines
y=\pmx
t
There is also a modified curve form of Bresenham's line drawing algorithm by Zingl that performs this rasterization by subdividing the curve into rational pieces and calculating the error at each pixel location such that it either travels at a 45° angle or straight depending on compounding error as it iterates through the curve. This reduces the next step calculation to a series of integer additions and subtractions.[26]
In animation applications, such as Adobe Flash and Synfig, Bézier curves are used to outline, for example, movement. Users outline the wanted path in Bézier curves, and the application creates the needed frames for the object to move along the path.[27] [28]
In 3D animation, Bézier curves are often used to define 3D paths as well as 2D curves for keyframe interpolation.[29] Bézier curves are now very frequently used to control the animation easing in CSS, JavaScript, JavaFx and Flutter SDK.
TrueType fonts use composite Bézier curves composed of quadratic Bézier curves. Other languages and imaging tools (such as PostScript, Asymptote, Metafont, and SVG) use composite Béziers composed of cubic Bézier curves for drawing curved shapes. OpenType fonts can use either kind of curve, depending on which font technology underlies the OpenType wrapper.[30]
Font engines, like FreeType, draw the font's curves (and lines) on a pixellated surface using a process known as font rasterization.[31] Typically font engines and vector graphics engines render Bézier curves by splitting them recursively up to the point where the curve is flat enough to be drawn as a series of linear or circular segments. The exact splitting algorithm is implementation dependent, only the flatness criteria must be respected to reach the necessary precision and to avoid non-monotonic local changes of curvature. The "smooth curve" feature of charts in Microsoft Excel also uses this algorithm.[32]
Because arcs of circles and ellipses cannot be exactly represented by Bézier curves, they are first approximated by Bézier curves, which are in turn approximated by arcs of circles. This is inefficient as there exists also approximations of all Bézier curves using arcs of circles or ellipses, which can be rendered incrementally with arbitrary precision. Another approach, used by modern hardware graphics adapters with accelerated geometry, can convert exactly all Bézier and conic curves (or surfaces) into NURBS, that can be rendered incrementally without first splitting the curve recursively to reach the necessary flatness condition. This approach also preserves the curve definition under all linear or perspective 2D and 3D transforms and projections.
Because the control polygon allows to tell whether or not the path collides with any obstacles, Bézier curves are used in producing trajectories of the end effectors.[33] Furthermore, joint space trajectories can be accurately differentiated using Bézier curves. Consequently, the derivatives of joint space trajectories are used in the calculation of the dynamics and control effort (torque profiles) of the robotic manipulator.
For a survey see Elber . G. . Comparing offset curve approximation methods . IEEE Computer Graphics and Applications . May 1997 . 17 . 3 . 62–71 . 10.1109/38.586019.