Computer Graphics Lecture 38
CURVES IV Taqdees A. Siddiqi cs602@vu.edu.pk
Bezier Curves
The Bezier curve is an important part of almost every computer-graphics illustration program and computer-aided design system in use today
It is used in many ways, from designing the curves and surfaces of automobiles to defining the shape of letters in type fonts.
Because it is numerically the most stable of all the polynomial-based curves used in these applications, the Bezier curve is the ideal standard for representing the more complex piecewise polynomial curves.
In the early 1960s, Peter Bezier began looking for a better way to define curves and surfaces one that would be useful to a design engineer
A Geometric Construction
We can draw a Bezier curve using a simple recursive geometric construction. Let’s begin by constructing a second-degree curve.
We select three points A, B, C so that line AB is a tangent to the curve at A, and BC is tangent at C. The curve begins at A and ends at C.
Figure 1: Geometric Construction of a second-degree Bezier curve.
For any ratio, ui, we construct points D and E such that: Equation 1
On DE we construct F so that DF/DE = uj. Point F is on the curve. Repeating this process for other values of ui, we produce a series of points on a Bezier curve.
Figure 1: Geometric Construction of a second-degree Bezier curve.
Note that we must be consistent in the order in which we sub-divide AB and BC. For example here first, AB is divided into AD & DB And then BC into BE & EC And finally DE into DF & FE
To define this curve in a coordinate system, let point A = (xA, yA), B = (xB, yB)
Then coordinates of points D and E for some value of ui are Equation 2
And Equation 3
The coordinates of point F for some value of ui are Equation 4
To obtain xF and yF in terms of the coordinates of points A, B and C, for any value of ui in the unit interval, we substitute appropriately from Equation 2 and 3 into equation 4 of plane curve. After rearranging terms to simplify, we find
Equation 5
We generalize this set of equations for any point on the curve using the following substitutions:
Equation 6
And we let Equation 7
Now we can rewrite Equation 5 as
This is the set of second-degree equations for the coordinates of points on Bezier curve based on our construction
We express this construction process and Equations 8 in terms of vectors with the following substitutions.
Let the vector po represent point A, p1 point B, and p2 point C.
Form vector geometry we have , and , if we let we see that
Equation 9
We rearrange terms to obtain a more compact vector equation of a second degree Bezier curve:
Equation 10
Where the points p0, p1 and p2 are called control points, and p is the point on the curve. The ratio u is the parametric variable that takes its value in the range [0,1]
Later we will see that this equation is an example of a Bernstein polynomial.
Similar constructions apply to Bezier curves of any degree Similar constructions apply to Bezier curves of any degree. In fact the degree of a Bezier curve is equal to n-1, where n is the number of control points.
Figure 2 shows the construction of point on a cubic Bezier curve, which requires four control points A, B, C, and D to define it. The curve begins at point A tangent to the, AB, and ends at D and tangent to CD. We construct points E, F, and G such that
Equation 11
Figure 2: Geometric Construction of a cubic Bezier curve.
On EF and FG we locate H and I, respectively, such that Equation 12
Finally on HI we locate J such that Equation 13
We can make no more subdivisions, which means that point J is on the curve. If we continue this process for a sequence of points, then their locus defines the curve.
If points A, B, C, and D are represented by the vectors p0 p1, p2 and p3 respectively, then expressing the construction of the intermediate points E, F, G, H, and I in terms of these vectors to produce point J, or P(u), yields
Equation 14
This awkward expression simplifies nicely to Equation 15
The geometric construction of a Bezier curve shows how the control points influence its shape. The curve begins at the first point and ends at the last point.
It is tangent to the lines connecting the first two points and the last two points. The curve is always contained within the convex hull of the control points.
An Algebraic Definition
Bezier began with the idea that any point p(u) on a curve segment should be given by an equation such as the following:
Equation 16
where and vectors pi are the control points (Figure 3). Equation 16 is a compact way to express the sum of several similar terms because what it says is this:
Figure 3: Bezier curves and their control points.
Equation 17
Of which Equation 10 and 15 are specific examples, for n=2 and n=3, respectively. The n+1 functions, that is the fi(u) must produce a cure that has certain well-defined characteristics. Here are some of the most important ones:
The curve must start on the first control point, p0, and end on the last, pn. Mathematically, we say that the functions must interpolate these two points. The curve must be tangent to the line given by p1 – p0 at p0 and to pn – pn-1 at pn.
The functions fi(u) must be symmetric with respect to u and (1-u) The functions fi(u) must be symmetric with respect to u and (1-u). This lets us reverse the sequence of control points without changing the shape of the curve.
Some Characteristics of Bezier Curves: - End Point Interpolation Affine Invariance (transform ctrl points and redraw – curve keeps shape) Convex Hull Property Linear Precision (ctrl points in st. line) Variation Diminishing
Figure 4: Three different sequences of four control points.
Problem of Local Control Figure 5: Modifying the shape of a Bezier curve
A family of functions called Bernstein polynomials satisfies these requirements. They are the basis functions of the Bezier curve (Other curves, such as the NURBS curves, use different, but related, basis functions).
Figure 6: Bezier curve basis functions
We rewrite Equation 16 using these basis functions as:
Were the basis functions are given as: Equation 19
The term is the binomial coefficient function from probability theory and statistics, defined as
Equation 20
The symbol. is the factorial operator. For example, 3. = 3 x 2 x 1, 5 The symbol ! is the factorial operator. For example, 3! = 3 x 2 x 1, 5! = 5 x 4 x 3 x 2 x 1, so forth. We use the following conventions when evaluating Equation 20; If i and u equal zero, then ui = 1 and 0! = 1.
We see that for n+1 control points, the basis functions produce an nth-degree polynomial.
Expanding Equation 18 for a second degree Bezier curve (When n=2 and there are three control points) produces
Equation 21
From Equation 20, we find Equation 22
Equation 23 and Equation 24
These are the basis functions for a second-degree Bezier curve These are the basis functions for a second-degree Bezier curve. Substituting them into Equation 21 and rearranging terms, we find
Equation 25
This is the same expression we found from the geometric construction, Equation 10. The variable u is now called the parametric variable. Now, let’s expand Equation 18 for a cubic Bezier curve, where n=3:
Equation 26
And from Equation 20 we find
Equation 28
Equation 29
Equation 30
Substituting these into Equation 26 and rearranging terms produces
Equation 31
Bezier curve equations are well suited for expression in matrix form Bezier curve equations are well suited for expression in matrix form. We can expand the cubic parametric functions and rewrite Equation 31 as
Equation 32
Equation 33
If we let Equation 34
Equation 35
Equation 36
Then we can write Equation 33 even more compactly as
Note that the composition of the matrices U, M, and P varies according to the number of control points (that is, the degree of the Bernstein polynomial basis functions).
Computer Graphics Lecture 38