25.03.2013 Views

Surface algorithms using bounds on derivatives

Surface algorithms using bounds on derivatives

Surface algorithms using bounds on derivatives

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Computer Aided Geometric Design 3 (1986) 295-311 295<br />

North-Holland<br />

<str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> <str<strong>on</strong>g>using</str<strong>on</strong>g> <str<strong>on</strong>g>bounds</str<strong>on</strong>g><br />

<strong>on</strong> <strong>derivatives</strong><br />

Daniel FILIP, Robert MAGEDSON, and Robert MARKOT<br />

Automati<strong>on</strong> Technology Products, 1671 Dell Aoenue, Campbell, CA 95008, U.S.A.<br />

Received 20 September 1986<br />

Revised 25 February 1987<br />

Abstract. This paper generalizes three very important <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> for surfaces which previously <strong>on</strong>ly worked well<br />

with polynomials. The <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> are calculati<strong>on</strong> of piecewise linear approximati<strong>on</strong>s, min-max boxes, and<br />

surface/surface intersecti<strong>on</strong>s. The class of surfaces that can be handled are all parametric C 2 surfaces. All the<br />

<str<strong>on</strong>g>algorithms</str<strong>on</strong>g> are related by theorems from approximati<strong>on</strong> theory which give informati<strong>on</strong> about the maximum<br />

deviati<strong>on</strong> an approximati<strong>on</strong> to a surface can have if <str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong> partial <strong>derivatives</strong> are known. We generalize<br />

these theorems to work with parametric geometry, and we also show how to obtain the necessary <str<strong>on</strong>g>bounds</str<strong>on</strong>g>.<br />

Keywords. Approximati<strong>on</strong> theory, surface <str<strong>on</strong>g>algorithms</str<strong>on</strong>g>.<br />

1. Introducti<strong>on</strong><br />

Computer Aided Geometric Design (CAGD) is c<strong>on</strong>cerned with <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> to manipulate<br />

parametric curves and surfaces. Unfortunately, many of the well known <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> can <strong>on</strong>ly<br />

work with particular kinds of geometry such as B-splines. In this paper we present <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

for curves and surfaces which <strong>on</strong>ly depend <strong>on</strong> knowing upper <str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong> the <strong>derivatives</strong> of<br />

order two. The <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> described are for piecewise linear approximati<strong>on</strong>, bounding box<br />

determinati<strong>on</strong>, and recursive subdivisi<strong>on</strong> for intersecti<strong>on</strong> problems. All three of these processes<br />

must be d<strong>on</strong>e in almost any surface or solid modeller. For simplicity, the surfaces are assumed<br />

to have a rectangular parameter space, although the <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> can easily be extended to work<br />

with other domains. The <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> are based <strong>on</strong> results from approximati<strong>on</strong> theory, and we<br />

derive some new theorems especially for parametric geometry.<br />

Lane and Carpenter [Lane et al. '79] first used <str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong> <strong>derivatives</strong> for display of<br />

parametric surfaces. However the result from approximati<strong>on</strong> theory that they used [Prenter '75]<br />

is crude and much better results are possible, as we show later. Wang [Wang '84] also used<br />

<str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong> <strong>derivatives</strong> for curve/curve and surface/surface intersecti<strong>on</strong>s. But Wang's result has<br />

problems for technical reas<strong>on</strong>s we discuss later. Koparkar and Mudur [Koparkar et al. '84]<br />

present a set of <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> not unlike ours although their <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> require knowing the zeros<br />

of <strong>derivatives</strong> which, in general, are much harder to find than upper <str<strong>on</strong>g>bounds</str<strong>on</strong>g>. Even for simple<br />

tensor product polynomials, their method involves solving simultaneous n<strong>on</strong>linear equati<strong>on</strong>s.<br />

Their method is also not rigid moti<strong>on</strong> invariant which means that when the surface is moved,<br />

the zeros must be recalculated. The <str<strong>on</strong>g>bounds</str<strong>on</strong>g> we use fortunately are rigid moti<strong>on</strong> invariant and<br />

are also easily adjusted when the surface is affinely transformed. Another algorithm was<br />

developed at McD<strong>on</strong>nell Douglas [Hought<strong>on</strong> et al. '85] to find the intersecti<strong>on</strong> between<br />

arbitrary C 1 surfaces, and is also very similar to the <strong>on</strong>e presented here. However, because no<br />

sec<strong>on</strong>d derivative informati<strong>on</strong> is used, the McD<strong>on</strong>nell Douglas algorithm has a few ad hoc<br />

parameters such as a bounding box expansi<strong>on</strong> factor to try to make a box fit around a surface<br />

0167-8396/86/$3.50 © 1986, Elsevier Science Publishers B.V. (North-Holland)


296 D. Filip et aL / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

and a surface normal ratio factor to try to determine surface flatness. The theory in this paper<br />

describes how to determine these factors very precisely.<br />

In Secti<strong>on</strong> 2 we develop the general theory needed, in Secti<strong>on</strong> 3, we give applicati<strong>on</strong>s of the<br />

general theory, and in Secti<strong>on</strong> 4 we show how to compute the upper <str<strong>on</strong>g>bounds</str<strong>on</strong>g> needed for the<br />

<str<strong>on</strong>g>algorithms</str<strong>on</strong>g>. Secti<strong>on</strong> 5 derives another theorem to improve the <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> in certain cases.<br />

2. General theory<br />

In this secti<strong>on</strong> we present some new and old approximati<strong>on</strong> theoretic results for curves and<br />

surfaces.<br />

2.1. Approximating curves<br />

Wang used the following result for linearly approximating curves, which is proved in [de<br />

Boor '78, p. 39]:<br />

Theorem 1. Let f:[a, b]~ R be any C 2 functi<strong>on</strong> and let l(x)<br />

l(a) =f(a) and l(b)=f(b). Then<br />

sup If(x)-l(x)l


Which implies<br />

D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 297<br />

lie(to) 112~ < lie(to)II IlftS(a-x)l'(x) dxll,<br />

and since I[ e(to)II > 0 (if not we're d<strong>on</strong>e):<br />

lie(t0) [I ~ [[ft~( a- x).f'(x) dxl[<br />

~< sup II/"(x) II II fa( a -- x) dx II<br />

a


298 D. Filip et aL / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

(a)<br />

B<br />

R 2<br />

A C A ~11<br />

Fig. 1. (a) The four regi<strong>on</strong>s of parameter triangle T used in the proof of Theorem 4, and (b) the regi<strong>on</strong> R 1 enlarged.<br />

where<br />

= 0 2i( u, o)l<br />

M1 (u,v)ETSUp an 2 ] ,<br />

sup I°V(u'°),<br />

(u,o)~T OUOO<br />

343= sup<br />

L<br />

O2f(u' v). I<br />

(u,v)~T 0V2 l"<br />

Proof. Let e(u, v)=f(u, v)-l(u, v) and s(u, v)=e(u, v).e(u, v). Since T is compact,<br />

s(u, v) attains its maximum at some point P0 ~ T. If P0 lies <strong>on</strong> the boundary, then we can just<br />

apply Theorem 2 (taking special care if P0 is <strong>on</strong> the hypotenuse of T). So suppose P0 is in the<br />

interior of T. Then (3s/Ou)(po) = 0 = (3s/Ov)(po), which implies e(po) . (Oe/Ou)(Po) = 0 =<br />

e(po). (3e/Ov)(po). Also suppose Po ~ R1, as shown in Fig. 1, the other cases being proved<br />

similarly. Let v=A-Po and write v=(d cos 0, d sin 0) where d= IIA -P0 II and 0 is the<br />

angle between A C and v. The proof now follows similarly to that given for Theorem 2 by<br />

looking at the curve g(t) from Po to A <strong>on</strong> e(u, v). Let g(t) = e(Po + tv), so g(0) = e(Po) and<br />

g(1) = e(A). Writing g(t) in its Taylor series yields:<br />

which implies<br />

,(t) =,(0) + g'(0)t +<br />

g(a) = g(0) + g'(0) +<br />

and expanding out gives<br />

where<br />

e(A) = e(Po) + ( Oe(po)<br />

Ou<br />

1( 02! (<br />

I = fo --'--~ Ou<br />

fotg"(f)(1 ~) d~,<br />

fo'g"(f)(1 f) d~,<br />

d cos 0 + )(Oe'P°-----------" d sin OI ~ + I<br />

0v /<br />

02I<br />

Po + ~v) d2 c°s20 + 2 3--~v (Po + t;v) d2 sin 0 cos 0<br />

+ Ov 202Izkpo + ~v)d 2 sin20)(1 -- ~) d~.<br />

Taking the dot product of the last expressi<strong>on</strong> with e(po), and noting the following equalities:<br />

e(Po) . (8e/au)(po) = 0 = e(Po) . (3e/3v)(po) and e( A) = 0, yields:<br />

O=e(Po) .e(po) + e(Po). I,


which implies<br />

II e(p0)II2< lie(p0)II II I II,<br />

and since II e(po)II > 0 (if not, we're d<strong>on</strong>e), we get<br />

II e(po) II < It 1 II<br />

D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 299<br />

(d 2 c0s2~ M l -4- 2d 2 sin 0 cos 8 M2 + d 2 sin28) I f01(1 - 4) d~]<br />

= ½(d 2 cos28 M 1 + 2d 2 sin 8 cos 8 ME + d 2 sin28).<br />

Now observing Fig. l(b), notice that d cos 8 < ½l 1 and d sin 8 ~< ½12. Therefore<br />

1 2<br />

II e(p0)II < ½(112M1 + 2~1112M2 + z12M3)<br />

= (l?M1 + 21112M2 + []<br />

Barnhill and Gregory [BarnhiU et al. '72] proved a similar theorem for scalar-valued<br />

functi<strong>on</strong>s with more general norms. However, their proof is not easily extended to vector-val-<br />

ued functi<strong>on</strong>s because of its complexity. It is actually possible to extend Theorem 4 to more<br />

general norms, but we elected not to do so for simplicity and also because these norms are<br />

rarely used in CAGD.<br />

It is not difficult to adjust the <str<strong>on</strong>g>bounds</str<strong>on</strong>g> 3/1, M2, and M 3 when f is affinely transformed to a<br />

surface g, where<br />

In this case<br />

g(u, v) = Mf(u, v) + T.<br />

auaav ~v) < II auaav~V) I,<br />

~a+bg(u,<br />

a--.~-.-.a~vt "<br />

V)<br />

. = I[ M aa + bI ( u'<br />

MII aa+bf(u'<br />

where II M II is the norm of the matrix M and is equal to the largest eigenvalue of this 3 × 3<br />

matrix. If the affine transformati<strong>on</strong> is a rigid body moti<strong>on</strong>, then II M I1 equals <strong>on</strong>e and so no<br />

change to the original <str<strong>on</strong>g>bounds</str<strong>on</strong>g> is needed.<br />

We now discuss <strong>on</strong>e more theorem due to Wang [Wang '84] which is directly applied to<br />

rectangular surfaces, and does not require the patches to be split up into triangles.<br />

Theorem 5. Let R c R 2 be the rectangular regi<strong>on</strong> with vertices (A, B, C, D ) of the form<br />

B = A + (l 1, 0), C = A + (0, 12), and D = A + (11, 12). Let Jr: R ~ R 3 be any C 2 functi<strong>on</strong>, and<br />

let l(u, v) be the linearly parametrized quadrilateral with l(A)=I(A)- A, l(B)=Jr(B)+ zl,<br />

t(C) =Jr(C) +A, and l(D) =Jr(D) -A, where A = ¼(f(A) -Jr(B) -Jr(C) +Jr(D)). (lt is not<br />

hard to show that l(u, v) is planar.) Then<br />

where<br />

sup II Jr(u, v) -t(u, v)II < ---ff- V~ (l?M 1 + 2I, I:M~ + I~M3),<br />

(u,v)~R<br />

( a2x2 a2x3 t<br />

M 1=max 3u 2 , 3u 2 , ~ ],<br />

[I 02xl ], a2x2<br />

M2=max~la--~v [ I,[ a2x3 1<br />

OuOv 1'<br />

1<br />

M3=max av 2 , av 2 ' av 2 ]


300 D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

Unfortunately, Wang's theorem has the following problem. Suppose f(u, v) and g(u, v) are<br />

two adjacent surface patches with their respective linear approximates ly and Ig given in<br />

Theorem 5, and suppose [1 f- If I[ and [[ g - i s [I are within some specified tolerance c. Then<br />

although f and g are at least C o across their comm<strong>on</strong> boundary, l! and lg will in general be<br />

completely disjoint. If ! I and I s are replaced by some other linear approximates ! S and l~<br />

which share a comm<strong>on</strong> boundary curve, then there is no guarantee that I[ f-IS [[ and<br />

I[ g- ! s [[ are also within e. Since C O c<strong>on</strong>tinuity of the piecewise linear approximati<strong>on</strong> is<br />

required for almost any algorithm that uses an approximati<strong>on</strong> to a C O surface, we have no<br />

practical use for Theorem 5.<br />

3. Applicati<strong>on</strong>s<br />

In this secti<strong>on</strong> we present three <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> for surfaces which are based <strong>on</strong> Theorem 4. Each<br />

algorithm can be easily modified to work with curves.<br />

3.1. Piecewise linear approximati<strong>on</strong><br />

The problem here is given a C 2 surface f: [0, 1] × [0, 1] ~ R 3 and an arbitrary tolerance c,<br />

find a piecewise linear surface l: [0, 1] × [0, 1] ~ R 3 so that sup II l(u, v) - l(u, v)II < c. This<br />

approximati<strong>on</strong> is important for applicati<strong>on</strong>s where the original surface definiti<strong>on</strong> is difficult to<br />

work with such as in display of the surface and calculati<strong>on</strong> of its mass properties. It is<br />

important that the bound <strong>on</strong> the error in the approximati<strong>on</strong> is known so that any analysis d<strong>on</strong>e<br />

<strong>on</strong> the approximati<strong>on</strong> can take this into c<strong>on</strong>siderati<strong>on</strong>. The traditi<strong>on</strong>al way this problem is<br />

solved for polynomial and rati<strong>on</strong>al polynomial surfaces is by means of recursive subdivisi<strong>on</strong> of<br />

the B-spline or B6zier form and flatness testing [Lane et al. '80; Filip '86]. These schemes have<br />

the advantage over the algorithm to be presented in that the approximating pieces can be<br />

placed adaptively over the surface, that is, more pieces can be placed in areas of greater<br />

curvature, which minimizes the total number of pieces. However, our algorithm runs several<br />

times faster than the adaptive <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> and is being used successfully at ATP. In additi<strong>on</strong>,<br />

the number of additi<strong>on</strong>al pieces used by this algorithm is not much more than necessary since<br />

the surfaces first can be split into its patches, each piece of which usually has the same measure<br />

of curvature. Each patch can then be approximated independently. The algorithm works by<br />

determining the numbers n and m so that after evaluating at the (n + 1)(m + 1) grid of points<br />

{( ) (1)(2 O) ( ) (__1) (1 1)(2 __1) ..,(1,1)}, (3.1)<br />

0,0, ,0 , , ,..., 1,0, 0, m . . . . m '"<br />

and forming the 2nm triangles from the points, we have our desired approximati<strong>on</strong>. More<br />

simply stated, we want to determine the step sizes 1/n and 1/m in the u and v directi<strong>on</strong>s for<br />

evaluati<strong>on</strong>. With polynomial and rati<strong>on</strong>al polynomial surfaces, the most comm<strong>on</strong> forms of<br />

surfaces in CAGD, these evaluati<strong>on</strong>s can be d<strong>on</strong>e very rapidly <str<strong>on</strong>g>using</str<strong>on</strong>g> forward differencing.<br />

Let l 1, l 2, M 1, M 2, and M 3 be as in Theorem 4. Also let l I = 1/n and let l 2 = 1/m. Then,<br />

from Theorem 4 we desire<br />

-8 MI+ nm 2+ M 3 =c. (3.2)<br />

We say that the u directi<strong>on</strong> is 'flat' if M 1 = O, i.e., the u directi<strong>on</strong> is linear. Likewise, we say the<br />

v directi<strong>on</strong> is 'fiat' if M 3 = O. If the u directi<strong>on</strong> is flat and the v directi<strong>on</strong> is not, then n is<br />

automatically set to <strong>on</strong>e. Similarly, if the v directi<strong>on</strong> is flat and the u directi<strong>on</strong> is not, then m is<br />

automatically set to <strong>on</strong>e. If both directi<strong>on</strong>s are flat, then n and m are set to be the same.


D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 301<br />

Otherwise, the algorithm proporti<strong>on</strong>ally rolls in the mixed partial term M 2 into the number of<br />

steps in u and the number of steps in v based <strong>on</strong> the ratio M1/M 3. Thus we have four cases:<br />

Case 1: M 1 > 0 and M 3 > 0. Let k = 3/11/3/13, and set n/m = k, which means n = km. Then<br />

from equati<strong>on</strong> (3.2) we have<br />

1 ( 1 M+ ~2 M + -l---2-M3/m]<br />

Solving for m we obtain<br />

Case 2:<br />

Solving for n we obtain<br />

Case 3:<br />

Case 4:<br />

km 2 2<br />

m = -~e ( M 1 + 2kM 2 + k2M3 ).<br />

.-~-(..<br />

M 1 > 0 and M 3 = 0. Let m = 1. Then from equati<strong>on</strong> (3.2) we have<br />

1 M<br />

M 1 = 0 and M 3 > 0. This is the same as Case 2 with the roles of n and m switched.<br />

M1 = 0 = M 3. This case is the same Case 1 with k = 1, i.e.<br />

n~--m= V/1 ~ ( M1+ 2 M2 + M3 )<br />

Crack Preventi<strong>on</strong>. Usually an object c<strong>on</strong>sists of many surfaces and if the object is c<strong>on</strong>tinuous,<br />

then the piecewise linear approximati<strong>on</strong> to the entire object is usually expected to be<br />

c<strong>on</strong>tinuous. However, if the above algorithm is applied to two different adjacent surfaces<br />

independently, then cracks can appear between the linear approximati<strong>on</strong>s to adjacent surfaces<br />

[Filip '86]. This is caused by adjacent surfaces being subdivided to different depths. One simple<br />

way to eliminate this problem is to subdivide all the surfaces to the same depth as the patch<br />

that needs the most subdivisi<strong>on</strong>. The problem with this soluti<strong>on</strong> is that it will generate an<br />

unduly large number of approximating pieces if just <strong>on</strong>e of the surfaces is highly curved.<br />

A much better soluti<strong>on</strong> to this problem is the following. First piecewise linearly approximate<br />

each boundary curve to the accuracy of c by applying the piecewise linear approximating<br />

scheme to the curve case. Then when evaluating the grid of points in set (3.1), if a point lies <strong>on</strong><br />

the boundary of the surface, move it to the closest point <strong>on</strong> the approximati<strong>on</strong> to the boundary.<br />

Since two adjacent surfaces share a comm<strong>on</strong> boundary curve, the approximati<strong>on</strong> to that curve<br />

will be the same from both patches. So because boundary points are moved to that approxima-<br />

ti<strong>on</strong>, no cracks will occur. One should notice that polyg<strong>on</strong>s from the approximati<strong>on</strong> al<strong>on</strong>g the<br />

boundary may have more than three sides and may be n<strong>on</strong>-planar (Fig. 2). These boundary<br />

polyg<strong>on</strong>s can easily be triangulated if required. It is very important to note, however, that the<br />

resulting approximati<strong>on</strong> may not be within c in the neighborhood of the boundary curves. One<br />

way to get around this problem is to approximate the boundary curves and the surfaces to a<br />

tolerance of c/2. Empirically, though, we have found that <str<strong>on</strong>g>using</str<strong>on</strong>g> this tighter tolerance is usually<br />

unnecessary, and subdividing everthing to tolerance of just E seems to work fine in practice.<br />

3.2. Min-max bounding box<br />

The bounding box of a surface f(u, v) is defined by two points (P0, Pl), where P0 =<br />

(x~, Ymi~, Zmin) and Pl = (Xm~x, Ym~x, Zm~), SO that any point (x, y, z) <strong>on</strong> the surface<br />

B ~<br />

~r~nlm ~Dot ~rdtuat~ ea Ir~m~


302 D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

satisfies<br />

Xmi n ~


D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 303<br />

show how to dramatically speed up these two processes. Flatness testing is usually d<strong>on</strong>e for<br />

polynomial surfaces by testing whether its Brzier or B-spline points are co-planar within E,<br />

which can be very costly. Also this scheme depends <strong>on</strong> having polynomial surfaces. Wang<br />

[Wang '84] first published a means to eliminate flatness testing by determining a subdivisi<strong>on</strong><br />

depth r so that after r levels of recursive midpoint subdivisi<strong>on</strong>, all the subsurfaces are<br />

guaranteed to be flat within c. His method, which we will now describe, works very similarly to<br />

the piecewise linear approximati<strong>on</strong> algorithm given in Secti<strong>on</strong> 3.1. (We use Theorem 4 rather<br />

than his Theorem 5 for reas<strong>on</strong>s discussed earlier.) First note that after r levels of midpoint<br />

subdivisi<strong>on</strong> of the parameter space [0, 1] × [0, 1] that l I = l 2 ----- 1/2 r. Using Theorem 4 the same<br />

way as in Secti<strong>on</strong> (3.1), we have<br />

)<br />

g MI-t- - - + =~.<br />

(2r) 2M2 (:r)2<br />

Solving for r (and taking the ceiling since r is an integer) yields<br />

We can improve Wang's algorithm in the case where <strong>on</strong>e of the parametric directi<strong>on</strong>s is flat<br />

and the other is not. For example, suppose the u directi<strong>on</strong> is flat and v directi<strong>on</strong> is not. In this<br />

case it is better to split <strong>on</strong>ly al<strong>on</strong>g c<strong>on</strong>stant v parameter lines rather than in both parametric<br />

directi<strong>on</strong>s. Then after r levels of subdivisi<strong>on</strong> we have l 1 = 1, and l 2 --1/2 ~. Again <str<strong>on</strong>g>using</str<strong>on</strong>g><br />

Theorem 4 we have<br />

and thus we get<br />

-~ (2r)2 M3 =c,<br />

1M +<br />

Although Wang's method for flatness testing is independent of the type of geometry used,<br />

his algorithm still depends<strong>on</strong> use of the B6zier c<strong>on</strong>trol points for bounding box determinati<strong>on</strong>.<br />

We now show how to get rid of this dependency and at the same time generate a bounding box<br />

with less computati<strong>on</strong>al cost. Let (P0, Pl) be the min-max bounding box of the four comers of<br />

l(u, v). Using the analysis from Secti<strong>on</strong> 3.2 we know f lies in the box (P0 - (K0, K0, K0), Pl<br />

+ (K0, Ko, K0)), where K 0 = -~(M a + 2M 2 + M3). Now c<strong>on</strong>sider the patches fa, I2, f3' and<br />

f4 generated from midpoint subdivisi<strong>on</strong> of f. Let (P0i, Px;) be the min-max bounding box of<br />

the four comers point of patch ~. Then it is easy to see that (P0,- (K1, Ka, K1), Pl, +<br />

(Ka, K1, Ka)) <str<strong>on</strong>g>bounds</str<strong>on</strong>g> L, where K 1 = Ko/4. Using inducti<strong>on</strong>, it is also easy to show that given<br />

K~ from subdivisi<strong>on</strong> level i, /£,+1 = Ky4 is the amount needed to 'swell' the bounding box of<br />

the comers of a sub-patch from recursive level i + 1 in order to bound that subpatch. The<br />

following pseudo-code should further illustrate the ideas presented in this secti<strong>on</strong>. For simplic-<br />

ity we exclude the optimizati<strong>on</strong> to Wang's method when the surface is flat in <strong>on</strong>e directi<strong>on</strong>.<br />

Procedure SURFACE_INTERSECT(S1, $2, tolerance)<br />

/. intersect surface $1 and $2 to an accuracy of tolerance •/<br />

K1 = (M1 + 2 * M2 + M3)/8 <str<strong>on</strong>g>using</str<strong>on</strong>g> M1, M2, M3 from $1 / • Swell factor * /<br />

rl = log 4(K1/tolerance)/. necessary subdivisi<strong>on</strong> depth for flatness */<br />

K2 = (M1 + 2 * M2 + M3)/8 <str<strong>on</strong>g>using</str<strong>on</strong>g> M1, M2, M3 from $2<br />

r2 = log 4(K1/tolerance)


304 D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

SURF2I(0, S1, SI(0, 0), SI(1, 0), SI(0, 1), SI(1, 1), 0, 0, 1, 1, K1, rl, $2, $2(0, 0), $2(1,0),<br />

$2(0, 1), $2(1, 1), 0, 0, 1, 1, K2, r2)<br />

END SURFACE INTERSECT<br />

Procedure SURF2I(d, S1, P1, P2, P3, P4, ull, vll, u12, v12, K1, rl, $2, Q1, Q2, Q3, Q4, u21,<br />

v21, u22, v22, K2, r2)<br />

/* Input parameter d: the current subdivisi<strong>on</strong> depth */<br />

/* Input Parameters for S1 ($2 are similar): */<br />

/. P1, P2, P3, P4 are c<strong>on</strong>ers points */<br />

/* (ull, vll) is lower left corner of parameter domain •/<br />

/* (u12, v12) is upper right comer of parameter domain */<br />

/. K1 is bounding box swell factor * ,/<br />

/* rl is the maximum subdivisi<strong>on</strong> depth necessary •/<br />

(A0, A1) = min-max bounding box of (P1, P2, P3, P4}<br />

A0 = A0 - (K1, K1, K1)<br />

A1 = A1 + (K1, K1, K1)<br />

(B0, B1) = min-max bounding box of (Q1, Q2, Q3, Q4}<br />

B0 = B0 - (K2, K2, K2)<br />

B1 = B1 + (K2, K2, K2)<br />

if (A0, A1) and (B0, B1) do not intersect<br />

then return<br />

else if kl >/rl and k2 >~ r2 then /* S1 and $2 are flat * ,/<br />

Output intersecti<strong>on</strong> curve of the linear approximati<strong>on</strong>s to S1 and $2<br />

else if kl >~ rl and k2 < r2 then /* S1 flat and $2 not flat */<br />

/* <strong>on</strong>ly generate subpatches for $2 */<br />

u2 = (u21 + u22)/2<br />

v2 = (v21 + v22)/2<br />

Q5 = $2(u2, v21)<br />

Q6 = $2(u21, v2)<br />

Q7 = $2(u2, v2)<br />

Q8 = $2(u22, v2)<br />

Q9 = $2(u2, v22)<br />

SURF2I(d + 1, $1, P1, P2, P3, P4, ull, vll, u12, v12, K1, rl,<br />

$2, Q1, Q5, Q7, Q6, u21, v21, u2, v2, K2/4, r2)<br />

SURF2I(d + 1, S1, P1, P2, P3, P4, u/l, vll, u12, v12, K1, rl,<br />

$2, Q5, Q2, Q7, Q8, u2, v21, u22, v2, K2/4, r2)<br />

SURF2I(d + 1, S1, P1, P2, P3, P4, ull, vll, u12, v12, K1, rl,<br />

$2, Q6, Q7, Q3, Q9, u21, v2, u2, v22, K2/4, r2)<br />

SURF2I(d + 1, S1, P1, P2, P3, P4, ull, vll, u12, v12, K1, rl,<br />

$2, Q7, Q8, Q9, Q4, u2, v2, u22, v22, K2/4, r2)<br />

else if kl < rl and k2 >t r2 then ... /* $2 flat and S1 not flat ,,/<br />

else ... /* both $1 and $2 are not flat * ,/<br />

END SURF2I<br />

We remark here <strong>on</strong> some properities of this algorithm. First, it is independent of any surface<br />

representati<strong>on</strong> and <strong>on</strong>ly depends <strong>on</strong> being able to evaluate the surface and knowing <str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong><br />

the sec<strong>on</strong>d order partials of the surfaces. Sec<strong>on</strong>d, the algorithm <strong>on</strong>ly needs to subdivide the<br />

parameter space and does not need to subdivide the surface definiti<strong>on</strong>, like in traditi<strong>on</strong>al B6zier<br />

subdivisi<strong>on</strong>. Third, the algorithm is adaptive in the sense that <strong>on</strong>ly the porti<strong>on</strong>s of the surfaces<br />

whose bounding boxes intersect need to be subdivided. Fourth, it is <strong>on</strong>ly necessary to find the


D. Filip et at. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 305<br />

min-max box of the comer points to generate the bounding box of the surface rather than<br />

finding the min-max of all the c<strong>on</strong>trol points (if the surface is a polynomial). Also note that K1<br />

and K2 are independent of the tolerance and so may be computed <strong>on</strong>ce and then stored with<br />

the surface definiti<strong>on</strong>. From empirical evidence we find that even if the surface is a polynomial<br />

that this algorithm can run an order of magnitude or more faster than the traditi<strong>on</strong>al algorithm<br />

based <strong>on</strong> subdivisi<strong>on</strong> and flatness testing of the c<strong>on</strong>trol points. One reas<strong>on</strong> is that all the<br />

evaluati<strong>on</strong>s can be d<strong>on</strong>e <str<strong>on</strong>g>using</str<strong>on</strong>g> Homer's rule <strong>on</strong> the power basis form of a polynomial. As in<br />

almost every surface intersector, the output of the line segments must be sorted if c<strong>on</strong>tiguous<br />

intersecti<strong>on</strong> curves are desired. These intersecti<strong>on</strong> curves may then be refined by a Newt<strong>on</strong> like<br />

method to generate more accurate curves [Hought<strong>on</strong> et al. '85].<br />

4. Calculating the <str<strong>on</strong>g>bounds</str<strong>on</strong>g> of the partials of order two<br />

In this secti<strong>on</strong> we discuss how to obtain the numbers M 1 = l[ a2I/<strong>on</strong>2 II, ME = II o2f/auav II,<br />

and M 3 = II a21/av2 II. Fortunately these numbers can be calculated in a straightforward<br />

manner for many of the comm<strong>on</strong> surface types used in CAGD. Also, it is not important that<br />

the calculati<strong>on</strong> of these numbers be d<strong>on</strong>e very quickly since they <strong>on</strong>ly need be d<strong>on</strong>e <strong>on</strong>ce for a<br />

given surface as a preprocessing step and then stored with the surface definiti<strong>on</strong>. Because many<br />

of the formulas for <str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong> the surfaces can be broken down into a sequence of curve<br />

problems, we first discuss finding <str<strong>on</strong>g>bounds</str<strong>on</strong>g> for curves. The <str<strong>on</strong>g>bounds</str<strong>on</strong>g> for curves are also needed if<br />

the <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> described in Secti<strong>on</strong> 3 are applied to the curve case.<br />

4.1. Bounds <strong>on</strong> curves<br />

To find the <str<strong>on</strong>g>bounds</str<strong>on</strong>g> of the partials of order two for some of the surfaces discussed in the next<br />

secti<strong>on</strong>, we require knowledge of the <str<strong>on</strong>g>bounds</str<strong>on</strong>g> of certain curves and their <strong>derivatives</strong> of order <strong>on</strong>e<br />

and two. The curves involved are often polynomials or rati<strong>on</strong>al polynomials. In this secti<strong>on</strong> we<br />

<strong>on</strong>ly discuss finding these <str<strong>on</strong>g>bounds</str<strong>on</strong>g> for curves which are functi<strong>on</strong>s from [0, 1] to the reals since<br />

the surface case usually deals with <str<strong>on</strong>g>bounds</str<strong>on</strong>g> for each comp<strong>on</strong>ent functi<strong>on</strong> seperately and then<br />

later combines the <str<strong>on</strong>g>bounds</str<strong>on</strong>g>.<br />

One simple method for finding the desired <str<strong>on</strong>g>bounds</str<strong>on</strong>g> <strong>on</strong> a polynomial curve c(t) of degree n is<br />

first to write it in its B~zier form (Boehm et al. '84]<br />

where<br />

i=n<br />

c( t ) = ~ biB~,<br />

i=0<br />

i 1 - t)n-lt i<br />

u~[0,1], b~R,<br />

is an element of the Bemstein basis (a basis for the vector space of polynomials of degree n).<br />

Because each basis element is positive over [0, 1] and the basis forms a partiti<strong>on</strong> of unity (i.e.<br />

sum to <strong>on</strong>e), it is easy to show<br />

sup Ic(t) l~< max (Ibil}.<br />

tE[O,1] O


306 D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

The derivative of a Brzier curve is a Brzier curve of lower degree<br />

and thus<br />

n-1<br />

c'(t)= Y'~ n(bi+a-bi)B n-l,<br />

i=0<br />

n-2<br />

c"(t) = ~, n(n- 1)(6/+ 2 -- 2bi+a + bi)BF -1,<br />

i=0<br />

sup Ic'(t)l~


neously by <str<strong>on</strong>g>using</str<strong>on</strong>g> the<br />

represented. The x(u,<br />

D. Filip et aL/ <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 307<br />

power basis form, by which all these other forms can also be exactly<br />

v) comp<strong>on</strong>ent of a degree n by m polynomial takes the form<br />

),<br />

x(u, v)= ai,jv j u, ai, j~R.<br />

i=0 \j=O ]<br />

We can also write the surface in another way<br />

where<br />

x(u, o)= E c,(v)u,<br />

i=0<br />

n<br />

i (4.1)<br />

rn<br />

ci(v)= E ai,j v'i. (4.2)<br />

y=O<br />

Using this form, it is easy to obtain the <str<strong>on</strong>g>bounds</str<strong>on</strong>g> needed. We first calculate the numbers (Ai, k }<br />

<str<strong>on</strong>g>using</str<strong>on</strong>g> the curve case, where<br />

Ai,k=su p dkc~(V)dv ~ , O


308 D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

Three special cases frequently used are<br />

(1) Translati<strong>on</strong>al Sweep. A 2½-D surface results when D(v) is a linear curve and k(v) is a<br />

c<strong>on</strong>stant functi<strong>on</strong>.<br />

(2) 3-D Sweep. Let k(v)= 1. Then S(u, v) can be thought of as C(u) being swept al<strong>on</strong>g<br />

D(v) or visa-versa.<br />

(3) Spherical Product [Barr '81]. Let da(v ) = d2(v ) = c3(u ) = 0. So<br />

x(u,v)=k(v)q(u),<br />

y(u, v)=k(v)c2(u ),<br />

z(u, v)=da(v ).<br />

Then C(u)= [ca(u) c2(u) 0] is a curve in the x-y plane and E(v)= [k(v) d3(v)] can be<br />

c<strong>on</strong>sidered a curve in the x-z plane. Any quadric or superquadric [Barr '81] can be parame-<br />

trized as a spherical product of c<strong>on</strong>ics or superc<strong>on</strong>ics. If C(u) is some parameterizati<strong>on</strong> of the<br />

unit circle, then S(u, v) is a surface of revoluti<strong>on</strong> with cross secti<strong>on</strong> E(v) and axis [0 0 1].<br />

Since in the general case all three comp<strong>on</strong>ent functi<strong>on</strong>s look identical, we just c<strong>on</strong>sider the<br />

X(U, V) = k(V)Cl(U ) + dl(V ) comp<strong>on</strong>ent:<br />

a x(u, o)<br />

OU 2<br />

= k(v)<br />

d2q(u)<br />

du 2<br />


5. Geometric vs. parametric distance<br />

D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 309<br />

C<br />

k<br />

Fig. 3. Each point of the curve C is<br />

within the tolerance of some point <strong>on</strong> the<br />

line segment L, but the line is still not a<br />

good approximati<strong>on</strong> to the curve.<br />

So far we have been defining the distance between a functi<strong>on</strong> f and an approximati<strong>on</strong> 1<br />

both over some domain D to be<br />

sup II f(v) - l(P)ll,<br />

P~D<br />

which we now define as the parametric distance de( f, i). However, for some applicati<strong>on</strong>s such<br />

as display of a surface, this parametric distance is not important as l<strong>on</strong>g as each point of f(D)<br />

is within the tolerance t of some point of l(D). C<strong>on</strong>sider the following definiti<strong>on</strong> of the<br />

distance between two functi<strong>on</strong>s g and h <strong>on</strong> a domain D.<br />

dG,(g, h) = sup ( inf lIB- All}.<br />

A ~g(D) k B~h(D)<br />

In our case we want da, ( f, l)


310 D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g><br />

Now let C2(v ) =/(u o, v), L2(v ) = (1 - v)f(A) + of(C), and let C3(/3 ) =/(u o + ll, v), L3(v )<br />

= (1 - v)I(B) + of(D). Then<br />

and similarly<br />

d(P 2, Q)


D. Filip et al. / <str<strong>on</strong>g>Surface</str<strong>on</strong>g> <str<strong>on</strong>g>algorithms</str<strong>on</strong>g> 311<br />

Lane, J.M. and Carpenter, L. (1979), A generalized ~ line algorithm for the computer display of parametrically<br />

defined surfaces, Computer Visi<strong>on</strong>, Graphics, and Image Processing 11, 290-297.<br />

Lane, J.M. and Riesenfeld, R.F. (1980), A theoretical development for the computer generati<strong>on</strong> and display of<br />

piecewise polynomial surfaces, IEEE Trans. Pattern Anal. Machine InteU. 2 (1) 35-46.<br />

Lane, J.M. and Riesenfeld, R.F. (1981), Bounds <strong>on</strong> a polynomial, BIT 21, 112-117.<br />

Prenter, P.M. (1975), Splines and Variati<strong>on</strong>al Methods, Wiley, New York.<br />

Wang, G. (1984), The subdivisi<strong>on</strong> method for finding the intersecti<strong>on</strong> between two B~zier curves or surfaces, Zhejiang<br />

University J., Special Issue <strong>on</strong> Computati<strong>on</strong>al Geometry (in Chinese).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!