
160 Applied Geometry for Computer Graphics and CAD
For example, two cubic curves can meet in as many as nine points. A simple
algorithm to compute the intersection points of two B´ezier 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 algorithm of
Exercise 6.36) 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
6.37. Implement the B´ezier rendering algorithm using (a) the simple rect-
angular bounding box criterion, and (b) the distance to line criterion.
Compare the performance of the two algorithms for curves of small
and large degrees, and for nearly linear curves which are parallel or
at an angle to the x-ory-axes.
6.38. Determine algorithms which (a) approximate a nearly linear B´ezier
curve by a line, and (b) determine the intersection of two linear seg-
ments. Use the algorithms to implement the line/B´ezier intersection,
and B´ezier/B´ezier intersection algorithms.