Bezier Curves and B-Splines, Blossoming: New York University

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

G22.

3033-002: Topics in Computer Graphics: Geometric Modeling New York University

Lecture #2

Bezier Curves and B-splines, Blossoming


Lecture #2: Lecturer: Scribe: 16 September 2002 Prof. Denis Zorin Kranthi K Gade

In this lecture, we discuss polynomial parametric curves, which is the most commonly used type of curves in geometric modeling. We consider two ways of representing such curves which are useful for computational purposes viz., Bezier and B-spline curves. We also discuss some properties of Bezier and B-spline curves.

Representation of Curves
For computational purposes, we need to represent curves in some form. The most commonly used representation is the parametric representation. As we have seen in the previous lecture, parametric method is to represent the curve in the form of a function of one parameter y(t) : R Rn , n = 2, 3, . . . It would be good if the function y(t) is simple because using arbitrary functions which can be obtained say by composition of commonly used elementary functions is computationally expensive. So we look for class of functions which is as simple as possible and yet diverse enough to represent a wide variety of curves. Polynomial functions to large extent satisfy this requirement. A general polynomial function is represented in the following way:
n

y(t) =
i=0

ai ti

where n is the degree of the polynomial. The variety of curves that you can obtain using polynomials depends on the maximum allowed degree. The higher the degree, the greater variety of shapes one can represent. For example, to dene a curve with n wiggles, we need a polynomial of degree n + 1. But higher degrees result in some problems. The computational complexity of maintaining the curve increases with increasing degree. The higher the degree of a curve, the less controllable it is, in a sense that small changes in coefcients are likely to result in large changes in the shape of the curve. Furthermore, the curves of high degree are more likely to develop bumps in unpredictable when the shape of the curve is changed. Let us try to gure out what is the minimal degree we can get away with. For simplicity, let us consider the functional case only. Degree 1 polynomials can only be used to represent straight lines; degree 2 curves are parabolas in non-degenerate cases. The problem with parabola is that it does not have a point of inection, where the curve turns from being concave to convex or vice-versa, and hence a curve with point of inection cannot be represented using a degree 2 polynomial; we can stitch several degree 2 polynomials together, but at inection points the

G22.3033-002: Lecture #2

curvature is likely to be discontinuous unless it is zero. Cubics on the other hand may have points of inection with curvature changing continuously. To represent arbitrarily complex curves one usually uses piecewise polynomials, stitching together many polynomial pieces. The next question we need to address is how to specify polynomial curves. The most straightforward approach is to dene a curve using the polynomial coefcients. For example, a two-dimensional curve can be represented using polynomials in the following way: y(t) = a0 + a1 t + a2 t2 + a3 t3 where ai s are two-dimensional points. One can see that y(t) is the weighted average of a0 , a1 , a2 , a3 but it is not intuitively clear though how y(t) is traversed as t changes, and how ai inuence the shape of y(t).

Bezier Curves
One can make the coefcients describing a polynomial more intuitive by changing the basis functions. Instead of using the standard monomial basis [1, t, t2 , t3 ], we use the Bernstein basis: [(1 t)3 , 3t(1 t)2 , 3t2 (1 t), t3 ]. One way to derive this set of basis function is to look at the expansion of 13 : 1 = (1 t + t)3 = (1 t)3 + 3t(1 t)2 + 3t2 (1 t) + t3 (1)

Why this basis? We shall see that Bezier curves have a number of nice properties. Bernstein basis is dened for any n. For n = 1, the Bernstein basis is [(1 t), t] and for n = 2 it is [(1 t)2 , 2t(1 t), t2 ]. The Bernstein basis for n = 3 are shown in Figure 1. Any polynomial can be written as a combination of the four polynomials of the Bernstein basis. If p0 , p1 , p2 , p3 are four points in space, then the cubic polynomial curve p (t) =
i=0 3 3

pi B3,i (t)

(2)

where B3,i is the ith Bernstein polynomial is called a cubic Bezier curve with control points p0 , . . . p3 .

Properties of cubic Bezier curves


1. Interpolation. One can easily see that p3 (0) = p0 and p3 (1) = p3 , i.e. the Bezier curve p3 (t) interpolates the points p0 ,and p3 2. Afne Invariance. This property can be easily veried by considering an afne map (x) = Ax + v where A is a 3 3 matrix and v is in R3 . Now
3 3 3 3

(pi )B3,i (t) =


i=0 i=0

(Api + v)B3,i )(t) = A


i=0

pi B3,i (t) + v = (
i=0

pi B3,i (t))

The last transformation uses the fact that Bernstein basis functions sum up to one (1).

G22.3033-002: Lecture #2
1

B3,0

B3,3

B3,1

B3,2

Figure 1: Bernstein basis functions for n = 3

Figure 2: Bezier Interpolation 3. Tangent to the curve at point p0 is the vector p0 p1 and tangent to the curve at p3 is p2 p3 . This can be easily veried by differentiating (2) and substituting appropriate parameter values: t = 0 for p0 and t = 1 for p3 . This property can be used to test whether two Bezier curves are joined smoothly: use this property to nd the tangents at the common point and then see whether they are parallel. 4. Convex Hull. It is clear that B3,i (t) 0 for t [0, 1]. This and (1) means that all points on the Bezier curve lie inside the convex hull of points p0 . . . p3 .

Polar forms and blossoming


Polar form of a polynomial of P (t) : R R of degree n is a multiafne symmetric function P (t1 , t2 , . . . , tn ) : Rn R such that P (t, t, . . . , t) = P (t)
n

(3)

We focus on the case n = 3. The two properties of polar forms are dened as follows:

G22.3033-002: Lecture #2

Figure 3: Blossoming for Bezier curves. A function f (t1 , . . . , tn ) is symmetric if the value of the function is the same for any permutation of the arguments t1 , . . . tn . A function f (t1 , . . . , tn ) is multiafne if for any arguments t1 , . . . t0 , t1 , . . . tn and any a j j f (t1 , . . . , at0 + (1 a)t1 , . . . tn ) = af (t1 , . . . t0 , tj+1 , . . . tn ) + (1 a)f (t1 , . . . , t1 , . . . , tn ) j j j j For any polynomial, there exists a unique symmetric and multiafne polar form. We do not give a formal proof for it but an intuition behind it for the case n = 3 will make it clear. Because the polar form is multiafne it is linear in each argument; therefore it is a polynomial in t1 , t2 , t3 , of total power 3 as it follows from (3). Therefore the polar form can be expressed as b0 + b11 t2 + b12 t3 + b13 t3 + b21 t1 t2 + b22 t2 t3 + b23 t1 t3 + +b3 t1 t2 t3 . Writing equations for symmetry and taking (3) into account yields a P (t1 , t2 , t3 ) = a0 + a1 a2 (t1 + t2 + t3 ) + (t1 t2 + t2 t3 + t1 t3 ) + a3 t1 t2 t3 3 3

Suppose P (t1 , t2 , t3 ) is the polar form of a cubic polynomial P (t), then the value of P (t) for any arbitrary t can be found if the values of P (0, 0, 0), P (0, 0, 1)P (0, 1, 1) and P (1, 1, 1) are given. This is done by repeated linear interpolation and is shown in Figure 3. In this way we can compute the value of the polynomial at any point t using a sequence of linear interpolations. Polar form representation is useful because it provides a uniform and simple approach to computing values of a polynomial using a variety of representations from Bezier curves to NURBS (non-uniform rational B-splines).

B-splines
B-splines is a different approach to representing piecewise polynomial curves, which overcomes some of the drawbacks of Bezier curves. Suppose we wish to design a long curve with many undulations. One approach would be to use a high-degree Bezier curve. As we have already discussed, this is not a very good approach; also note that each of n + 1 control points of a Bezier curve of degree n inuences the whole curve, which means that it is difcult to introduce a small feature without changing the curve everywhere. Another approach using Bezier curves is to construct the curve from many parts

G22.3033-002: Lecture #2

(piecewise Bezier); in this case we need to match at least the values and tangents at the endpoints of each segment. Values are easily matched by constraining the last control point of segment j and the rst control point of segment j + 1 to be the same: pj = pj+! . Tangents can be made 3 0 the same if the points pj , pj = pj+1 , pj+1 of the segments j and j + 1 are constrained to be on 2 3 0 1 the same line. This is the way curves are constructed in many drawing programs, for example, in Adobe Illustrator. Resulting curves need not be C 2 however, and it is not that easy to make them fair which typically means that we want the curvature not to change abruptly. To summarize, three commonly desirable properties of curves are: 1. C 2 -continuity: Should be C 2 continuous at all points. 2. Interpolation: Should interpolate the input control points. 3. Local control: The modication of a particular control point should modify the curve only locally. As we have seen, piecewise Bezier curves interpolate the control points shared by segments, and have local control, but need not be C 2 -continuous. It turns out that these three properties are incompatible for cubic curves: e.g. if we attempt to write a system of equations that ensures that sequential Bezier segments are joined with C 2 continuity, we will see that interior control points pj pj for segment j have to depend on the endpoints pi = pi+1 for all i, i.e. there is no 1 2 0 3 local control. If we give up the interpolation property there is a type of piecewise cubic polynomial curves which satises the remaining requirements called the B-spline curves. If we require interpolation but give up local control we get curves called natural splines, which we will not discuss in detail. A B-spline curve dened everywhere on R can be written in the following form:

p(t) =
i==

pi Bi (t)

where pi are control points and Bi (t) are the basis functions associated with control points pi . Each basis function can be thought of as the variable weight which determines how the control point pi inuences the curve at parametric value t. For uniform splines, the basis functions satisfy Bi (t) = B(t i) (4) for a xed function B. We choose the basis function B(t) in such a way that the resulting curves are C 2 -continuous, the inuence of the control points is local (i.e. B(t) = 0 on the smallest possible interval) and the curves are piecewise cubic polynomials on each each interval [i, i + 1]. We would like the inuence of a control point to be maximal at regions of the curve close to it and for this inuence to decrease as we move away along the curve and disappear completely at some distance. Also desirable is afne invariance property that we have seen for Bezier curves. we describe how to construct basis functions satisfying all these requirements. There are many different ways to dene B-splines; we will consider two equivalent denitions: using convolution and using blossoming.

G22.3033-002: Lecture #2

B-spline basis functions


We start with the simplest functions which already meet some of the requirements above: piecewise constant coordinate functions. Any piecewise constant function can be written as

p(t) =
i=

pi Box(t i)

where Box(t) is the box function dened as Box(t) = 1, if 0 t < 1 0 otherwise

We dene the convolution of two functions f (t) and g(t) as (f g)(t) =


f (s)g(t s)ds

The remarkable property of convolution is that each time we convolve a function with a box its smoothness increases. We will see that convolution can be seen as moving average operation. A B-spline basis function of degree n can be obtained by convolving a B-spline basis function of degree n 1 with the box Box(t). For example, the basis function of degree 1 is dened as the convolution of Box(t) with itself. We need to compute

Box(s)Box(t s)ds

Graphically, this convolution can be evaluated by sliding one box function along the coordinate axis from to and keeping the second box xed (see Figure 4). The value of the convolution for a given position of the second box is simply the area under the product of the boxes, which is just the length of the interval where both boxes are non-zero. At rst the two graphs do not have common area. Once the moving box reaches 0, there is a growing overlap between the areas of the graphs. The value of the convolution increases until t = 1. Then the overlap starts decreasing, and the value of the convolution decreases down to zero at t = 2. The function B1 (t) = (Box Box)(t) is as shown in Figure 4. Now take the convolution of Box(t) with B1 (t) and we obtain B2 (t), the degree 2 basis function. We can continue further and obtain degree 3 B-spline, B3 (t) by convolving B2 (t) with Box(t) (Figure 5).

Properties of B-splines
Bn (t) is a piecewise polynomial of degree n (each convolution increases the degree by 1). Bn (t) has a support of length n + 1. We have seen that Box(t) has a support 1 and each convolution increases the support by 1.

G22.3033-002: Lecture #2

Figure 4: The denition of Degree 1 B-spline basis function through convolution of Box function with itself.

0.6

0.4

0.2
1 3 t 6 2 3 2t + 2t2 1 3 t 2

2 3
+2(4

2(4
t)2

t) 1 (4 2

t)3

1 (4 6

t)3

Figure 5: Degree 3 B-spline basis function B n (t) is C n1 -continuous. Box(t) is C 0 continuous and each convolution increases smoothness by 1. The set of functions Bn (t i), i = . . . is afne invariant. This comes from the observation that

Bn (t i) = 1
i=

8
P(0,1,2)
3t 3 t 3

G22.3033-002: Lecture #2
P(1,2,3)
4t 3 t1 3

P(2,3,4)
5t 3 t2 3

P(3,4,5)

P(1,2,t)
3t 2 t1 2

P(2,3,t)
4t 2 t2 2

P(3,4,t)

P(2,t,t)
3t t2

P(3,t,t)

P(t,t,t)

Figure 6: Blossoming in B-splines which can be proved by in induction observing that this property holds for the box function and is preserved by the convolution.

Blossoming in B-splines
For a cubic B-spline, if t [2, 3], then we can obtain the value of P (t) = P (t, t, t) from the values of P (0, 1, 2), P (1, 2, 3), P (2, 3, 4), P (3, 4, 5) as shown in Figure 6. For t [i, i + 1] and cubic B-splines, we need four control points P (i 2, i 1, i), P (i 1, i, i + 1), P (i, i + 1, i + 2), P (i + 1, i + 2, i + 3).

You might also like