Vous êtes sur la page 1sur 23

Shape Modeling

Parametric Representation Technique I


Lecture 7

Convex Hulls

An important and useful property of Bzier curves is that of the convex


hull property (CHP). The CHP and the de Casteljau algorithm lead
naturally to geometric algorithms for rendering a Bzier curve, and for
finding the points of intersection of two Bezier curves. In order to describe
the CHP it is necessary to define the convex hull of a set of points. Given a
set of points X = {x0, x1, ... , xn} the convex hull of X, denoted by CH{X},
is defined to be the set of points
n

CH{x} = {a0x0 +... +anxn |

i 0

ai= 1 , ai 0}

(1)

For points in a plane, the convex hull CH{X} may be visualized as


follows. Imagine an elastic band placed around the entire set of points.
The band is permitted to shrink around the points to form a polygon, the
vertices of which are a subset of the original set of points. The region
bounded by the polygon is the convex hull of the set of points.

The definition of the convex hull is valid for points in space. The intuitive
elastic band is replaced by an elastic balloon which is permitted to shrink
around the points to form a polyhedron. The convex hull is the region
bounded by the polyhedron. Several examples of convex hulls are
illustrated in Fig. 1.

Figure 1. Convex hulls

Properties of Bzier Curves

Theorem 2
A Bzier curve B(t) of degree n with control points b0, ..., bn satisfies the
following properties.

Endpoint Interpolation Property:


B(0) = b0 and B(1) = bn.

Endpoint Tangent Property:


B(0) = n(b0 - b1) and B(1) = n(bn - bn-1)

Convex Hull Property (CHP):

For all t [0.1], B(t) CH{ b0,..., bn}.

Thus every point of a Bezier curve lies inside the convex hull of its
defining control points. The convex hull of the control points is often
referred to as the convex hull of the Bezier curve.

Invariance under Affine Transformations:

Let T be an (affine) transformation (for example, a rotation, reflection,


translation, or scaling). Then
n

T( biBi,n(t)) =
i 0

i 0

T(bi )Bi,n(t)

Variation Diminishing Property (VDP):

For a planar Bzier B(t) curve the VDP states that the number of
intersections of a given line with B(t) is less than or equal to the number of
intersections of that line with the control polygon.

Proof

Considere the proof of Convex Hull Property and Afflne Invariance


Property.
(Convex Hull Property ) From the definition of the convex hull expressed
in equation (1) it is sufficient to show that every point B(t) on a Bezier

curve has the form a0b0 +... +anbn for some constants ai satisfying

i 0

ai =

1. Let ai = Bi,n(t), then positivity implies ai 0, the partition of unity

implies that

i 0

ai = 1, and the proof is complete. Figure 2 illustrates the

CHP for a cubic Bzier curve.

Figure 2. Illustration of the convex hull property for a cubic Bezior curve

(Afflne Invariance) Let an affne transformation T be given by

(x',y') =(ax + by+c,dx+ey + f),

and let a Bezier curve of degree n have control points bi(pi, qi) for i =
0, ... ,n. Then
n

i 0

i 0

B(t) = (x(t),y(t)) = ( piBi,n(t), ( qiBi,n(t))


Applying the transformation yields
n

i 0

i 0

i 0

i 0

T(B(t)) = a( piBi,n(t) + b qiBi,n(t) + c,


d( piBi,n(t) + e qiBi,n(t) + f),
n

Then, by partion of unity, Bi,n(t) = 1. and


i 0

i 0

i 0

i 0

i 0

i 0

i 0

T(B(t)) = a( piBi,n(t) + b qiBi,n(t) + c Bi,n(t),


d( piBi,n(t) + e qiBi,n(t) + f Bi,n(t))
n

i 0

i 0

= ( (api + bqi + c) Bi,n(t), (dpi + eqi + f) Bi,n(t))


n

= ( (api + bqi + c, dpi + eqi + f) Bi,n(t) =


i 0

Example 7

i 0

T(bi) Bi,n(t)

Consider a cubic Bzier curve with vertices b0(1, 0), b1(2, 3), b2(5, 4), and
b3(2, 1). To apply a rotation through an angle /4 about the origin in the
anticlockwise direction to the curve, it is sufficient to apply the rotation
matrix Rot(/4) to the homogeneous coordinates of the control points.

101

231
541

211

. . .
cos / 4 sin / 40 0707070710

. . .
sin / 4 cos / 40 0707353610

. . .
001
0707212110

The control points of the rotated curve are b0(0.707,0.707), b1(-0.707,


3.536), b2(0.707, 6.364), and b3(0.707, 2.121). The curve and its rotated
image are illustrated in Figure 3.

Figure 3. Application of a rotation to a cubic Bzier curve

Figure 4 illustrates two lines intersecting a Bzier curve and its control
polygon. The upper line intersects the polygon in two points but does not
intersect the curve. The lower line intersects both the polygon and the
curve in two points. In both cases, the number of intersections with the
given line is equal to or greater than the number of intersections of the line
with the curve. Thus the variation diminishing property is satisfied. The
proof of the variation diminishing property can be found in [1].

Figure 4. Variation diminishing property

Exercises

22. Plot the cubic Bezier curve defined by control points b0(0, 1), b1(2. 5),
b2(4, 6), and b3(8, 1). On the same plot, draw the control polygon.
Observe that the resulting curve satisfies the convex hull property. Next
plot the Bezier cubic with control points b0(1, 1), b1(3.4, 1.8), b2(6, 6.5),
and b3(9,1). Does the newly displayed curve violate the convex hull
property? Explain.

23. Prove the endpoint interpolation property for the general Bezier curve:
B(0) = b0 and B(1) = bn.

24. Prove that when the control points are collinear, the resulting Bezier
curve is a straight line segment.

25. Determine the control points of the image of the Bezier curve with
control points b0(0, 0), b1(2,1), b2(3, -1), and b3(1, -2) when the following
transformations have been applied
(a) a translation of 3 units in the x-direction and 4 units in the y-direction,
(b) a rotation about the origin through an angle of /2 radians in an anticlockwise direction,
(c) a reflection in the line y = x.
For each transformation plot the image curve and its control polygon.

The de Casteljau Algorithm

The de Casteljau algorithm provides a method for evaluating the point on a


Bezier curve corresponding to the parameter value t [0, 1]. The same
algorithm can be used to divide a curve into two curve segments. For the

case of a cubic Bzier curve with control points b0, b1, b2, and b3, and for
a specified parameter value t [0, 1], the de Casteljau algorithm is
expressed by the recursive formula

b0i = bi ,

b ji+1 = (1-t)b j-1i +tb j-1i+1 ,


for j = 1,2,3 and i = 0,, 3 - j. The formula generates a triangular set of
values (6) for which b30= B(t) for the specified value of t.
b00 b01 b02 b03
b10 b11 b12

(2)

b20 b21
b30
Example 8

A cubic Bezier curve has control points b0(1.0, 1.0), b1(2.0, 7.0), b2(8.0,
6.0), and b3(12.0, 2.0). The point B(0.25) is determined by applying the de
Casteljau algorithm with t = 0.25. Then
b10 = 3/4(1.0,1.0) + 1/4(2.0,7.0) = (1.25,2.5),
b11 = 3/4(2.0,7.0) + 1/4(8.0,6.0) = (3.5,6.75),
b12 = 3/4(8.0,6.0) + 1/4(12.0,2.0) = (9.0,5.0),
b20 = 3/4(1.25,2.5) + 1/4(3.5,6.75) = (1.8125,3.5625), etc.

The algorithm gives the following table of points.


(1.0,1.0)

(2.0,7.0)

(8.0,6.0)

3/41/4 3/41/4
(1.25.2.5) (3.5.6.75)
3/41/4
(1.8125, 3.3625)

(12.0,2.0)

3/41/4

(9.0,5.0)

3/41/4
(4.875,6.3125)

3/41/4
(2.578,4.25)

The algorithm yields B(0.25) = (2.578, 4.25). Geometrically, each step of


the algorithm is a linear interpolation of the control polygon as illustrated
in Figure 5.

Figure 5. The de Casteljau algorithm with t = 0.25

Theorem 3

Let a Bezier curve of degree n be given by control points b0, ... , bn, and let
t [0,1] be any parameter value. Then B(t) = bn0, where b0i = bi and

bji = bj-1i (1 - t) + bj-1i+1t,


for j = 1,...,n, and i = 0, ... , n-j.
Proof
The de Casteljan algorithm follows from the recursion property of the
Bernstein polynomials
Bi,n(t) = (1- t) Bi,n-1(t) + t Bi-1,n-1(t),
Then
n

B(t) =

i 0

biBi,n(t) =

i 0

bi((1- t) Bi,n-1(t) + t Bi-1,n-1(t))

i 0

bi(1- t) Bi,n-1(t) +

i 0

bi t Bi-1,n-1(t))

Since B-1,n-1(t) = 0 and Bn,n-1(t)) = 0, it follows that


B(t) =

n 1

i 0

bi(1- t) Bi,n-1(t) +

i 1

bi t Bi-1,n-1(t).

Next renumber the second summation by replacing i by i + 1,


B(t) =

n 1

i 0

bi(1- t) Bi,n-1(t) +

n 1

i 1

bi t Bi-1,n-1(t)

n 1

i 0

(bi(1- t) + bi+1 t)Bi,n-1(t).

Set b1i = bi(1- t) + bi+1 t) = boi(1- t) + boi+1 t) for i = 0, ... , n-1, then
B(t) =

n 1

i 0

b1iBi,n-1(t)

(3)

Equation (3) expresses B(t) as a Bezier curve of degree n - 1 with control


points b10, ... , b1n-1.. Applying a similar argument yields
B(t) =

n 2

i 0

b2iBi,n-2(t)

where b2i+1 = b1i(1- t) + b1i+1 t) for i = 0, ... , n-2. In general,


B(t) =

n j

i 0

bjiBi,n-j(t)

where bji = bj-1i(1- t) + bj-1i+1 t) for i = 0, ... , n-j. In particular, j = n gives

B(t) =

i 0

bniBi,n-n(t) = bn0.

Exercises
26. A cubic Bezier curve has control points b0(1, 0), b1(3, 3), b2(5, 5),
and b3(7, 2). Evaluate the point B(0.25) by (a) applying the de Casteljau
algorithm, and (b) substituting t = 0.25 into the defining equation of the
Bzier curve. Make a sketch illustrating the points derived in applying de
Casteljau algorithm.

27. Apply the do Casteljau algorithm to the quadric Bezier curve with
control points b0(3.0,3.0). b1(4.0, 2.0), b2(-1.0, 0.0), b3(6.0, 1.0). and
b4(8.0, 5.0). and evaluate the point B(0.6).

Subdivision of a Bezier Curve

A Bzier curve is generally defined over the interval [0,1] and given by

B(t) =

i 0

biBi,n(t). On occasions, only a part of a curve is of interest. For

instance, suppose that a Bezier curve is cut at the parameter value t =


to give two curve segments, denoted by Bleft(t) and Bright(t), defined over
the intervals [0, ], and [, 1] as shown in Fig. 6.

Figure 6.

Since Bleft(t) and Bright(t) are polynomial curves they can be represented in
Bezier form over the interval [0,1]. Theorem 4 will show that to determine
the control points of Bleft(t) and Bright(t) it is sufficient to apply the de

Casteljau algorithm to B(t) with t = . For a cubic Bezier curve, the


theorem implies that the control points of Bleft(t) are b00, b10, b20, b30, and
the control points of Bright(t) are b30, b21, b12, b03. The two sets of points are
observed to be two edges of the triangle of control points (2). Subdivision
is one way of creating extra control points in order to give additional
freedom for curve design. For instance, one segment of the curve can be
left untouched while the other part of the curve is changed.

Example 9

A Bzier cubic B(t) has control points b0(l.0,1.0), b1(2.0,7.0), b2(8.0. 6.0),
and b3(12.0. 2.0). The control points of the two curve segments Bleft(t) and
Bright(t), obtained by cutting B(t) at the parameter value t = 0.25, are
determined from the triangle of points computed in Example 8. Bleft(t) has
control b0(l.0,1.0), b1(1.25,2.5), b2(1.8125, 3.5625), b3(2.578, 4.25),
points and Bright(t) has control points b0(2.578, 4.25), b1(4.875, 6.3125),
b2(9.0, 5.0), b3(12.0, 2.0).
0

Theorem 4 (Subdivision)

For a general Bzier curve B(t) =

i 0

biBi,n(t)., the control points of the

two curve segments obtained by subdivision at parameter value t are b00,


b10, b20, ... , bn-10 , bn0 for Bleft and bn0, bn-11, ... , b1n-1 , b0n for Bright, where
the bji are the points computed in the de Casteljau algorithm (Theorem 3).

Exercises
30 A cubic Bezier curve B(t) is given by the four control points b0(0.2,
0.0), b1(1.0, 0.4), b2(1.8, 1.2), and b3(3.4, 0.0).
(a) Use the de Casteljau algorithm to evaluate the point B(0.25).
(b) Use the triangular array of points evaluated in part (a) to write down
the sets of control points defining the segments Bleft and Bright, which are
obtained when B(t) is subdivided at t = 0.25.

Applications

In this section the de Casteljau algorithm is applied to three problems: (i)


rendering a Bezier curve, (ii) finding the points of intersection of a Bezier
curve and a line, and (iii) finding the points of intersection of two Bzier
curves. The algorithms discussed in this section indicate how the
properties of the Bzier representation can be applied to these problems.

1. Rendering

To render a curve means to obtain a plot of it. The main step of the
rendering algorithm is an application of the de Casteljau algorithm to
subdivide the curve.
Step 1: Apply the de Casteljau algorithm with t = 1/2 to subdivide the
Bezier curve into two curve segments denoted Bleft and Bright
Step 2: If Bleft is near linear' (using the criterion described below) then go
to step 3; else, go to step 1 and apply the algorithm to Bleft. Similarly, if
Bright is near linear go to step 3; else go to step 1 and apply the algorithm to
Bright.

The algorithm continues to subdivide the newly obtained curve segments


which are not near linear. Eventually, the subdivision produces curve
segments which are near linear and no further subdivisions take place.

Step 3: The segment is near linear and can be approximated by its control
polygon. Draw the control polygon.

Each time step 3 is executed, the control polygon of a segment of the curve
is drawn. The union of all these control polygons gives a linear
approximation of the original Bezier curve.

Test to determine whether a Bezier curve is near linear

There are a number of ways of deciding whether or not a curve is close to


being linear. One method requires the user to specify a tolerance > 0. For
a plane curve, the control points are enclosed in a rectangle (see Figure
7(a)), called a minmax bounding box, with lower left corner (xmin, ymin) and
upper right corner corner (xmax, ymax), where xmin/xmax, is the
minimum/maximum x-coordinate of any control point, and ymin/ymax. is the
minimum/maximum y-coordinate of any control point. The curve is
considered linear if the horizontal or vertical dimensions of the box are
less than . The smaller the tolerance the greater the number of
subdivisions computed, and the smoother the resulting approximation to
the curve.
A more sophisticated alternative is to determine the largest distance of any
interior control point (i.e. a control point which is not an endpoint) from
the line through the endpoints of the curve as shown, in Figure 14(b). This
is a more computationally expensive method than the minmax box method,

but generally it will result in fewer subdivisions which will give a saving in
computations.

(a) Minmax bounding box

(b) Test for near linearity

Figure 7.

A further improvement of the algorithm can be obtained by subdividing at


values other than t = 1/2. In general, the point B(1/2) is not exactly halfway along the curve. So the algorithm could be improved if the subdivision
takes place nearer to half-way as this would reduce the number of
subdivisions. To determine the value of t which corresponds to half-way
requires considerable additional computation, and it is not obvious whether
this results in a more efficient algorithm.

2. Intersection of a Planar Bzier Curve and a Line

A planar Bzier curve B(t) of degree n can intersect a line in the plane in
up to n points. (It is assumed that B(t) is not a line segment and

intersecting in an infinite set.) A simple algorithm to compute the points


of intersection is as follows.

Step 1: Test whether the convex hull of the control points intersects the
line (see below for details). If so, go to step 2 as there may be an
intersection; else the curve does not intersect the line and the curve may be
disregarded.

Step 2: Test to see if the curve is near linear. If so, go to step 3; else, apply
the de Castehjau algorithm to subdivide the curve into two Bezier curve
segments and repeat step 1 with each segment.

Step 3: The curve (or curve segment) is linear and may be approximated
by a line segment (for example, by the line joining the first and last control
points), and intersected with using the algorithm, implementing the
line/Besier intersection, and Bezier.Bezier intersection algorithms. The
intersection is a point of intersection of the Bzier curve and .

Test to determine ,whether a convex hull intersects a line

Suppose the line has equation ax + by + c = 0. A line partitions the plane


into two regions, one on either side of the line. The regions are
distinguished by the fact that points (z,y) in one region satisfy ax + by + c
> 0 and points in the other satisfy ax + by + c < 0. All control points of a
curve lie on one side of the line if and only if the convex hull does not
intersect the line. Thus a simple check for intersection would be to
determine whether axi + byi + c has the same sign for every control point
bi(xi, yi) (i = 0, ... ,n) as illustrated in Figure 8.

Figure 8. Convex hull test

3. Intersection of Two Bezier Curves

Determining the points of intersection of two curves is a complex problem.


A curve of degree m intersects another of degree n in up to mx n points.
(This result follows from a more general result known as Bezout's
theorem.) For example, two cubic curves can meet in as many as nine

points. A simple algorithm to compute the intersection points of two Bzier


curves is as follows.

Step 1: Test to see if the convex hulls of the control polygons intersect (see
below for details). If so, go to step 2 as the curves may intersect; else the
curves cannot intersect and may be disregarded.

Step 2: Test whether the curves are linear. If so, go to step 3; else, apply
the de Casteljau algorithm to subdivide each curve into two segments, and
to give a total of four pairs of curve segments. Go to step 1 and apply the
algorithm to each pair.

Thus, each pair of subdivided curve segments is treated in a similar


manner to the original pair. Each subdivision produces curves with control
points that have successively smaller convex hulls. The subdivision
process will stop when the curve segments are near linear. Alternatively,
the subdivision process could be coded to stop after a fixed number of
iterations (obviously with some loss of precision in the computation of the
intersection points).

Step 3: Since both curves are near linear, the curves may be approximated
by line segments (for example, by the line joining the first and last control
points). The two linear segments are intersected (using the line/Besier
intersection, and Bezier.Bezier intersection algorithms) to determine the
point of intersection of the two segments.

Test to determine whether two convex hulls are intersecting

The simplest method is to enclose each convex hull in a minmax bounding


box. The two boxes are easily checked for overlap.

Exercises

36 (optional) Determine algorithms which (a) approximate a nearly linear


Bezier curve by a line, and (II) determine the intersection of two linear
segments. Use the algorithms to implement the line/Bezier intersection,
and Bzier/Bzier intersection algorithms.

Spatial Bezier Curves


n

A spatial Bezier curve B(t) =

i 0

biBi,n(t) is obtained when the control

points bi are three-dimensional. Spatial Bezier curves satisfy the properties


of planar Bezier curves, namely, the endpoint interpolation and endpoint
tangent conditions, invariance under affine transformations, the convex hull
property (CHP), and the variation diminishing property. In general, the
convex hull of the set of control points is a volume.
The de Casteljau algorithm is executed in a similar manner to the twodimensional case, except that the linear interpolation is applied to three
coordinates rather than two.

References
[1] I. Shoenberg, Contribution to The Problem of Approximation of equidistant data by
Analytic functions, Quart. Appl. Math. , Vol. 4, 1946, 45-99
[2] A. Watt and M. Watt, Advanced Animation and Rendering techniques, Theory and
Practice, Addison-Wesley, 1992, 455
[3] J.D. Foley, A. van Dam, S.K. Feiner, J.F. Hughes, T. L. Philips, Introduction to
Computer Graphics, Addison-Wesley publishing Company, 1986, 559
[4] D. Marsh, Applied Geometry for Computer Graphics and CAD, Springer, 1999
[5] M.E. Mortenson, Geometric Modeling, John Wiley &Sons, 1985

Vous aimerez peut-être aussi