|
In the mathematical field of numerical analysis, a Bézier curve is a parametric curve important in computer graphics. Generalizations of Bézier curves to higher dimensions are called Bézier surfaces, of which the Bézier triangle is a special case. Bézier curves were widely publicised in 1962 by the French engineer Pierre Bézier, who used them to design automobile bodies. The curves were first developed in 1959 by Paul de Casteljau using de Casteljau's algorithm, a numerically stable method to evaluate Bézier curves. Linear Bézier curves Given points P0 and P1, a linear Bézier curve is just a straight line between those two points. The curve is given by Quadratic Bézier curves A quadratic Bézier curve is the path traced by the function B(t), given points P0, P1, and P2, TrueType fonts use Bézier splines composed of the quadratic Bézier curves. Cubic Bézier curves Four points P0, P1, P2 and P3 in the plane or in three-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 P0 and P1 determines "how long" the curve moves into direction P2 before turning towards P3. The parametric form of the curve is: Modern imaging systems like PostScript, Asymptote and Metafont use Bézier splines composed of cubic Bézier curves for drawing curved shapes. Generalization The Bézier curve of degree can be generalized as follows. Given points P0, P1,..., Pn, the Bézier curve is For example, for : This formula can be expressed recursively as follows: Let denote the Bézier curve determined by the points P0, P1,..., Pn. Then In words, the degree Bézier curve is an interpolation between two degree Bézier curves. Terminology Some terminology is associated with these parametric curves. We have where the polynomials are known as Bernstein basis polynomials of degree n, defining 00 = 1. 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. Notes Linear curves Quadratic curves Higher order curves Application in computer graphics
Code example The following code is a simple practical example showing how to plot a cubic Bezier curve in the C programming language. Note, this simply computes the coefficients of the polynomial and runs through a series of t values from 0 to 1 — in practice this is not how it is usually done - a recursive solution is often faster, taking fewer processor cycles at the expense of requiring more memory temporarily. However the direct method illustrated here is easier to understand and produces the same result. The following code has been factored to make its operation clear — an optimization in practice would be to compute the coefficients once and then re-use the result for the actual loop that computes the curve points — here they are recomputed every time, which is less efficient but helps to clarify the code. The resulting curve can be plotted by drawing lines between successive points in the curve array — the more points, the smoother the curve. On some architectures, the code below can also be optimized by dynamic programming. E.g. since dt is constant, cx
typedef struct Point2D; / cp0 is the starting point, or P0 in the above diagram cp1 is the first control point, or P1 in the above diagram cp2 is the second control point, or P2 in the above diagram cp3 is the end point, or P3 in the above diagram t is the parameter value, 0 <= t <= 1 Point2D PointOnCubicBezier( Point2D / points generated from the control points cp. Caller must allocate sufficient memory for the result, which is void ComputeBezier( Point2D Another application for Bézier curves is to describe paths for the motion of objects in animations, etc. Here, the x, y positions of the curve are not used to plot the curve but to position a graphic. When used in this fashion, the distance between successive points can become important, and in general these are not spaced equally — points will cluster more tightly where the control points are close to each other, and spread more widely for more distantly positioned control points. If linear motion speed is required, further processing is needed to spread the resulting points evenly along the desired path. Rational Bézier curves The rational Bézier 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. Given n + 1 control points Pi, the rational Bézier curve can be described by: mathbf(t) = rac or simply mathbf(t) = rac . See also | |||||||||
|
| ||||||||||
![]() |
|
| |