You are on page 1of 24

COMPUTER AIDED GEOMETRIC DESIGN

ELSEVIER Computer Aided Geometric Design 14 (1997) 111-134

A new approach to the surface intersection problem Thomas A. Grandine*, Frederick W. Klein IV
MS 7L-21, Boeing Information and Support Services, P.O. Box 3707, Seattle, WA 98124-0346, USA

Received September 1995; revised April 1996

Abstract

Planar cut and surface intersection software is an important part of any computer aided design system. This paper presents two new ideas in the numerical solution of such problems. The first is the notion of topology resolution. In this process, the structure of the intersection curves, including the identification of closed interior loops, is determined prior to their actual numerical solution. The second idea is to compute the intersection curves as the numerical solution of a differential algebraic equation, yielding intersection curves which are (nearly) parametrized by arclength.

O. Introduction

Planar cut and surface intersection software is an important part of any computer aided design system. A number of different fundamental approaches to this problem are followed in these systems, including geometric methods for quadric sections (Miller, 1987; Piegl, 1989), subdivision-based methods (Filip et al., 1986; Houghton et al., 1985), implicit schemes (Asteasu, 1988; Bajaj et al., 1988; Garrity and Warren, 1989), and curve tracing schemes (Appel, 1976; Barnhill et al., 1987; Bamhill and Kersey, 1990; Chen and Ozsoy, 1988; Sederberg and Nishita, 1991; Zhao, 1995). The latter schemes are often referred to as "marching" or "curve following" schemes in the literature. Of these, the quadric section methods are of limited interest in the general context, and implicit schemes are useful only in CAD systems which support implicit surface definition. The remaining two techniques, subdivision and curve tracing, have proven useful for solving a wide variety of intersection problems, but both give rise to tolerance setting problems and issues that are very difficult to resolve. A comprehensive bibliography of the surface intersection problem can be found in (Farin, 1992). * Corresponding author. 0167-8396/97/$17.00 Copyright 1997 Elsevier Science B.V. All rights reserved
SSDI 0167- 8396(96)00024-6

112

T.A. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

In recent years, "loop detection" has become the hot topic in this field (Sinha et al., 1985; Sederberg and Meyers, 1988; Cheng, 1989; Sederberg et al., 1989; Kriezis et al., 1992). This technique guarantees that all branches of the intersection curves will be found, and it has become an almost essential add-on to the curve tracing algorithms mentioned above. Despite the obvious benefits of this technology, "loop detection" does not guarantee that the topology of the intersection curves will be correctly resolved. This responsibility is usually imposed on the curve tracking scheme. These schemes solve a sequence of initial value problems, each of which is terminated when the solution passes one of the possible candidate stopping points. Because it is impossible to predict the parameter value at which such a passing might occur, a heuristic stopping mechanism must be built into the tracking scheme. This mechanism usually depends upon properly setting some tolerances, a tricky process which can demand different settings for different problems. An alternative approach is to determine which of the candidate stopping points is the actual stopping point prior to marching. In this case, the initial value problem over an unknown parameter interval can be replaced by a boundary value problem over a fixed, specified interval. This has the added benefit of eliminating the bias built into some curve tracking schemes which arises because of the direction in which the intersection curves are tracked. The setup in this paper formulates the intersection problem as a differential algebraic equation and determines the basic topology of the contours so that it can be solved as a boundary value problem instead of an initial value problem. Our experiments suggest that paying the price to compute the boundary conditions prior to tracking the contours can pay handsome rewards. Our scheme for determining the boundary conditions for the curve tracker requires that the surfaces be restricted to any class of surfaces for which a robust capability for determining all solutions to a nonlinear system of equations. In general, no such capability is possible without some simplifying assumptions or extra knowledge of the structure of the nonlinear system. The simplifying assumption that we have made in our software is that the surfaces we are intersecting are tensor product spline surfaces. This restriction is sufficient to enable a robust nonlinear system capability to be developed, and we have done so. A similar capability could be developed for piecewise polynomial functions over triangles and irregularly shaped regions as well as algebraic and piecewise algebraic surfaces, though we have not implemented this. The method used to track the actual intersection curves does not require finding all solutions to a nonlinear system, so its applicability is not limited to special classes of surfaces. However, it does require the surfaces to be (71 . If the surfaces are not (71, then they can be broken up into pieces which are. These pieces can then be intersected, and the resulting intersection curves pieced back together to form the intersection curves for the original surfaces. This is the approach we have adopted in cases where we have, for example, a pair of bilinear surfaces we wish to intersect. In the generic case, the intersection of a pair of surfaces will be a collection of curves. Of course, it is possible for two surfaces to coincide over an entire region. The problem of finding the boundary of such a region is very different from the problem of finding intersection curves, and will not be considered in this paper.

T.A. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

113

Section 1 of this paper describes a scheme for determining the topology for the planar cut problem, for arbitrary tensor product spline surfaces. This special case of the general surface intersection problem is easier to analyze, and the topology determination scheme for it can be extended to the general problem for tensor product spline surfaces in a straightforward way. This is done is Section 3. Section 2 discusses some of the singular cases for the planar cut problem and how they can be handled within the context of the algorithm outlined in the first section. Section 3 describes the extension of the ideas outlined in the first two sections to the general problem. Finally, Section 4 discusses a method for solving the two point boundary value problems that arise. This method, which is a general contouring method, is analyzed and discussed elsewhere in more detail, but is presented here for completeness. Some numerical examples are presented in Section 5, and conclusions and future directions presented in Section 6.

1. Determining planar cut topology


Overview Consider a parametric surface F parametrized by u and v over [0, 1] 2. 1 Consider also a plane whose implicit equation is a z + by + cz = d. The goal is to find all points F ( u , v) which lie on the plane, i.e., all u and v which satisfy a F j ( u , v) + bF2(u, v) + cF3(u, v) - d = 0. (1.1)

Thus, the planar cut problem is equivalent to the problem of computing zero contour lines for a bivariate function. 2 Thus, the problem is equivalent to the problem of finding all mappings from [0, l] -+ [0, l] 2 with components u and v such that f ( u ( t ) , v(t)) = 0 (1.2)

for a given tensor product spline function f and all t E [0, 1]. This is the classic contouring problem, but it has some special features. One is that the requested accuracy of the computed contours is expected to be much higher than what would be required in a typical computer graphics application. Another special feature is the requirement that all branches of a given contour be found. In order to satisfy both of these special requirements, the problem is divided into two parts. One part is a spline collocation method for approximating the contours. This is designed to achieve arbitrary accuracy and is discussed in Section 4. The first part of the algorithm is a topology resolution scheme, and it is designed to determine the number of contour branches as well as endpoints for each of those branches. The algorithm can be motivated by considering the example shown in Fig. 1, for some smooth spline function f . J The surface is parametrized over a rectangle, so a ~< u ~< b and c ~< v <~ d. The intervals [a, b] and [c, d] can both be assumed to be [0, 1]. The notation (u, v) E [0, 1]2 denotes this setup. 2If F is a rational spline, Eq. (1.1) becomes aFl(u,v) + bF2(u,v) + cF3(u,v) - dw(u,v) = 0, where w(u, v) is the denominator.

114

T.A. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

T
V

u---+ Fig. 1. The parametric domain of f.

/ f J J J 1 / ig

u--~

u---+

Fig. 2. Possible topologies of the zero contour.

Suppose that all zeros of f for fixed u = 0, u = 1, v = 0, and v = 1 have been found, say two along each vertical edge. Suppose further that the contours of f do not cross and that the contour has no closed loops. In this case, the contours must have one of the two possible topologies depicted in Fig. 2, since f is smooth and none of the contour components disappear in the interior of the parametric region. To determine which topology is correct, the region can be divided into ordered panels in which the contours themselves remain ordered. The first panel will contain the point (0, 0), while the last panel will contain (1, 1). The panel boundaries will be parallel lines ordered by distance from the origin. A typical collection of panels is depicted in Fig. 3. Each panel boundary is determined by an arbitrary fixed direction 0 and its distance from the origin. The direction 0 is assumed to be in [0,1r/2] and constant for all panel boundaries, so the vector ( - sin 0, cos 0) is parallel to each of them, as shown in Fig. 3. Determining the locations of the panel boundaries is accomplished by finding the places where contours turn back on themselves relative to a panel boundary. We have chosen to call such points turning points, and they can be characterized by the fact that

TA. Grandine, EW. Klein IV/Computer Aided Geometric Design 14 (1997) 111-134

115

( - sin0, c o s ~ u---+ Fig. 3. Possible panels of the parametric domain of f. the tangent to the contour at such points will be perpendicular to the panel direction. Thus, if (u(t), v(t)) is a turning point, then

u'(t) cos 0 + v'(t) sin 0 = 0.

(1.3)

Such points can be determined by differentiating the contouring Eq. (1.2) with respect to the contour parameter. This gives

fuu'(t) + fvv'(t) = 0

(1.4)

for all t E [0, 1]. 3 Eq. (1.4) says that the vector (u'(t),v'(t)) is always perpendicular to the vector (f~, fv). Eq. (1.3) says that (u'(t),v'(t)) is perpendicular to (cos0, sin0), so (f~, fv) must be a multiple of (cos 0, sin 0). The point (u(t), v(t)) will be a turning point whenever fu sin 0 - fv cos0 = 0. (1.5)

Thus, all of the turning points can be located by finding all solutions to the 2 2 system of equations

f ( u , v) = 0,
fu sin 0 - f . cos 0 = 0. (1.6)

Note that the solution set to these equations must contain all points where contours cross. Contours can only cross at critical points, which are points on the contour for which the gradient of the function vanishes. However, these points must be solutions to Eqs. (1.6) as well, so there is no possibility of missing them if all solutions to those equations are found. Suppose that n solutions to (1.6) exist and are given by (Ul, vl), (u2, v2), , (Un, Vn). For each of these points, determine the distance of its panel from the origin

di = ui cos 0 + vi sin 0.

(1.7)

3 The notation fu is an abbreviation for either Duf(u(t), v(t)) or Duf(u, v), depending on context, and f,. fu~, fur, f , , are analogous abbreviations.

116

T.A. Grandine, E W. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

Without loss of generality, assume that the points are ordered by increasing d~, so that d~+l >~ di for all i. Place panel boundaries at the distances d~ from the boundary, which ensures that all of the turning points and critical points lie on the panel boundaries.

Description of Algorithm
With this location of panel boundaries, it is now impossible for contours either to cross or to double back on themselves within a panel. Thus, only one possible topological configuration of the contours can exist within each panel. Further, no closed loops can exist within the interior of a panel, as that would require contours doubling back on themselves. These observations give rise to the following algorithm: (1) Choose 0 and find all solutions to (1.6). (2) Find all zeros of f on the boundary of [0, 1]2. (3) Take all the points found in Step (1) and Step (2) and order them by distance in the 0 direction from the origin. (4) Initialize an ordered list of contours. Unless a contour starts right at the origin, no contours will be on the list at first. (5) If no points remain to be processed, stop. Otherwise, take the next closest point. If it is a boundary point, go to Step (6). Otherwise, go to Step (7). (6) Determine whether the point corresponds to a contour which is starting or ending at the given point. A point corresponds to a starting contour if it continues in the increasing panel direction, and it corresponds to an ending contour if it continues in the decreasing panel direction. If it is starting and the point is on the v = 0 or u = 1 edge, add a new contour to the front of the ordered list of contours with the given point as an endpoint. If it is starting and the point is on the u = 0 or v = 1 edge, add a new contour to the end of the ordered list. If it is an ending point, then delete a contour from either the beginning or the end of the list, depending upon which edge the point is on. Go back to Step (5). (7) Determine whether the point is a turning point or a critical point. For now, we will assume that the point is a turning point and defer the discussion of critical points to Section 2. Determine whether two contours start or two contours end at the turning point. Locate the two contours in the list of contours by finding all points which lie on both the panel boundary and on the contour. The turning point will be one of these, and it will be well ordered with respect to the other points. Either insert two new contours in the list or delete two existing ones from the list. Go back to Step (4).

Discussion
These steps can be tricky. In Step (1), an entire contour or portion of one may lie along a panel boundary. In this case, solutions to (1.6) are no longer isolated points, and the problem of determining the turning points becomes just as difficult as the contouring problem we are trying to solve. Indeed, an earlier version of our software used 0 = 0 exclusively. In practice, vertical contours arise with alarming frequency, and our code suffered a high rate of failure.

TA. Grandine, E W. Klein IV~Computer Aided Geometric Design 14 (1997) 111-134

117

This problem has been overcome b y noting that, for any given problem, values of 0 which do not lead to a continuum of turning points must exist. We have built into our software a simple strategy for choosing one of these. It doesn't matter which one because the particular value of 0 used does not affect the accuracy of the contour that eventually gets tracked. In Step (5), determining whether a contour is starting or ending requires a sign determination. Along the bottom edge, the contour will be a starting contour if the (u'(t), v'(t)) direction lies within the cone given by the u axis and the panel boundary direction. In other words, the vector (u'(t),v'(t)) must lie between the vectors (1,0) and ( - s i n 0, cos O). This will be the case when the cross products (1,0) x (u'(t), v'(t)) and (u'(t),v'(t)) ( - s i n S , cos0) are both positive or both negative, i.e., when their product is positive. This condition is

v'(t)(v'(t) sin0 + u'(t) cos0) > 0.

(1.8)

Since (u'(t),v'(t)) is perpendicular to (f~, fv), it must be a multiple of ( - f , , f ~ ) . Making this substitution indicates that the contour will be a starting contour whenever

fu(f~sinO - fvCOSO) > 0.


Along the top edge, the condition is - f ~ ( f , , sint9 - fv cos0) > 0.

(1.9)

(1.10)

Thus, the contour will be a starting contour along either of the horizontal edges whenever (0.5 - v) f~ (f~, sin 0 - fv cos 0) > 0 is true. Along the left edge, the condition is (1.11)

u'(t)(v'(t) s i n O + u'(t)cos0) > 0.


As before, this condition is equivalent to

(1.12)

(u - 0.5)fv(fu sinO - fvCOSO) > 0

(1.13)

which works along both vertical edges. In the corners, both conditions must be true for it to be a starting point, both must be false for it to be an ending point. If one is true and one is false, then it is a single point contour in the corner. Step (6) has a similar sign determination that needs to be carried out to determine whether the turning point starts two new contours or ends two old ones. Two new contours will start at the turning point if the vector (u"(t), v"(t)) lies in the new panel, and two old contours will end if it lies in the old panel. Thus, two contours will start whenever

u"(t) cos0 + v"(t) sinO > 0.

(1.14)

The problem checking this is that the values ut'(t) and v'l(t) are not known. However, this is a turning point, so f~ \ sin0 (1.15)

118

T.A. Grandine, E W. Klein IV/Computer Aided GeometricDesign 14 (1997) 111-134

for some c~. Similarly,

(u'(t)) (- sin0) v'(t) = fl cos0

(1.16)

for some ft. This information can be used in the equation that results when (1.4) is differentiated

(fu~u'(t) + fuvv'(t))u'(t) + fuu"(t) + (f~u'(t) + f~v'(t))v'(t) + f~v"(t) = 0,

(1.17)

a relationship that must hold for all points on the contour. Making the substitutions for f~,, fv, u'(t), and v'(t) given by (1.15) and (1.16) give f12 ( f ~ sin 2 0 - 2fu~ sin 0 cos 0 + f ~ cos 2 0)

+ o~(u"(t)cos0 + v"(t)sin0) = O,
which can be solved for the desired expression to get u"(t) cos 0 + v" (t) sin 0 = - f12 ( f ~ sin 2 ~9- 2fu~ sin 0 cos 0 + f ~ cos 2 0). o~

(1.18)

(1.19)

The term f12/~ has the same sign as o~. Taking the inner product of both sides of (1.15) with the vector (cosO, sinO) reveals that o~ = f,~cos0 + f ~ s i n & Thus, the condition (1.14) is equivalent to

(f~cosO+f~sinO)(f~usin20-2f~sinOcosO+f~vcos20)

<0.

(1.20)

This test determines whether or not to add or delete two contours from the list of contours, but it does not necessarily answer the question of where in the list they need to be added to or deleted from. This question can be answered by finding all points which lie on the panel boundary and on the contour. These points satisfy

f(u, v) = O,
ucosO + vsinO = d, (1.21) where d is the distance to the origin of the panel edge. The points can be ordered along the panel edge, and the ordering of the turning point with respect to the others is clear.

Example
An example clarifies much of the discussion. Consider the function f given by

f(~,v) = (~: + ( v - I) 2 -

~) ((~- ~):+ (.- ~ ) : - 2~) (u: + (v- ~):- ~) ((.- 17 + (~- ~o):- ~)-

A contour map of the zeros of f are given in Fig. 4. Discovering the topology of this zero set will be the goal of the algorithm. The first step of the algorithm calls for choosing 0 and finding the turning points. With O = 7r/6, the function f has turning points located at

T.A. Grandine, E W. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

119

u--+

Fig. 4. An example contour problem.

(ul, vl) = (0.17320508, 0.85), (u2, v2) = (0.22679492, 0.5), (u3, v3) = (0.57320508, 0.7), (u4, v4) = (0.82679492, 0.2),

dl = 0.575 d2 = 0.44641016 d3 = 0.84641016 d4 = 0.8160254

with the distances as indicated. In Step (2), the boundary points are calculated, and their corresponding distances are computed. These are

(us, v5) = (0,0.25),


('//'6, 'O6) = (0, 0.55),
(u7, v7) = (0, 0.95),

d5 = 0.125 d6 = 0.275 d7 = 0.475

(~8,v8) = (1,o.1),
(U9,2)9) = (1,0.5),
(UlO,Vlo) = (1,0.75), The ordering of the distances is

d8 = 0.9160254
d9 = 1.1160254
dlo = 1.2410254.

d5 < d6 < d2 < d7 < dl < d4 < d3 < d8 < d9 < d10.
These points and their corresponding panel boundaries are shown in Fig. 5. In Step (3), a list of contours C is initialized. This list has no contours on it to begin with, but this changes as the first point is processed. Because d5 is the smallest of the distances, the point (us, v5) is the first one to be processed. It is a boundary point on a vertical boundary, so condition (1.13) is tested. The value of the left hand side of the inequality is 0.0065019587, and this quantity is positive. Thus, one contour is added to C to reflect that the next panel must have one contour passing through it. This contour will have as one of its endpoints (us, v5). The next point to consider is (u6, v6). This is also a point on a vertical boundary, and it too satisfies inequality (1.13), so it is a starting

120

TA. Grandine, E ~ Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134
\ \\ \ \ \

\1 ,x \
\

\\\ \\ ~

\ \
\

\
tO

\'I v \

"r

6 x\ \ \,\2 \
\ \

\\

~.k \ \k \ x\. \ \ \

\\ \ \\ \

\\ \ \\ \ \\ \

\\
\

\~ x \ \
x\ \~, U--+

\ \

\\4 \ \ ~\
\\ \\

Fig. 5. Example boundary and turning points. point. Because it is on the left boundary, a new contour must be added to the end of the list. Thus, after processing the first two points, the list of contours must now be

c:

{ (,,5, v5), (u6, v6) }.

The next point up is (u2, vz). This is a turning point, so the inequality (1.20) is checked. The value on the left hand side of this inequality is -0.00040825416, so the inequality is satisfied. Thus, two new contours must start here. However, where to place them within C is not known, so system (1.21) must be solved with d = d2. This reveals the three solutions, ordered from bottom to top along the panel boundary, 0.29808608 ' \ 0.5 J ' 0.62391682 "

Since the turning point is the middle of these three, it must be that the two new contours start in between the other two. Therefore, two new contours, both starting at (u2, v2) get added to the list to get

c = {(~5, ~5), (~2, ~2), (~2, ~2), (~6, v6)}.


Next up is (uT, vv). This is a point along the left edge which satisfies condition (1.13), so it must get added to the list at the end. Now the list is

c = {(~5, v~), (u2, ~2), (~, ~2), (~6, ~), (~7, ~7)}.
The next point in the lineup is (Ul, Vl). This point is a turning point for which the value on the left hand side of (1.20) is 0.0048229398. Thus, two contours end here, but once again it is not clear which two. Solving (1.20) with d = d l and ordering the solutions along the panel boundary yields 0.34062956)' 0.40250666 ' \0.72608318J' 0.85 J"

The last one is (Ul, Vl), so the last two contours end there. Thus, one of the contours must start at the left edge a t ( u 6 , v 6 ) , pass through (u],vl), and end at (uv,vT). The current situation now has

T.A. Grandine, E g~ Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134
\\ \ \ \ \

121

xx \
\\

\
\
\ \

\\ 3
\q \ \\ \

tO
\

2
5

\\ \
\\

\\

\\ \ \\4\ \\ \\
it-+

Fig. 6. Identification of the first contour. C = { (us, vs), (u2, v2), (u2, v2) } with one contour identified as in Fig. 6. The next step is to process (u4, v4). This is another turning point, and the value on the left hand side of (1.20) for this point is -0.043007984, so two new turning points start here. Solving (1.21) with d = d4 gives (0.82679492"~ 0.2 J' {0.6813072)( \0.45199213' 0.59987854"~ \0.59303071J' { 0.49390368"~ \0.77658454)"

The first of these is the turning point, so two new contours get added to the start of the list:

c = {(u4,

(u4,

(us,

(u2,

v2)}.

The next point, (u3, v3), is also a turning point, but this time (1.20) is not satisfied, so two contours end. Solving (1.21) with d = d3 and ordering the results reveals that the two contours which end are the last two. Thus, the topology of another contour is now known. This one is a closed loop which starts at (u2, vz) and passes through (u3, v3) before ending up at (u2, v2) again. At this point the situation is

c = {(u4,

(us,

with the endpoints of two contours already identified. The last three points to get processed are (us, v8), ( U 9 , ' 0 9 ) , and (ulo, VlO), and each of these is a point along the right boundary. As these are vertical boundaries, test (1.13) is performed in each case, and in each case the condition is not satisfied. Thus, contours end at each place, so three more contours get removed from C. The first starts at (u,, v4) and ends at (us, v8). The second starts at (u4, v4) and ends at (ug, v9). These two can be combined into a single contour which starts at (us, vs), passes through (u4, v4), and ends up at (u9, v9). The last one is a contour which starts at (us, vs) and ends at (ulo, vlo). The topology uncovered by this approach is depicted in Fig. 7. The endpoints of each of the contours are now correct and accurate, a fact clarified by comparing this picture with the true contours shown in Fig. 4.

122

ZA. Grandine, EIE Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134 7

]
10

u ---). Fig. 7. The topology of all the contours. This example is rather long, but the details of the topology determination are sufficiently interesting to warrant it. In the discussion, one detail got buried under the covers, and that is that the algorithm requires a method for determining all solutions to a nonlinear system of equations. In the case of tensor product spline systems, at least three effective methods for doing this exist. The first would be an interval Newton approach whose one dimensional version was discussed in (Grandine, 1989). Another approach, based on resultants, poses and solves a sequence of eigenvalue problems to guarantee finding all solutions. This is outlined in several papers by Manocha in a number of different contexts (e.g., curve intersection, ray tracing, and curve/surface intersection). The trick in all cases is to set up an eigenvalue problem and determine all solutions to a system of polynomial equations (Allgower et al., 1992; Manocha and Demmel, 1994). An alternative approach is to use the projected polyhedron algorithm as outlined in (Sherbrooke and Patrikalakis, 1993). As presented in (Sherbrooke and Patrikalakis, 1993), this algorithm is used to determine all real solutions to a system of polynomial equations over a rectangle. However, with minor modifications, the algorithm works in the more general case of a spline system of equations. Our particular software uses this latter approach, but software based on eigenvalue problems and resultants or interval arithmetic should work, too.

2. Topology resolution of singular cases


In some cases, the tests (1.11), (1.13), and (1.20) are indeterminate. This happens, in the cases (1.11) and (1.13), when the contour itself is tangent to either the edge of the parametric domain or to the panel boundary (see Fig. 8). In the case of (1.20), an indeterminate result means that the turning point is a critical point. Each of these cases requires checking of higher order derivatives. When (1.11) or (1.13) is indeterminate, the contour is tangent to either the edge of the parametric domain or to the panel boundary. The first step is to figure out which of the pieces is zero. In the case of (1.11), either fu or f~, sin 0 - fv cos 0 is zero. In the second case, the contour is tangent to the panel boundary, so the point must be a turning point.

TA. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

123

\ \ \ \ \

73
\ \

J
u--~

Fig. 8. Degenerate boundary contours. This case gets handled properly by performing check (1.20). The only difference in this case is that, since the turning point is on the boundary, only one new contour starts or ends instead of two. If f~, = 0, then the contour is tangent to the edge itself. In this case, a higher order check must be performed to determine whether the contour itself lies inside or outside the parametric region. If it lies inside, then the boundary intersection point can be ignored. If it lies outside, then the point is an isolated contour point. The contour will lie inside the parametric region whenever (0.5 -

v)v"(t)

> 0.

(2.1)

Using Eqs. (1.17) and the fact that f,, = 0, this condition gives rise to (0.5 -

v)fv (f~,u sin 2 0 -

2f~,v sin 0 cos 0 + f ~ cos 2 0) < 0.

(2.2)

A similar condition can be checked along the vertical edges whenever fv = 0. In this case, the correct higher order condition is (u - 0.5)f~, ( f ~ , sin 2 0 -

2fur sin 0 cos 0 +

fvv cos 2 0) < 0.

(2.3)

Another degeneracy occurs when the intersection of the boundary with the contours contains more than just isolated points. In this case, intervals along the boundary coincide with pieces of the contour. Assuming the intervals can be detected, they can be ignored provided that their endpoints are correctly labeled as starting or ending points. This usually requires one of the tests (2.2) or (2.3), as the contours themselves are usually smooth. When the test (1.20) is indeterminate, the turning point in question is a critical point. In this case, the local character of the function can be ascertained by examining the determinant of the Hessian matrix

f~,~, f~,~ f~,~ f~v"


If this determinant is positive, then the turning point is a local minimum or maximum of the function and hence an isolated turning point. On the other hand, if the determinant

124

T.A. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

is negative, then the point is a saddle point, so two contours cross there. In this case, it is a simple matter to identify the two appropriate contours in the list of current contours and interchange their positions. Of course, it is possible that the determinant may be zero, in which case even higher order conditions must be checked. (Strictly speaking, some information may be derived from the individual matrix entries without checking higher order derivatives, but not enough to ascertain the topology of the contours completely.) The tests (2.2) and (2.3) may also be indeterminate, with the same result. These higher order conditions are not derived here, nor have we implemented them in our code. This will likely be an enhancement made to a future version of the software.

3. Topology resolution for surface surface intersection


The surface intersection problem is harder than the planar cut problem. In the planar cut case, the desired contours are trajectories in [0, 1]2. In the surface intersection case, they are trajectories in [0, 1]4. Consider a parametric surface F parametrized by u and v and a parametric surface G parametrized by s and t. Without loss of generality, assume that each is parametrized over [0, 1]2. The goal will be to find all points u, v, s, and t which satisfy

F(u,v) - G(s,t) = 0.

(3.1)

As before, the idea will be to find all mappings from [0, 1] --+ [0, 1]4 (with components u, v, s, and t) such that

F(u(7), v(7)) - a(s(7), t(7)) = 0

(3.2)

A similar algorithm to that used for planar cuts can be used in the general surface intersection case. In this more general case, the topology can still be resolved by keeping track of the parts of the contours as they wend their way through the parameter space for F. To make the algorithm work, the appropriate equations for turning points and the appropriate checks for starting and ending contours must be derived. One additional complication is the possibility of open contours which start or end in the middle of the region. These can occur because the parametric region in [0, 1] 4 n o w has eight boundaries consisting of each variable fixed at its upper or lower limit, only four of which are accounted for by u = 0, u = 1, v = 0, and v = 1. As before, a turning point is still characterized by u' (r) cos 0 + v' (r) sin 0 = 0. (1.3)

Deriving a usable equation to get turning points takes a little more work than before, but it is not difficult. Differentiating the contouring equation (3.2) with respect to the parameter r yields F u u ' ( 7 ) + f ~ v ' ( 7 ) - a s s ' ( 7 ) - a r t ' ( 7 ) = 0, (3.3)

which must hold for all r E [0, 1]. Here, as in the planar cut case, F~, will be an abbreviation for F~,(u(r), v(r)) or F~,(u, v), depending on context. Similar abbreviations Fv,

T.A. Grandine, FIE Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

125

Gs, Gt, F,,~, etc. are used. Thus, the vector (u'(r), v ' ( r ) , s ' ( r ) , t'(r)) is in the null space of the 3 x 4 matrix (Fu Fv - G s - G t ) . The null space of this matrix is given by
multiples of the vector

-I Fu Gs Gt l
-IF,~ IFu Fv Fv Gtl GsI '

(3.4)

where each of the entries is the determinant of the indicated 3 x 3 matrix. In this case, (1.3) becomes (F~ sin 0 - Fv cos 0) - G~ x Gt = 0. Thus, the turning points will be solutions of the 4 x 4 system F ( ~ , v) - a ( 8 , t) = 0, (F~ sin 0 - Fv cos 0) Gs x Gt = 0. (3.6) (3.5)

All the turning points and critical points will be solutions to this system of equations. Finding the contours which start on a boundary can be accomplished by setting one of the four parameters to zero or one and solving the remaining 3 x 3 system. For the cases u = 0, u = 1, v = 0, and v = 1 this generates contours which start or end on the boundary of the surface F . The four cases s = 0, s = 1, t = 0, and t = 1 generate contours which can start anywhere in the domain of F . Thus, the cases for the boundary of F and the boundary of G need to be processed separately. If the boundary point is on the boundary of F , then it can be tested to determine whether it is a starting point or an ending point. Along the horizontal edges (v = 0 and v = 1), the condition is (0.5 - V)V'(T)(V'(T) sin 0 + ~fl(-r) cos 0) > 0. (1.8)

As above, the vector ( u ' ( r ) , v'(T), s'(r),t'(r)) must be a multiple of (3.4), so the condition to check is (0.5 - v)(F~. Gs x Gt)(FusinO - F ~ c o s 0 ) . Gs x Gt > 0. Similarly, the condition along the vertical edges can be derived, and it is (u - 0 . 5 ) ( F ~ . G~ x Gt)(F,,sinO - FvcosO). Gs x Gt > 0. (3.8) (3.7)

If the boundary point is on the boundary of G, it can also be tested to determine whether it is a starting point or an ending point. In the case of the s = 0 boundary, a test that would work would be to compute du COS 0 + d~ sin 0 t a n - 1 d'-~" d,~ sin 0 -- T~ cos 0 ' d~ a-S where tan -~ is interpreted, in this case, takes into account separately the signs of value in the range [-Tr, 7@ i.e., the C or is positive, that says that as s increases (3.9) as the inverse trigonometric function which the numerator and denominator and returns a F O R T R A N a t : a n 2 function. If this quantity (the contour moves away from its boundary

126

TA. Grandine, EV~ Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

in G), the contour heads in the parameter space of F in the increasing panel direction, so it must be a start point for a new contour. Similarly, if the quantity is negative, then it must be an endpoint for an old contour. If multiple contours start or end at that point, they can be ordered according to the magnitude of (3.9). Larger values will correspond to contours which lie above smaller values in either the previous or the next panel. The condition for the s = 1 boundary is the opposite, since the contour must head in the increasing panel direction as s decreases. This requires negating the values d u / d s and dv/ds. One easy way to do this would be to multiply both the numerator and the denominator of (3.9) by (1/2 - s) prior to computing the inverse tangent
(1/2 c o s e + dv sin 0)

tan-I ( 1 / 2 -

s) ( ~ s i n 0 -

~dvCOS0)"

(3.10)

The quantities d u / d s and d v / d s can be determined by parametrizing the contour locally by s at the edge point, where the following equation must be satisfied duF, dv F _ G s at ds u + ds ~ --~sGt =0. (3.11)

This is a 3 x 3 linear system of equations in the variables du/ds, dv/ds, and dt/ds. Solving this system generates the values that can be plugged into (3.10) to determine whether it is a starting or ending point (and how it should be ordered if there is more than one). For the t = 0 and t = 1 edges, the quantity ( 1 / 2 - - t ) ( ~ c o s 0 + dv sin 0) ~tan-I ( 1 / 2 - - t ) ( ~ s i n 0 - - ~-d~ COS0) (3.12)

can be computed by plugging in the values du/dt and d v / d t which are generated by solving the 3 x 3 linear system du F dV F, dt ~' + dt v dS G - Gt = 0. dt s (3.13)

The sign of these values again determine whether points are starting or ending points, and their magnitudes differentiate the various contour brances if there is more than one starting or ending contour at a point. One final problem remains, that of determining whether two new contours start or two old contours end at a turning point. For this, the condition u" (r) cos 0 + v" (~-) sin 0 > 0 (1.14)

must be checked. As before, this is known to be a turning point, so some quantities are known. In particular, F~ Gs x Gt = a \ sin0

cos0)

(3.14)

TA. Grandine, EN Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134
for some c~. Similarly,

127

s'(~-) ] =/3
t' (~-) /

- F ~ . Fv x G~
F~,. Fv x a s

(3,15)

for some/3. Differentiating Eq. (3.3) yields

(F~,uu'(w) + F,.,v'('r))u'('r) + (F,,.vu'('r) + Fv~,v'(w))v'('r) - (Gsss'(9-) + Gstt'(T))S'(T) -- (Gsts'(T) + Gttt'(T))t'(T) = O.


(3.16)

The inner product of this equation with Gs x Gt together with the substitutions (3.14) and (3.15) yield (~/32.y + U"(T) COS0 + v"(9-) sin 0 = 0, where (3.17)

7 = (Fu~. G~ x G t ) ( F ~ . Gs x Gt) 2
- 2(fu,~ Gs x G t ) ( F ~ . Gs x Gt)(P~. Gs x Gt)

+ (Fvv. as a,)(F~, a s x a t ) 2
- (Gs~ G~ x G t ) ( G t " F,, x Fv) 2

+ 2(as~ a s x a~)(as. F,~ rv)(a~. F~ Fv)


- (Gtt" Gs x Gt)(Gs F,, x Fv).
The inner product of (3.14) with (cos0, sin0) gives c~ : cos 0F~L Gs x Gt + sinOFv G~ x Gt. Finally, two new contours will start at the given turning point if c~"/< 0 (3.20) (3.19) (3.18)

there, and two will end if it is negative. If it is zero, then higher order derivative conditions must be checked. Such conditions can be derived, but their infrequency coupled with our ability to change the angle 0 if such an event occurs has allowed us to resist the temptation to do so here.

4. Contour tracking via spline collocation


Both the planar cut problem and the surface intersection problem are special cases of the more general contouring problem. The one dimensional contouring problem is the problem of finding the zero set of a mapping f : R '~+j -+ R ' . In general, the zero set of f will be a one dimensional manifold whose various pieces can each be parametrized over [0, 1]. Thus, the goal will be, for each piece of the contour, to find a mapping x: [0, 1] --+ ]I~n + l such that f ( x ( t ) ) = 0 for all t C [0, 1]. We propose to solve this problem by applying spline collocation to a two point boundary value problem for a differential algebraic equation of index two (cf. (Clark and

128

T.A. Grandine, E l~ Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

Petzold, 1989)). Specifically, if z0 and acl are endpoints for the desiredpiece of the contour, then the problem is to find the mapping z satisfying
=0, x " ( 0 x ' ( t ) = 0,

x(o) =

(4.1)

z0,

z(1) =zl.

This problem is well-posed whenever the desired contour of f is well defined. The first equation demands that the function z map to the contour. Many such functions have this property. The second equation selects, from all possible functions which map to the contour, the function z which is parametrized by arclength. This makes the solution unique in a neighborhood of the desired contour and forces it to be parametrically wellbehaved. Solving this problem numerically is straightforward with standard techniques. Our software uses the spline collocation method of de Boor and Swartz (1973), but other techniques could also be used, including shooting and finite differencing. Spline collocation requires the selection of a spline space S whose members are all C I. 4 The goal will be to find 2 E S such that the distance between z and ~ is less than a user-specified error. The approach is to use spline collocation, i.e., make 2 satisfy Eqs. (4.2) exactly at the collocation points, which, in this setup, are chosen to be the Gauss points of each of the polynomial intervals of the spline space. Thus, if the dimension of the spline space is m, then m - 2 collocation points are selected, say
0 '~ tl < t2 < ' ' " < tin--2 "Q 1,

(4.2)

and the nonlinear system


~(0) = z0,

f('2(t~))

=0,

2"(ti).

~'(t~) = 0, i = 1 , . . . , m -

2,

(4.3)

~(l) =x~,

can be solved for a unique 2 C S. This technique has been analyzed in (Clark and Petzold, 1989) for the linearized version of this problem.

5. Numerical examples
We have tested our code on a number of examples, and we have generated rendered images for some of them. One simple example is the planar cut example shown in Fig. 4, which depicts the analytical solution. The computed solution is shown in Fig. 9, where the red surface is the graph of the function (viewed from the upper right corner of 4A function is said to be G'k if the function and all of its derivatives up through order k are continuous functions.

TA. Gratzdinc, E W Klein IV / Computer Aided Gcmzetric Design 14 (1997)

111-134

129

t e
Fig. 9.

Fig. IO

v,t

I.

--.

Fig. II.

130

ZA. Grandine, E I~ Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

I),1,

U, 8 - ~

)"

Fig. t4.

Fig. 15.

\ /
"ll - +

// \
Fig. 16.

\.

Fig. 17.

T.A. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

131

Table 1 Case
1

Time (sec)
1.3

Components
4

2 3 4 5 6 7 8 9

118.7 14.0 10.8 8.3 12.5 0.1 37.7 3.3

28 11 2 1 2 1 4 1

parameter space), the blue surface is the plane z = 0, and the yellow curves are graphs of the computed intersection curves. The curves in parameter space are shown in the right figure. Resolving the topology and solving the four differential algebraic equations for the four components of the solution required 1.3 seconds of CPU time on the Sun Sparcstation 20. A useful feature of our implementation of the planar cut algorithm is its ability to handle an arbitrary number of dependent variables. Nothing in Eqs. (1.1) and (1.2) requires the number of dependent variables to be three. In practice, this allows for contouring of functions, as in this case, as well as planar cutting of geometry. It has also proved useful in some analysis applications which have larger numbers of dependent variables. A typical example might be pressure on an aircraft wing, which can be modeled as a tensor product spline with four dependent variables (three geometric components for the wing surface and one component for the pressure field). This makes it possible, in a simple and elegant way, to locate constant pressure curves along the wing using exactly the same software as is used to determine pressure profiles along airfoil sections. Some examples constructed using the surface intersection code are shown in Figs. 10 through 17. Each figure consists of three parts. The first part is a color picture of the two surfaces, one in red, and one in blue, and the computed intersection curves shown in yellow. The second parts are the curves plotted in the parameter spaces of the two surfaces. The first plot corresponds to the red surface, while the second plot corresponds to the blue surface. The CPU requirements for each of these cases varied, as shown in Table 1 which reports CPU times for the Sparcstation 20. The third column is the number of contour components in the solution. The second case is perhaps the most difficult of all. The solution consists of 28 separate components. Our algorithm must find all of the points along the boundary (52 in all), all of the turning points (42 in all), and all of the contours passing through each of the panel boundaries. This represents a very large number of nonlinear systems which must be solved. Failure to find even one solution of one of the systems is likely to cause the

132

T.A. Grandine, E IE Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

entire algorithm to fail. Nevertheless, our spline system solver found everything it was supposed to find, and the surface intersection code, after establishing the existence of the 28 intersection components, solved all 28 differential algebraic equations to obtain the solutions shown in Fig. 10. The third case is similar, but not quite as nasty. It is characterized by 11 intersection components, including four small pieces in the corners that do not even appear in the parameter space graph. One additional interesting feature is the presence of closed, nested loops in the interior, all of which are found and resolved by our topology resolution code. The fourth case contains just two components, but neither intersects the parametric boundary. In addition, the contours look very different in the parameter spaces of the two surfaces. The fifth case presents only one difficulty, namely the presence of contour portions very close to each other in the parameter space of the second surface. This problem is included here because some marching scheme codes have struggled with this phenomenon. The sixth case is a plane intersecting a surface through two of its saddle points. This case is difficult because of the presence of crossing contours. We tested this case for a plane which cuts right through the saddle points as well as for planes which pass just above and just below them. The planes which pass just above them generate three contours, one of which is closed. The planes which pass just below them generate two contours which pass near each other at two points. The case shown here is the three contour case. The seventh case is very simple, but it does demonstrate that contours can start and stop in the middle of parametric regions and that our code handles that case. The eighth case is also pretty simple, but the picture of the torus intersecting the saddle surface from the sixth case is such a nice picture that we decided to show it. It does demonstrate that contours closed in one parametric domain may not be closed in the other. The ninth case is due to Bob Ames. It shows half a ship hull intersecting the water. This case is interesting because of the differences in scale between the two parametric regions. An intersection which runs completely across one parametric domain is only a tiny fraction of the other. Our experiments, coupled with our mathematical analysis of the surface intersection problem, suggest that our surface intersection code is very robust and efficient. We continue to explore additional opportunities for expanding its capability and increasing its reliability.

6. Acknowledgements
This work is the culmination of several efforts undertaken by the authors during the course of the last five years. We appreciate the funding and support for this work provided by Navy Contract #N61533-90-D-0033. We are indebted to Bob Ames for his continual interest in and support of this effort, as well as his contribution of the ninth example, which suggested several improvements to earlier versions of the algorithm and code. We thank Dr. Eric Brechner for his assistance in visualizing our results.

TA. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

133

Most of all, we thank Dr. David Ferguson for his unending support and encouragement of our work, and his keen insight, advice, and experience freely shared along the way.
References

Allgower, E.L., Georg, K. and Miranda, R. (1992), The method of resultants for computing real solutions of polynomial systems, SIAM Journal of Numerical Analysis 29, 831-844. Appel, A. (1976), Detecting and rendering intersections of complex surfaces, IBM Technical Disclosure Bulletin 18, 3527-3529. Asteasu, C. (1988), Intersection of arbitrary surfaces, Computer-Aided Design 20, 533-538. Bajaj, C.L., Hoffmann, C.M., Hopcroft, J.E. and Lynch, R.E. (1988), Tracing surface intersections, Computer Aided Geometric Design 5, 285-307. Barnhill, R.E., Farin, G., Jordan, M. and Piper, B.R. (1987), Surface/surface intersection, Computer Aided Geometric Design 4, 3-16. Barnhill, R.E. and Kersey, S.N. (1990), A marching method for parametric surface/surface intersection, Computer Aided Geometric Design 7, 257-280. de Boor, C. and Swartz, B. (1973), Collocation at Gaussian points, SlAM J. Numer. Anal. 10, 582-606. Chen, J.J. and Ozsoy, T.M. (1988), Predictor-corrector type of intersection algorithm tbr C 2 parametric surfaces, Computer-Aided Design 20, 347-352. Cheng, K.-P. (1989), Using plane vector fields to obtain all the intersection curves of two general surfaces, in: Strasser, W. and Seidel, H.-P., eds., Theory and Practice of Geometric Modeling, Springer, Berlin, 187-204. Kenneth, C.D. and Petzold, L.R. (1989), Numerical Solution of Boundary Value Problems in Differential-Algebraic Systems, SIAM J. Sci. Statist. Comput. 10, 915-936. Farin, G. (1992), An SSI Bibliography, in: Barnhill, R., ed., Geometry Processing for Design and Manufacturing, SIAM, 205-207. Filip, D., Magedson, R. and Markot, R. (1986), Surlhce algorithms using bounds on derivatives, Computer Aided Geometric Design 3,295-311. Garrity, T. and Warren, J. (1989), On computing the intersection of a pair of algebraic surfaces, Computer Aided Geometric Design 6, 137-153. Grandine, T.A. (1989), Computing zeros of spline functions, Computer Aided Geometric Design 6, 129-136. Houghton, E.G., Emnett, R.F., Factor, J.D. and Sabharwal, C.L. (1985), Implementation of a divideand-conquer method for intersection of parametric surfaces, Computer Aided Geometric Design 2, 173-183. Kriezis, G.A., Patrikalakis, N.M. and Wolter, E-E. (1992), Topological and differential equation methods for surface intersections, Computer-Aided Design 24, 41-55. Manocha, D. and Demmel, J. (1994), Algorithms for intersecting parametric and algebraic curves, Part I: Simple intersections, ACM Transactions on Graphics 13, 73-100. Miller, J.R. (1987), Geometric approaches to nonplanar quadric surface intersection curves, ACM Transactions on Graphics 6, 274-307. Piegl, L. (1989), Geometric method of intersecting natural quadrics represented in trimmed surface form, Computer-Aided Design 21,201-212. Sederberg, T.W. and Meyers, R.J. (1988), Loop detection in surface patch intersections, Computer Aided Geometric Design 5, 161-171. Sederberg, T.W., Christiansen, H.N. and Katz, S. (1989), An improved test for closed loops in surface intersections, Computer-Aided Design 21,505-508.

134

T.A. Grandine, EW. Klein IV~ Computer Aided Geometric Design 14 (1997) 111-134

Sederberg, T.W. and Nishita, T. (1991), Geometric Hermite approximation of surface patch intersection curves, Computer Aided Geometric Design 8, 97-114. Sherbrooke, E.C. and Patrikalakis, N.M. (1993), Computation of the real solutions of nonlinear polynomial systems, MIT Ocean Engineering Design Laboratory Memorandum 91-12. Sinha, P., Klassen, E. and Wang, K.K. (1985), Exploiting topological and geometric properties for selective subdivision, in: Proceedings ACM Symposium on Computational Geometry, 39--45. Zhao, Kang (1995), Parametrization invariant marching method for SSI, Preprint.

You might also like