Bezier Curve Subdivision: De Casteljau Algorithm and Applications, Study notes of Computer Graphics

The subdivision of bezier curves using the de casteljau algorithm. The mathematical background of bezier curves, the process of subdividing a bezier curve into two or more curves, and the de casteljau subdivision algorithm. The document also explains the recursive nature of the algorithm and its applications in rendering and intersecting bezier curves and surfaces.

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-u3r-1
koofers-user-u3r-1 🇺🇸

10 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 22: Bezier Subdivision
And he took unto him all these, and divided them in the midst, and laid each piece one against
another: Genesis 15:10
1. Bezier Subdivision
The control points of a Bezier curve typically describe the curve with respect to the parameter
interval
[0, 1]
. Sometimes, however, we are interested only in the part of the curve in some
subinterval
[a,b]
. For example, when rendering a Bezier curve we may need to clip the curve to a
window. Since any segment of a Bezier curve is a polynomial curve, we should be able to represent
such a segment as a complete Bezier curve with a new set of control points. Splitting a Bezier curve
into smaller pieces is also useful as a divide and conquer strategy for intersection algorithms (see
Section 3). The process of splitting a Bezier curve into two or more Bezier curves that represent the
exact same curve is called subdivision (see Figure 1)
t–a
P
0=Q0
P
1
P
3=R3
Q3=R0
Q2
R2
Q(t)
R(t)
Figure 1: Subdivision. The Bezier curve with control points
P0,K,Pn
is split into two Bezier
curves: the left Bezier segment has control points
Q0,K,Qn
; the right Bezier segment has control
points
R0,K,Rn
.
2. The de Casteljau Subdivision Algorithm
The main problem in Bezier subdivision is: given a collection of control points
P0,K,Pn
that
describe a Bezier curve over the interval
[0,1]
, find the control points
Q0,K,Qn
and
R0,K,Rn
that
describe the segments of the same Bezier curve over the intervals
[0,r]
and
[r.1]
. Remarkably the
solution to this problem is provided by the same de Casteljau algorithm that we use to evaluate
points on a Bezier curve.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Bezier Curve Subdivision: De Casteljau Algorithm and Applications and more Study notes Computer Graphics in PDF only on Docsity!

Lecture 22: Bezier Subdivision And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:

1. Bezier Subdivision The control points of a Bezier curve typically describe the curve with respect to the parameter interval [0, 1 ]. Sometimes, however, we are interested only in the part of the curve in some subinterval [ a , b ]. For example, when rendering a Bezier curve we may need to clip the curve to a window. Since any segment of a Bezier curve is a polynomial curve, we should be able to represent such a segment as a complete Bezier curve with a new set of control points. Splitting a Bezier curve into smaller pieces is also useful as a divide and conquer strategy for intersection algorithms (see Section 3). The process of splitting a Bezier curve into two or more Bezier curves that represent the exact same curve is called subdivision (see Figure 1) ∇ ♦

t–a P 0 = Q 0 P (^1) P 2 P 3 = R 3 Q 3 = R 0 Q 1 Q 2 R 1 R 2

Q ( t ) R ( t ) Figure 1: Subdivision. The Bezier curve with control points € P 0 ,K, Pn is split into two Bezier curves: the left Bezier segment has control points € Q 0 ,K, Qn ; the right Bezier segment has control points € R 0 ,K, Rn.

2. The de Casteljau Subdivision Algorithm The main problem in Bezier subdivision is: given a collection of control points € P 0 ,K, Pn that describe a Bezier curve over the interval € [0, 1 ], find the control points € Q 0 ,K, Qn and € R 0 ,K, Rn that describe the segments of the same Bezier curve over the intervals € [0, r ] and € [ r .1]. Remarkably the solution to this problem is provided by the same de Casteljau algorithm that we use to evaluate points on a Bezier curve.

De Casteljau’s Subdivision Algorithm Let B ( t ) be a Bezier curve with control points P 0 ,..., Pn. To subdivide B ( t ) at t = r , run the de Casteljau algorithm at t = r. The points Q 0 ,..., Qn that emerge along the left lateral edge of the triangle are the Bezier control points of the segment of the curve from t = 0 to t = r , and the points R 0 ,..., Rn that emerge along the right lateral edge of the triangle are the Bezier control points of the segment of the curve from t = r to t = 1 (see Figure 2). Q 0 =^0 P 0 1 2 P 1 P 2 P 3 = R 3 Q 1 Q 2 Q 3 = R 0 1 − r (^) r R 2 R 1 1 − r 1 − r 1 − r 1 − r r 1 − r r r r r S Figure 2: The de Casteljau subdivision algorithm for a cubic Bezier curve with control points P 0 , P 1 , P 2 , P 3. The points Q 0 , Q 1 , Q 2 , Q 3 that emerge along the left edge of the triangle are the Bezier control points of the segment of the original curve from t = 0 to t = r ; the points R 0 , R 1 , R 2 , R 3 that emerge along the right edge of the triangle are the Bezier control points of the segment of the original curve from t = r to t = 1. We shall defer the proof of the de Casteljau subdivision algorithm till Lecture 23. In this lecture we will study the properties and the consequences of this subdivision algorithm. Figure 3 provides a geometric interpretation for the de Casteljau subdivision algorithm. ∇ ♦

  • (^) •

t–a P 0 = Q 0 P 1 P 2 P 3 = R 3 Q 3 = R 0 Q 1 Q 2

R 1 R 2

S

Figure 3: Geometric interpretation of the de Casteljau subdivision algorithm for a cubic Bezier curve with control points P 0 , P 1 , P 2 , P 3. The points Q 0 , Q 1 , Q 2 , Q 3 are the Bezier control points of the segment of the original curve from t = 0 to t = r , and the points R 0 , R 1 , R 2 , R 3 are the Bezier control points of the segment of the original curve from t = r to t = 1.

We can also subdivide tensor product Bezier patches. Recall from Lecture 21 that a Bezier surface € B ( s , t ) is defined by applying the de Casteljau algorithm in the parameter s to a collection of Bezier curves € P 0 ( t ),K, Pm ( t ) in the parameter t. To subdivide the Bezier patch along the parameter line € t = t 0 , simply subdivide each of the curves € P 0 ( t ),K, Pm ( t ) at € t = t 0. Similarly, to subdivide the Bezier patch along a parameter line € s = s 0 recall that the same Bezier surface € B ( s , t ) is defined by applying the de Casteljau algorithm in the parameter t to a collection of Bezier curves €

P 0

( s ),K, Pn

( s ) in the parameter s. Thus to subdivide the Bezier patch along the parameter line € s = s 0 , simply subdivide each of the curves €

P 0

( s ),K, Pn

( s ) at € s = s 0. Now we have the following result. Theorem 2: The control polyhedra generated by recursive subdivision converge to the original tensor product Bezier surface provided that the subdivision is done in both the s and t directions. The proof of Theorem 2 for Bezier surfaces is much the same as the proof of Theorem 1 for Bezier curves, so we shall not repeat the proof here. Notice, however, that we must be careful to subdivide in both the s and the t directions. If we subdivide only along one parameter direction, convergence is not assured because in the limit the control polyhedra will not shrink to a single point. Thus to assure convergence it is best to alternate subdividing in different parameter directions.

3. Rendering and Intersection Algorithms Subdivision is the main mathematical tool for analyzing Bezier curves and surfaces. Here we shall apply recursive subdivision to develop algorithms for rendering and intersecting Bezier curves and surfaces. 3.1 Rendering and Intersecting Bezier Curves. The convergence of recursive subdivision is quite fast. This rapid convergence leads to the following important recursive algorithms for rendering and intersecting Bezier curves. Rendering Algorithm -- Bezier Curves If the Bezier curve can be approximated to within tolerance by the straight line segment joining its first and last control points, then draw either this line segment or the control polygon. Otherwise subdivide the curve (at € r = 1 / 2 ) and render the segments recursively. 4

Intersection Algorithm -- Bezier Curves If the convex hulls of the control points of two Bezier curves fail to intersect, then the curves themselves do not intersect. Otherwise if each Bezier curve can be approximated by the straight line segment joining its first and last control points, then intersect these line segments. Otherwise subdivide the two curves and intersect the pieces recursively. To determine whether a Bezier curve can be approximated to within tolerance by the straight line segment joining its first and last control points, it is sufficient, by the convex hull property, to test whether all the interior control points lie within tolerance of this line segment. By the Pythagorean theorem (see Figure 6), the distance between a point P and a line L determined by a point Q and a unit direction vector v is given by dist 2 ( P , L ) =| PQ | 2 − (( PQ ) • v ) 2 .

Q ( P^ − Q )^ • v L v | PQ | dist ( P , L ) P Figure 6: A line L determined by a point Q and a unit direction vector v , and a point P not on L. By the Pythagorean theorem dist 2 ( P , L ) =| PQ | 2 − (( PQ ) • v ) 2 . Be careful. It may happen that a control point Pk is close to the line L determined by the first and last control points P 0 , Pn even though the projection of Pk does not lie inside the line segment P 0 Pn -- that is, Pk may be close to the line L even though it is not close to the line segment P 0 Pn. To be sure that this is not the case, one need only check that 0 ≤ ( PkP 0 ) • ( PnP 0 ) ≤| PnP 0 | 2 . It is relatively easy to test whether or not a Bezier curve can be approximated to within some tolerance by a straight line segment. On the other hand, finding and intersecting the convex hulls of two Bezier curves can be quite difficult and time consuming. In practice, the convex hulls in the intersection algorithm are replaced by bounding boxes which are much easier to compute and intersect than the actual convex hulls: simply take the minimum and maximum x and y coordinates of the control points. Since the subdivision algorithm converges rapidly, not much time is lost by replacing convex hulls with bounding boxes.

To determine whether a Bezier surface can be approximated to within tolerance by two triangles each joining three of its four corner points, it is sufficient, by the convex hull property, to test whether all the interior control points lie within tolerance of these two triangles. By straightforward trigonometry (see Figure 7), the distance between a point P and a plane S determined by a point Q and a unit normal vector N is given by € dist ( P , S ) =| PQ | cos θ =| ( PQ ) • N |.

Q^ •

€ €^ plane^ S dist ( P , S ) PQ P

N θ

Figure 7: A plane S determined by a point Q and a unit normal vector N , and a point P not on S. By the trigonometry € dist ( P , S ) =| PQ | cos θ =| ( PQ ) • N |. Again be careful. It may happen that a control point € Pij lies close to the plane S of a triangle € Δ even though the projection of the point € Pij onto the plane S does not lie inside the triangle €

that is, € Pij may be close to the plane S even though € Pij is not close to the triangle € Δ. To be sure that this is not the case, one need only check that the projection €

Pij − [( Pij − Q ) • N ] N lies inside

(see Exercise 5). Finding and intersecting the convex hulls of two Bezier surfaces can be quite difficult and time consuming. In practice, as with curves, the convex hulls in the intersection algorithm are replaced by bounding boxes. Again since the subdivision algorithm converges rapidly, not much time is lost by replacing convex hulls with bounding boxes. To complete the intersection algorithm for Bezier surfaces, we need to be able to intersect two non-coplanar triangles. Suppose that these triangles lie in the two planes €

N 1 • ( P − Q 1 ) = 0

N 2 • ( P − Q 2 ) = 0.

These two infinite planes intersect ia a straight line. We can specify this line L by a point Q and a direction vector N. Since the line L lies in both planes, the direction vector N must be perpendicular

to the normal to both planes. Therefore we can choose €

N = N 1 × N 2.

To find a point € P = (x, y,z) on the line L , we need to solve two linear equations in three unknowns: €

N 1 • ( P − Q 1 ) = 0

N 2 • ( P − Q 2 ) = 0.

There are infinitely many solutions to these two equations, since there are infinitely many points P on the line L. To find a unique solution and make the problem deterministic, we can add the equation of any plane that intersects the line L. Since the vector € N 1 × N 2 is parallel to the direction of the line L , any plane with normal vector € N 1 × N 2 will certainly intersect the line L. Therefore we can choose any point € Q 3 , and find a unique point P on the line L by solving three linear equations in three unknowns €

N 1 • ( P − Q 1 ) = 0

N 2 • ( P − Q 2 ) = 0

( N 1 × N 2 ) • ( P − Q 3 ) = 0

for the coordinates of the point P (see also Lecture 18, Exercise 2).

4. The Variation Diminishing Property of Bezier Curves We introduced Bezier curves because, unlike Lagrange interpolation, Bezier approximation does not introduce oscillations not already present in the data. This property of Bezier curves is called the variation diminishing property. We are now going to use Bezier subdivision to derive the variation diminishing property of Bezier curves. To prove that Bezier curves never oscillate any more than their control polygons, we need a way to quantify oscillation. One way to measure oscillations is to compute intersections with straight lines. The number of intersections of a curve with a line tells us how much the curve oscillates with respect to the line (see Figure 8). C L Figure 8: The number of intersections of a curve with a straight line counts the number of oscillations of the curve with respect to the line.

Now look at the geometric interpretation of the de Casteljau subdivision algorithm in Figure 3. Evidently, the de Casteljau subdivision algorithm is a corner cutting procedure: first the corners at € P 1 , P 2 are cut off, then the corner at € Δ is cut off (see Figure 11). ∇ ♦

t–a

P 0

P 1 P

2

-^ P 3 - - (^) • - -

Q 1

R 2

∇ ♦

t–a

P 0

P 1

P 2

-^ P 3 - - • - -

Q 1

R 2

Q 2 R 1

Q 3 = R 0

First step Second step Figure 11: The de Casteljau subdivision algorithm as a sequence of corner cuts. In the first stage corners are cut off at € P 1 , P 2 ; in the second stage the corner is cut off at € Δ. Compare to Figure 3. Although we have illustrated only the cubic case, it is easy to verify that the de Casteljau subdivision algorithm is a corner cutting procedure in all degrees. This observation leads to the following result. Theorem 3: Bezier curves are variation diminishing. Proof: Since recursive subdivision is a corner cutting procedure, the limit curve must be variation diminishing with respect to the original control polygon. But by Theorem 1, the Bezier curve is the limit curve generated by recursive subdivision, so Bezier curves are variation diminishing. ♦ By the way, there is no known analogue of the variation diminishing property for Bezier surfaces, since for Bezier surfaces subdivision is not a corner cutting procedure.

5. Joining Bezier Curves Smoothly In Lecture 21 we used our procedure for differentiating the de Casteljau algorithm for Bezier curves to derive constraints on the location of the control points to insure that two Bezier curves meet smoothly where they join. Given a Bezier curve with control points € P 0 ,K, Pn , we derived the following constraints for the location of the control points € Q 0 ,K, Qn of another Bezier curve that meets the first curve and matches its first k derivatives at its initial point:

k = 0 ⇒ Q 0 = Pn k = 1 ⇒ Q 1 = Pn + ( PnPn − 1 ) k = 2 ⇒ Q 2 = Pn − 2 + 4( PnPn − 1 )

We observed that each derivative generates one new constraint on one additional control point. These constraints are easy to solve, but rather cumbersome to write down. Here we show how to use subdivision to determine the location of the points € Q 0 ,K, Qk that guarantee k -fold continuity at the join. We know that the location of the points € Q 0 ,K, Qk is unique. If we could find a curve € Q ( t ) that meets the original curve € P ( t ) smoothly at the join, then the control points of € Q ( t ) would necessarily give the location of the points € Q 0 ,K, Qk. But we certainly do know such a curve, for € P ( t ) meets itself smoothly at the join! Suppose that € P ( t ) is parameterized over the interval €

[0, 1 ].

Let € Q ( t ) be € P ( t ) over the interval € [ 1 ,2]. Then € P ( t ) and € Q ( t ) meet smoothly at € t = 1. All we need now are the Bezier control points of € Q ( t ). To find the Bezier control points of € P ( t ) over the intervals € [0, r ] and € [ r .1], we can subdivide the Bezier curve € P ( t ) at € t = r. Nothing in our subdivision algorithm requires that € 0 ≤ r ≤ 1. If we take € r = 2 , then the de Casteljau subdivision algorithm will generate the Bezier control points for the curve € P ( t ) over the intervals € [0,2] and € [2.1]. By the symmetry property of Bezier curves, the Bezier control points for the interval € [2.1] are the same as the Bezier control points for the interval € [ 1 ,2] but in reverse order. Thus we can read off the points € Q 0 ,K, Qk from the right edge of the de Casteljau subdivision algorithm for € r = 2. We illustrate this algorithm in Figure 12 for cubic Bezier curves. (^1 ) P 0 P 1 P 2 P 3 =^ Q 0 Q 1 Q 2 Q 3 − (^1 2) − 1 − 1

Figure 12: The de Casteljau subdivision algorithm at € r = 2. for cubic Bezier curves. The first € k + 1 points € Q 0 ,K, Qk that emerge on the right lateral edge of the diagram are the control points that guarantee k -fold continuity at the join. Compare to the points to the values in Equations (5.1). 11

a. Prove that Pb 1 L bn is the control polygon for the original Bezier curve from t = b to t = b + 2 − n , where b is the binary fraction represented by 0. b 1 L bn. b. Prove that the sequence of control polygons Pb 1 , Pb 1 b 2 ,..., Pb 1 L bn ,... converges to the point on the Bezier curve at parameter value b = Limn → ∞0. b 1 L bn.

  1. Show that to find the control points of the segment of a Bezier curve between t = r and t = s , we can subdivide the original Bezier curve at t = s and then subdivide the first segment of the subdivided curve at t = r / s.
  2. Prove that the arc length of a Bezier curve is less than or equal to the perimeter of its control polygon. Explain how to use this result to compute the arc length of a Bezier curve.
  3. Recall that the projection of a point P into a plane S determined by a unit normal vector N and a point Q is given by € P ⊥ = P − (^) (( PQ ) • N ) N. Using this result, show that for two skew lines, the solutions to Equation (3.1) give the closest points on the two lines.
  4. Suppose that the point P lies in the plane of € Δ Q 1 Q 2 Q 3. Give two algorithms for determining if P lies inside of €

Δ Q 1 Q 2 Q 3.

  1. Develop an algorithm to intersect a Bezier curve with a Bezier surface based on recursive subdivision.
  2. Develop an algorithm to ray trace a Bezier surface based on recursive subdivision.