guaranteed ray intersections with implicit surfaces

Upload: daniel-simoes-lopes

Post on 10-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Guaranteed Ray Intersections With Implicit Surfaces

    1/10

    ~ Computer Graphics, Volume 23, Number 3, July 1989l l l l

    Guaran teed Ray Intersections with Implicit SurfacesDevendra KalraAlan H. BarrComputer Science DepartmentCalifornia Inst itute of Technology

    Pasadena, California 91125A bs t r a c tI n th i s p a p e r , w e p r e s e n t a r o b u s t a n d m a t h e m a t i c a l l y so u n d r a y -i n t e r s e c ti o n a l g o r i t h m f o r i m p l i c i t s u r f ac e s . T h e a l g o r i t h m i s g u a r -an teed to nume r ica l ly f ind the neare s t i n t ersec t ion o f the su r face wi tha ray , and i s guar an tee d no t to m iss f ine fea tu res o f the su r face . I td o e s n o t r e q u i r e f i n e t u n i n g o r h u m a n c h o i ce o f in t e r a c t i v e p a r a m e t e r s .I n s t e a d , i t r e q u i r e s tw o u p p e r b o u n d s : " L " t h a t l i m i t s t h e n e t r a t e o fchange o f the impl i c i t su r face funct ion f ( x , y , z ) a n d " G " t h a t l i m i t sthe ra t e o f change o f the g rad ie n t . We refer to an impl i c i t su r face wi tht h e s e r a t e l i m i t s a s a n " L G - i m p l i c i t s u r f ac e . "

    E x i s t i n g s c h e m e s t o i n t e r s e c t a r a y w i t h a n i m p l i c i t s u r f a c e h a v et y p i c a l l y b e e n g u a r a n t e e d t o w o r k o n l y f o r a l i m i t e d s e t o f i m p l i c i tfunct ions , such as quadr i c su r faces o r po lynom ial s , o r e l se have beena d - h o c a n d h a v e n o t b e e n g u a r a n t e e d t o w o r k. O u r t e c h n i q u e s i g n if i -can t ly ex ten ds the ab i l i t y to in t ersec t rays wi th impl i c i t su r faces in ag u a r a n t e e d f a s h io n .C R C a t e g o r i e s a n d S u b j e c t D e s c r i p t o r s : 1 .3. 3 ( P i c t u r e / I m a g eG e n e r a t i o n ) - d i s p l a y a l g o r i r t h m s ; 1 . 3. 5 ( C o m p u t a t i o n a l G e o m e t r yand Obje c t Model ing) - Curve , su r face , so l id and ob jec t rep resen-t a t i o n s , G e o m e t r i c a l g o r i t h m s , l a n g u a g e s a n d s y s t e m s ; 1 . 3 .7 ( T h r e e -D i m e n s i o n a l G r a p h i c s a n d R e a l i s m ) - C o l o r , s h a d in g , s h a d o w i n g a n dtex tu re , Vi s ib le l i ne / su r face a lgo r i thms ;K e y w o r d s : I m p l i c i t S u r f a c e s, F G uy T r a c i n g , R e n d e r i n g , S a m p l i n g ,S u b d i v i s i o n , L i p s c h i t z C o n s t a n t 1 I n t r o d u c t i o nThe t ask o f in t ersec t ing rays wi th impl i c i t su r faces (see Figure 1 ) is ani m p o r t a n t p a r t o f t h e t h e o r y a n d a p p l i c a t i o n o f r a y c a s t i n g a n d r a yt r a c i n g . I m p l i c i t f u n c t io n s c a n b e u s e d t o r e p r e s e n t s o m e u s e f u l a n din teres t in g su r faces The y a l so have a n i ce comp os i t ion p rope r ty int h a t t h e y c a n b e c o m b i n e d i n g e o m e t r i c a l l y u se f u l a n d c o n c i s e w a ys t og e n e r a t e n e w i m p l i c i t f u nc t i o ns E x a m p l e s o f th e s e a r e t h e a l g e b r a i csurfaces introduced by Blinn [BLtI ' ,Ir , ,I82 ] and ex tens ions (Figure 16 and20).

    The reader m igh t be su rp r i sed to f ind tha t i t is imposs ib le to crea tea n a l g o r i t h m ( b a s e d s o l e ly o n t h e e v a l u a t i o n o f t h e i m p l i c i t f u n c t i o n a tpo in t s in space) which i s guar an tee d to co rrec t ly in t ersec t a ray wi th anarb i t ra ry i m p l i c i t s u r fa c e . F o r a n y a l g o r i t h m t h a t c o u l d b e c o n s t r u c t e d ,t h e r e e x i s t t r o u b l e s o m e f u n c t i o n s f ( x ,y , z ) f or w h i c h i m p o r t a n t p a r t s o fthe su r faces are missed . Figure 2 i l l u s t ra t es th i s p rob lem. In th i sexample , we would need in fo rmat io n abo u t the ex i s t ence o f a sp ike inbetween the sampl e po in t s , wh ich i s no t avai l ab le f rom the va lues o ft h e f u n c t i o n o b t a i n e d a t t h e s a m p l e p o i n t s .

    T h u s , t o g u a r a n t e e r a y i n t e r s e c t i o n s w it h i m p l i c i t su r f a c es , s o m esor t o f aux i l i a r y in fo rm at ion i s needed . In our case , we have chosent h i s a u x i l i a r y in f o r m a t i o n t o b e t h e L a n d G r a t e l i m i t s .

    Permiss ion to copy wi thou t fee a l l o r par t o f th i s mater i a l i s g ran tedprov ided tha t t he cop ies are no t made o r d i s t r ibu ted fo r d i rec tcommercia l advan tage , t he ACM copyr igh t no t i ce and the t i t l e o f thepub l i ca t ion and i t s da te appear , and no t i ce i s g iven tha t copy ing i s bypermiss ion o f the Associa t ion fo r Comput ing M ach inery . To copyo therwise , o r to repub l i sh , requ i res a fee and /o r speci f i c permiss ion .

    1989 ACM-0-g9791-312-4/89/007/0297 $0O.75

    S u r f a c e

    Fig ure 1:A,1 implicit surface is defined by f( ~, V, z) = 0. f( x, y, z) is negativeinside the surface, positive outside the surface and zero on the surface. The rayintersects the surface at Xnear and X Jar.

    \

    Fi gu re 2: A spike flmction demonstrates some of the difficulties of sampling with-out sufficient inform ation about the fun ction being sampled. The above surface ateach of the samples has zero curvature; the samples do not indicate the presence ofa spike since the spike falls between the sa mplin g points.

    1 .1 A Need For "Guaranteed" AlgorithmsS o m e r e a d e r s m i g h t q u e s t i o n t h e u t i l i t y o f d e v e l o p in g a n a p p a r e n t l yc o m p l e x a l g o r i t h m u s i n g t h e m a t h e m a t i c a l m a c h i n e r y o f L a n d Gb o u n d s . T h e y c o u l d a l so q u e s t i o n t h e n e e d t o d i r e c t ly r e n d e r c o m p l e xm o d e l i n g p r i m i t i v e s , i n s t e a d o f c o n v e r t in g i n t o m o r e e a s i l y r e n d e r a b leob jec t s such as po lygons Final ly , t hey migh t ques t ion the u t i l i t y o fimpl i c i t funct ions a t a l l. They cou ld be l ieve tha t t here would be noneed fo r su r face types beyo nd b icub ic pa tches , quadr i c su r faces , andp o l y g o n s f or t h e i r m o d e l i n g n e e d s .

    The a nswer to the f i r s t ques t ion i s s t ra ig h t fo rw ard . Given the L and .G n u m e r i c r a t e c o n s t a n t s , o u r a l g o r i t h m a c t u a l l y i s q u i t e s i m p l e a n de a s y t o i m p l e m e n t . T h e a m o u n t o f co d e f or t h e a l g o r i t h m i s r e l a t i v e l ys m a l l a n d i s e a si l y p u t i n t o a s t a n d a r d r a y t r a c i n g p r o g r a m .

    M o r e i m p o r t a n t l y , h o w e v e r , t h e a l g o r i t h m guaran tees t h a t w e w i l lf ind a l l o f the co rrec t ray in t e rsec t ions in the en t i r e image. I f we wereto f i r s t conver t t he impl i c i t model in to po lygons , we would have top r o d u c e a " g u a r a n t e e d " p o l y g o n a l t e s s e l a t i o n o f t h e s ur f a c e . T h i s i s

    29 7

  • 8/8/2019 Guaranteed Ray Intersections With Implicit Surfaces

    2/10

    & lI G G R A P Ha non-trivial task for general implicit surfaces, and could depend onthe camera view angles and viewing parameters of the scene. (Ourtechnique can be adapte d to produce gu aranteed polygonalizations, butwe feel direct rendering is easier).Even in directly rendering a geometric primitive, rather than itspolygonal tesselation, a "guaranteed" technique, which does not requireany corrective interaction or fine tuning of parameters by a human be-ing, is most vahlable. Tbis is especially attract ive to people makingcomputer animation. In fact, we frequently use computer animati on asa means to verify the accuracy of our rendering algorithms. Imaginerunning ion gscri pts to make a movie and then finding that frame num-ber 129 has pixel dropouts because the frame uses a particu lar cameraangle and parameters for the rendering algor ithm that worked for otherframes but do not work for this frame. The recourse is to find the rightset of parameters for this frame and restart the animation until wenotice other anomalies. With a guaranteed "direct" method, one isassured of the correctness of the whole sequence, without re-renderingframes.

    Even in making still-frames, much time is spent modeling a scene.With an algorithm that guarantees the correctness of the rendering,there is less to worry about, as changes are made to other object pa-rameters of the scene.The utility of having a wider variety of surface types can be seenin Figures 16 and 20. The pol ygonal or patch re prese ntati on for theseobjects would be more difficult to specify and would require moie datathan implicit techniques.Finally, developing a "direct" guaranteed algorithm that works ev-ery time without any searches through a parameter space was an ex-hilarati ng research experience for us.1 . 2 P r e v i o u s M e t h o d s T o R e n d e r I m p l i c i t S u r f a c e sAn implic it surface S is defined by a funct ion S : f( x) = 0. The func-tion is negative inside the surface and positive outside (Figure 1).P o l y n o m i a l I m p l i c i t F u n c t i on sThe efforts to render impl icit surfaces have been two-fold. The first ap-proach has been to li mit types of imp lici t functions. [HANRAHAN 83]limited the implicit functions to be polynomia l functions of spatial vari-ables. Using some results presented in [USPENSKY 48] and [COLLINSand AI

  • 8/8/2019 Guaranteed Ray Intersections With Implicit Surfaces

    3/10

    ~ Com puter Graphics , Volume 23 , Num ber 3 , Ju ly 1989

    " 'qA / \

    Fi g u re 4 : Gi ven a po i n t Z 0, r = f (x 0 ) / ,C i s t he r a d i u s o r t he sphe re S ~ oun d X0s u c h t h a t. f ( z ) d o e s n o t c h a n g e s i g n i n S . . ~ i s t h e L i p s c h it . z c o n s t a n t i n e q u a t i o n 3i n t h e r e g i o n o f ~ . S p h e r e s ( a ) a n d ( b ) a r e g u a r a n t e e d n o t ~ o i n t e r s e c t t h e s u r f a c esi.o, Lips~t~ ~r i r~ = f( x~ )/ L~ < 1~ and ~b = f(zb) /~Cb < R. H . . . . . ."P c > R a n d ~ c m a y i n t e r s e c t t h e s u r f a c e .

    D e f i n i t i o n o f g ( t)W e n o w d e f i n e a n e w f u n c t i o n

    d Fg(O = - -d t= ~ vf (x)1 ~ , + /3 (2)N o t e t h a t g ( t ) i s t h e d i r e c t i o n a l d e r i v a t i v e o f f ( x ) a l o n g t h e r a y

    d i r e c t i o n o ~ ( ' g ' r e l a t i n g t o " g r a d i e n t " ) .D e f i n i t i o n O f L i p s c h i t z C o n s t a n tA ( p o s i t i v e ) r e a l n u m b e r i s c M l e d a Lipsch i t z cons tan t o n a f u n c t i o nf ( x ) i n a r e g i o n T~ , i f g i v e n a n y t w o p o i n t s x l a n d x 2 i n ~ , t h e f o l l o w i n gc o n d i t i o n h o l d s :

    I l f ( x t ) - f ( x 2 ) l l < I l x x - x ~ l l (3 )wh e re I1.11 i s a ve c t o r n o rm .I f t h e c o n s t a n t e x i s t s , a l i p sch i t z cond i t i on i s s a i d t o e x i s t o n t h e

    f u n c t i o n f ( x ) i n t h e r e g io n ~ . ( S e e F i g u r e 4 . )W e a l s o n o t e t h a t o t h e r s c h e m e s b a s e d o n L i p s c h i t z C o n s t a n t sh a v e b e e n u s e d f o r a c c u r a t e s a m p l i n g o f p a r a m e t r i c s u r f a c e s b y[VON HERZEN 87 ] , [VON HERZEN 88 ] and [VON HERZEN 89 ] .

    2 . 2 L G - s u r f a c e D e s c r i p t io nW e d e f i n e a n L G s u r f a c e t o b e a n i m p l i c i t f u n c t i o n f ( x ~ y , z ) w h i c h h a sb o u n d s o n t h e n e t r a t e o f c h a n g e o f th e f u n c t i o n a n d i t s d i r e c t i o n a ld e r i v a t i v e ( t h a t w e c al l L a n d G ) . M a t h e m a t i c a l l y , t h e s e b o u n d s a r et h e Lipsch i t z cons tan t s a s d e f i n ed a b o v e ; L i p s c h i t z c o n s t a n t s h a v e o t h e ru s e f u l a p p l i c a t i o n s in a p p l i e d m a t h e m a t i c s a n d n u m e r i c a l a n a l y s i s (s e e[ G E A R 7 I ] a n d [ L I N A N D S E G E L T 4 ] ).D e f i n i t i o n o f L G - s u r f a c e sL e t L b e t h e L i p s c h i t z c o n s t a n t f o r t h e f u n c t i o n f ( x ) i n a th r e e -d i m e n s i o n a l r e g i o n ~ a n d G b e t h e L i p s c h i t z c o n s t a n t f o r t h e c o r-r e s p o n d i n g f u n c t i o n g ( t ) i n a cl o s e d i n t e r v a l T = [ Q , t 2 ] , i v .,

    I l f ( xo ) - f (xb)l l _< L [ I x a - x ~, ][ ( 4 )IIg(to) g ( t b ) l l _ < c l i t . - t d l . ( 5 )f o r a n y ~ a , ~ b E 7 a n d a n y t a , t b E T .A n i m p l i c i t s u r f a c e S r e p r e s e n t e d b y a n i m p l i c i t f u n c t i o n f ( x ) = 0

    i s a n L G - i m p l i e l t s u r f a c e , i f t h e L i p s ch i t z c o n s t a n t s L an d G a sd e f i n ed a b o v e e x i s t a n d a r e c o m p u t a b l e .2 . 3 H o w T o C o m p u t e L ' s a n d G ' sI t c a n b e s ee n f r o m e q u a t i o n ( 3 ) t h a t a L i p s c h i t z c o n s t a n t i s a m e a s u r eo f t h e m a x i m u m r a t e o f c h a n g e o f a f u n c t i o n i n a r e g i o n o v e r w h i c ht h e f u n c t io n i s d e fi n e d . T h i s c a n b e s e e n b y d i v i d i n g e q u a t i o n 3 b yI l x t - x211, t a k i n g t h e l i m i t ~ X l ~ x 2 a n d u s i n g t h e d e f i n i ti o n ofd e r i v a t i v e .

    F i g u re 5 : T he s t r a dd l i ng boxe s o f a su r fa c e a s found by pa r t A , Spa ce Prun i ngs t e p o f t h e a lg o r i t h m . T h e f i g u r e s h o w s a t w o - d i m e n s i o n a l s l i c e t h r o u g h t h e t h r e ed i m e n s i o n a l c o l l e c t i o n o f b o x e s.

    " 1 I "

    F i g u r e 6 : W h a t i s s t r a d d l i n g ? T h e b o x v e r t i c e s s t r a d d l e t h e s u r f a c e i f a t l e a s to n e o f t h e v e r t i c e s o f t h e b o x i s i n s i d e a n d a t l e a s t o n e o f t h e v e r t i c e s i s o u t s i d e t h es u r f a c e ( c a s e ( a ) ) . C a s e s ( b ) , ( c ) a n d ( d ) a r e a l l n o n - s t r a d d l i n g .

    C o m p u t i n g L :G i v e n a t h r e e d i m e n s i o n a l r e c t a n g u l a r r e g i o n T ~ , w e s h a l l c a l l t h e L i p s -e h i t z c o n s t a n t f o r f ( x ) f o r 7~ t o b e L . L i s e q u a l t o o r g r e a t e r t h a n t h em a x i m u m r a t e o f c h a n g e o f f ( x ) i n 7 ~. T h a t i s

    > l v s ( x IC o m p u t i n g G :G i v e n a o n e d i m e n s i o n a l c l o s e d i n t e r v a l T = [q , t2 ] , w e c a l l t h e L i p s -c h i t z c o n s t a n t f o r g( t ) i n 7- t o b e G . T i s e q u a l t o o r g r e a t e r t h a n t h em a x i m u m r a t e o f c h a n g e o f 9 ( t ) i n 7- . T h a t i s

    m a x d 9 IG > 7- ~ (7)T h e a l g o r i t h m w o r k s f a s t e r f o r s m a l l e r v a l u e s o f L a n d G .

    3 R e n d e r i n g L G - s u r f a c e sW e r e n d e r L G - s u r f a c e s b y c a s t i n g r a y s a n d o b t a i n i n g i n t e r s e c t i o n s o ft h e r a y w i t h t h e s u r f a c e u s i n g tw o a l g o r i t h m s , A a n d B .A l g o r i t h m A ) S p a c e P r u n i n gA l g o r i t h m A i s a n e f f ic i e n c y m e a s u r e . E v e n i f a l g o r i t h m A i s n o t u s e d ,t h e r a y in t e r s e c t i o n m e t h o d i n a l g o r i t h m B i s g u a r a n t e e d t o w o r k .

    T h i s a l g o r i t h m p r u n e s a w a y l a rg e p a r t s o f s p a c e t h a t a r e g u a r a n t e e dn o t t o c o n t a i n a n y p a r t o f th e L G - s u r f a c e a s i n F i g u r e 5. W e o b t a i na v o l u m e " 12, c o m p o s e d o f n o n - o v e r l a p p i n g r e c t a n g u l a r b o x e s , t h a t c o n -t a i n s t h e w h o l e s u r fa c e . T h e v e r t i c e s o f e a c h o f t h e b o x e s i n V s t r a d d l et h e s u r f a c e ( f i g ur e 6 ) . T h i s i n i t i a l p r u n i n g r e d u c e s t h e s p a c e i n w h i c hw e h a v e t o s e a r c h f o r i n t e r s e c t i o n s o f r a y s w i t h t h e s u r f a c e .

    2 9 9

  • 8/8/2019 Guaranteed Ray Intersections With Implicit Surfaces

    4/10

    S I G G R A P HAlgorithm B) Ray" IntersectionIn algorithm B, the volume Y in space generated in the algorithm Ais used to intersect a ray with the surface. The rectangular boxescomposing Y are intersected with a ray in order of appearance alongthe ray. In any box, if one or more intersection exists, the neares tintersection is determined and we are done with this ray. The al gorithmguarantees that if an intersection in the box exists, the intersection isfound. Further , if more than one intersection exists, the nearest one iscomput ed (near est to th e origin t = 0 of the r ay vtt + 13).We now discuss each algorithm in more detail.3 . 1 P a r t A : P ru n in g A w a y E m p ty R e g io n s O f S p a c eThe vertices of a rect angular box are said to straddle an implicit surfaceif at least one of the vertices lie inside the sur face and at least one of thevertices lie outside. In Figure 6, part (a) shows a straddling box. We donot conside r'the box vertices in part (b) to be straddli ng even thoughthe box itself contai ns a par t of the siarface. Boxes (c) and (d) areobviously non-straddling. The sign of f(x), the inside-outside functionfor the surface tells if the point x is inside or outside t he surface.

    Algorithm A (Space Pruning) of the algorithm is shown in pseudocode in Figure 7 and in pictures in Figure 8. In this algorithm, we startwith a bounding box that surrounds the surface of interest (Figure 8,step 1). This bounding box is subdivided (Figure 8, step 2) to somelevel n and sub-boxes guaranteed not to contain any portions of thesurface are thrown away ((Figure 8, step 6 Box Bi). Only boxes thatstr addle t he surface are kept (Figure 8, step 4 Box B4). By keeping theboxes that only straddle the surface, each box is guaranteed to containa par t of the surface and we get a collection of boxes that lie close tothe surface.Given a sub-box B, how do we decide if it is to be accepted and no tpruned away?

    If B straddles the surface, it certainly contains a part of the surfaceand it is kept (Figure S, step 4 box .B4).tf B does not straddle the surface, it still might contain a portionof the surfac e (Figure 8. step .4 box B3). The L Lipschitz co nstan t tellsus if B does not contain any part of the surface: Let xs be the centerof B, and d be half the length of the principal diagonal of B. Sincethe maximum rate of change with respect to distance of f(x) is L andthe maximum distance of any point in B from x0 is d, the maximumchange in the value of f(x) in B from .f(x0) is Ld. Hence if

    )f(xo)[ > Ld (8)then f( x) is guaranteed to stay the same sign that it has at x 0 andnever assume a value of zero in B and hence B can be thrown away

    (fig 7, steps 5 and 6, box B1).If B does not satisfy condition in equation (8), it is subdivided intoeight sub-boxes and each of the sub-boxes is checked again to checkthat it satisfies either the straddling condition or equation (8). InFigure 8, step 7, Ba is subdivided and upon subdivision we find somesub-boxes that str addle the surface. For box Bz, none of the sub-boxesstraddle the surface and the subdivision is stopped after condition (8)is satisfied.Figure 5 shows a surface and its straddl ing box forming P as foundby our algorithm.

    This initial subdivision in algorithm A is not an essential require-ment for the algorithm. It is guaranteed to work even if the initialsubdivi sion level n = 0, i.e., no initial subdivi sion of the bou ndin g boxis performed. The level of initial subdi vision does effect the perfor-mance of the ray-intersection.Subdivision TerminationIs it guaranteed that the subdivision algorithm terminates?

    If any of the vertices of a box lies exactly on t he surface, cond ition(8) will never be satisfied. Even if we compu te the small est possibleL, we can meet the condition If(xo)[ = Ld rather than the inequality.Hence, we have to stop subdivis ion at some level if it does not stop inthe natu ral cour se of the algo rithm . Since we compute the intersec-tions numerically, sto ppin g the intersection whe n the box size becomessmaller than the tolerance of the numerical method is a natural con-dition to use. Experimentally, in all the pictur es we have computed

    ' 89 , Boston, 31 Ju ly -4 Aug ust , 1989

    S t e p I . C o m p u t e a b o u n d i n g b o x B f o r s u r f a c e~ . S u b d i v i d e B t o a l e v e l n3 . F o r e a c h s u b - b o x b4 A c c e p t b if b s t r a d d l e s s u r f a c e

    e l s e5 . C o m p u t e L f o r b6. If i f ( x 0 ) [ > Ld7. R e j e c t be l s e8 . S u b d i v i d e b i n t o e i g h t s u b - b o x e s9 . F o r e a c h s u b - b o x of b,I 0. R e p e a t t h e a b o v e

    Figure 7: Algorithm A prunes away parts off space guaranteed no t to contain anyp o r t i o n o f t h e surface. The algorithm is shown in pictures in Figure 8. The stepsin this figure and i n Figure 8 correspond.

    Box B

    Step 1

    Box B' I t ~

    AN/ AS, ~ / .~ . / / > ./ / / / " / / / " / / )~6..~_..z.z..~_/ / . ' / / j

    Step 2

    [~]B l - -Bs [Z]B1 ~-1B3

    Step 3 Step 4

    Step 5 Step 6

    Step 7 Step 8Figure 8: Algorithm A prunes away parts of space gurarazlteed not to containany portion of an LG-surfac. Cross hatched b o x e s a r e added to V, lightly shadedbox~ are thrown away. The pseudocode for the algoritlu'n is given in Figure 7. Thesteps in this figure and in Figure 7 correspond.

    so far, such a terminating condition has never taken place. The strad-dling condition occurred before the box reached the numerical precisionlimit.

    300

  • 8/8/2019 Guaranteed Ray Intersections With Implicit Surfaces

    5/10

    * Com puter Graphics, Volum e 23, Num ber 3, July 198

    3 . 2 P a r t B : I n t e r s e c t i o n o f a R a y w i t h a n L G -s u r f a c e

    This part of the algor ithm is designed to guarant ee finding the inter-s e c t i o n o f a ra y w i t h a n L G - s u r f a c e n e a r e s t t o t h e o r i g i n o f t h e r a y.

    I n a l g o r i t h m A , w e h a v e f o r m e d a s e t o f b o x e s t h a t c o m p r i s e av o l u m e ~ a n d t h e v e r t i c e s o f e a c h o f th e b o x e s i n 1 ; s t r a d d l e t h e s u r f a c e .T h e v o l u m e V c o m p l e t e l y e n c l o s e s t h e s u r f a c e o f i n t e r e s t . H e n c e a l li n t e r s e c t i o n s l i e i n V . V is c o m p o s e d o f n o n - o v e r l a p p i n g b o x e s . T h er a y i n t e r s e c t i o n p r o b l e m i s n o w b r o k e n d o w n i n t o a s i m p l e r p r o b l e m :a ) F i n d t h e b o x i n V n e a r e s t t o t h e o r i g i n o f t h e r a y .b ) C o m p u t e a n y r a y i n t e r s e c t i o n s i n t h i s b o x ; i f n o n e e x i s t , c o n s i d e r

    t h e n e x t b o x i n o r d e r .T h e p r o b l e m o f f i n d i n g t h e n e a r e s t b o x i s d e s c r i b e d l a t e r i n s ec -

    t i o n 4 . H e r e w e c o n s i d e r t h e f o l l o w i n g p r o b l e m .P r o b l e m S t a t e m e n tI n t e r s e c t i o n o f a r a y w i t h t h e s u r f a c e i n a s t r a d d l i n g b o x : G i v e n a r a ya n d a b o x B w h o s e v e r t i c e s s t r a d d l e t h e s u r f a c e , e i t h e r e n s u r e t h a tt h e r e i s n o i n t e r s e c t i o n o f t h e r a y w i t h t h e s u r f a c e i n B o r f i n d t h en e a r e s t i n t e r s e c t i o n .P r e l i m i n a r i e sW e w i s h t o c o m p u t e i n t e r s e c t i on s a l o n g th e r a y c d + ~ . t t e n e e , w ea r e i n t e r e s t e d i n t h e b e h a v i o r o f f ( x ) a l o n g t h e ra y . A s d e f i n e d i ne q u a t i o n 1 , F ( t ) r e p r e s e n ts t h e b e h a v i o r o f f ( x ) a l o n g t h e r a y a n d

    d Fg ( t ) = - ~ - .A n i n t e r s e c t i o n i s g i v e n b y v a l u e s o f t s u c h t h a t

    F ( t ) = 0 .T h e r e l i a b i l i t y o f o u r r a y i n t e r s e c t i o n a l g o r i t h m d e p e n d s o n o u r a b i l -

    i t y t o d e t e r m i n e i f g ( t ) b e c o m e s z e r o in a n i n t e r v a l . T h e f o l l o w i n g t w oc a s e s d e s c r i b e t w o i m p o r t a n t s i t u a t i o n s , o n e in w h i c h t h e r e i s e x a c t l yo n e r a y - s u r f a c e i n t e r s e c t i o n i n a n i n t e r v a l , a n d s e c o n d i n w h i c h t h e r ei s n o n e .1 . I f F ( t ~ ) a n d F ( t ~ ) a r e o f o p p o s i t e s i g n s a t t w o p o i n t s t~ a n d t ~

    a l o n g t h e r a y , t l < t ~ , t h e r e i s a t l e a s t o n e i n t e r s e c t i o n b e t w e e nt t a n d t 2 . F u r t h e r , i f g ( Q = d F / d ~ d o e s n o t b e c o m e z e r o b e t w e e nt ~ a n d t ~ , t h e r e i s e x a c t l y o n e i n t e r s e c t i o n b e t w e e n t h e r a y a n dt h e s u r f a c e i n t h e i n t e r v a l f r o m t l t o t ~ ( s e e b e l o w z ) .

    2 . I f F ( Q ) a n d F ( t z ) h a v e t h e s a m e s i g n a t Q a n d t ~ a l o n g t h e r a y ,t ~ < t 2 a n d g( t ) = dr ~dr d o e s n o t b e c o m e z e r o b e t w e e n t~ a n dt ~ , t h e r e i s n o i n t e r s e c t i o n b e t w e e n t h e r a y a n d t h e s u r f a c e i n t h ei n t e r v a l f r o m Q t o t 2 .

    G i v e n t h a t G i s th e L i p s c h i t z c o n s t a n t f o r g ( t ) i n a n i n t e r v a l [ Q , t ~ ]a n d

    t m = ( t t + t z ) / 2 d = ( t z - - t l ) / 2 ,

    I g ( t ~ ) l > G d (9 )i n [ /~ , t z] , t h e n g ( t ) n e v e r s b e c o m e s z e r o i n t h e i n t e r v a l . ( G i s e q u a l o rm o r e t h a n t h e m a x i m u m r a t e o f c ha n g e o f g ( t ) a n d d i s t h e m a x i m u md i s t a n c e a l o n g t h e r a y f r o m t r n . ) Gd i s t h e m a x i m u m p o s s i bl e c h a n gein g(t) from g(tm).

    Ill a continuous function f(t) a t t ~ n s t w o c o n s ec u t i ve zero values at tl an d tz,b y the me an value theorem, there exists at lea~st ne point be twe en tl and t~ whe red]/ dt = O.

    I . I n t e r s e c t r a y o ct + ~ 9 w i t h b o x B i n t~ a n d t z , t2 > Q2 . C o m p u t e G w i t h r e s p e c $ t o m i d p o i n t tm = t2 + Q /2

    L e t h a l f d i s t a n c e d = ( t 2 - t i n ) ~ 23 . i ~ I g ( t ~ ) ] > C d4 . i ~ F ( ~ ) ~ a f ( t z ) a r e o f o p y o s i t e s i g n eS . t h e r e i s e x a c t l y o n e i n t e r s e c t i o n :

    c o m p u t e i n t e r s e c t i o n v i a n e w t o ni t e r a t i o n o r r e g u l a f a l s i

    e l s e6 . t h e r e i s n o i n t e r s e c t i o n i n t h e

    i n t e r v a l [ ~ i, ~ ]e l s e

    7. llg(~m)ll Cd8 . s t t b d i v i d e i n t o t w o s u b i n t e r v a l s [ tl ,t ,n ~

    an d [ t m , t z ]9 . a n d r e p e a t s t e p s 2 t o 8 o n e a c h s u b i n t e r v a l

    u n t i l t m - - t l < e o r t 2 - - t m m a xwhere I I 'l l r e p ~ e s e . t s a vector uorm.

    C o m p u t i n g G i n a n i n te r v a l [ t l , t ~]D e f in e dg ( t ) = ~ f f ( ~ + ~) .fo r a r a y x = c ~t + f t .T h e n G f o r a n i n t e r v a / 7 " a l o n g t h e r a y i s c o m p u t e d a s

    > m a x d g ( t )G - t 6 T ~ T h e d e t a i l e d d e r i v a t i o n a n d e x p r e s s io n s f o r L a n d G m a y b e f o u n d i n[KALRA and BARR 89].

    [ V O N H E R Z E N 8 9 ] B r i a n V o n H e r z e n , A l a n H , B u r r , H a r o l d R . Z a t z , Col-l i si o n D e t e r m i n a t i o n f o r P a r a m e t r i c S u r f a c e s , C a l t e c h C S T e c h n i c a lR e p o r t .

    [ W Y V I L L 8 6 ] S p a c e D i v i s io n f o r K a y T r a c i n g i n C S G , G e o ~ W y v i l l ,To s i ya su L . K u n i i a n d Ya su t o S h i ra i , I E E E C o m p u t e r G r a p h i c s a ndA p p l i c a t i o n s , A p r i l 7 8 6 .

    ~ W Y V IL L 8 7 1 1 ] ] S ol i d T e x t u r i n g o f S o f t O b j e c t s , Geo f f W g vi l l , Br i a nW yvi l l , C ra i g Ph ee t ers , I E E E C o m p u t e r G r a p h i c s a n d A p p l i c a ti o n s ,D e c e m b e r ' 8 7 .

    [ W Y V I L L 8 7 [ 2 ] ] A n i m a t i n g S o f t O b j e c t s , Geo f f W yvi l l , C ra i g Ph ee t ers ,B r i a n W y v i l l , T h e V i s u a l C o m p u t e r , ( 1 9 8 6 ) 2 .

    R e f e r e n c e s[BARR 8 1 ] A l a n H . B u r r , S u p erq u a d r i cs a n d An g l e- Preserv i n g Tra n s f o rma -t i o n s , I E E E C o m p u t e r G r a p h i c s a n d A p p l i c a t i o n s , J a n ' 8 1 .[ B A R R 8 4 ] A l a n I -I . B a n , Gl o ba l An d Lo ca l Def o rma t i o n s o f S o l i d Pr i m i -

    t ives, C o m p u t e r G r a p h i c s , J u l y ' 8 4 .[ B L I N N 8 2 ] J a m e s F . B l i n n , A g en era l i za t i o n o f A l g eb ra i c S u r f a ce Dra w i n g ,

    A C M T r a n s a c t i o n s o n G r a p h i c s , V ol . 1 , N o . 3 , J u l y 1982, p p 2 3 5 - 2 5 6 .

    [BLOOMENTHAL 85] J u l e s B l o m e n t h a l , M o d el i n g t h e M i g h t y M a p l e ,C o m p u t e r G r a p h i c s , V o l 1 9 , N o . 3 , J u l y 1 9 8 5 .[ B L O O M E N T H A L 8 7 ] J u l es B l o m e n t h a l, P o l y g o n i z a ti o n o f I m p l i c i t S u r -f a ces , C o u r s e N o t e s on " T h e M o d e l i n g o f N a t u r a l P h e n o m e n a " , S i g -g r a p h 1 9 8 7 .[ C O L L I N S A N D A K R I T A S 7 6 ] C o l l i n s , G . E . a n d A k r i t a s , A . G . , P o l y n o -mi a l rea l roo t i so l a t i o n u s i n g D esca r t es ' ru l e o f f s i g n s , P r o c . 1 9 7 6 A C M

    S y m p o s i u m o n S y m b o l i c a n d A l g e b r a i c C o m p u t a t i o n .[ G E A R 7 1 ] G e a r , C . W i l l i a m , N u m er i ca l I n i t i a l Va lu e Pro b l ems i n Ord i n a ryDi f f eren t i a l Eq u a t i o n s , P r e n t i c e - H a l l , E n g l e w o o d C l i f f s , N J , 1 9 7 1 .[ G L A S S N E R 8 4 ] S p a c e S u b d i v is i o n f o r F a s t R a y T r a c i n g An d rew S . G l a ss-

    n er , 1 S E E C o m p u t e r G r a p h i c s a n d A p p l i c a t i o n s , O c t o b e r ' 8 4 .[ H A N R AH A N 8 3 ] P a t H a n r a h a n , Ra y Tra c i n g Al g eb ra i c S u r f a ces , C o m -

    p u t e r G r a p h i c s . J u l y ' 8 3 .[KALRA and BARR 8 9 ] D e v e n d r a K a l r a a n d A l a n H . B u r r , Gu a ra n t eed I n -t er sec t i o n s w i t h l mp l i c i t su r f a ces , C a l t e e h C o m p u t e r S c i en c e T e ch R e -p o r t .[ LI N A N D S E G E L 7 4 ] M a t h e m a t i c s A p p l i e d T o D e t e r m i n i s ti c P r o b l e m s I n

    T h e N a t u r a l S c i e n c es , C . C . L i n a n d L . A . S eg e l , M a c m i l l a n P u b l i s h i n gC o . , I n c . , N e w Y o r k .

    [ L O R E N S E N A N D C L I N E 8 7 ] M a r c h i n g C u b e s : A h i g h r e s o l u t io n 3 d s u r -f a c e c o n s t r u c t i o n a l g o r i t h m , W i l l i a m E . L o r e n s e n a n d H a r v e y E . C l in e ,C o m p u t e r G r a p h i c s , J u l y 1 9 8 7 .

    [ M I D D L E D I - I -C H e t a l 8 5 ] A l a n E . M i d d l e d i t c h a n d K e n n e t h H . S e a r s ,B l e n d S u r f a c e s f o r S e t t h e o r e ti c v o l u m e M o d e l i n g S y s t e m s , C o m p u t e rG r a p h i c s , V o l. 1 9 , N o . 3 , J u l y 1 9 8 5 , p p . 1 6 1 - 1 7 0 .

    [ PL A T- [- a n d B A R R ] J o h n P l a t t a n d A l a n B u r r , C o n s t r a i n t M e t h o d s f o rFl ex i b l e M o d el s , C o m p u t e r G r a p h i c s , A u g 8 8 .[ S M P ] S t e v e n W o l f r a m e t a l, , S M P : A s y m b o l m a n i p u l a t io n P a c k a g e , C a l i-f o r n i a I n s t i t u t e o f T e c h n o l o g y , 1 9 8 1 .[TERZOPOULO~5 e t al ] D e m e t r i T er z o p o u lo s , J o h n P l a t t , A I B u r r , K u r tF l e i s c h e r , El a s t i ca l l y Def o rm a b l e M o d el s, C o m p u t e r G r a p h i c s , J u l y 6 7 .[ U S P E N S K Y 4 8 ] U s p e n s k y , J . V . , T h e o r y o f E q u a t i o n s , M c G r a w - H i l l , 1 9 4 8 .[ V O N H E R Z E N 8 4 ] B r i a n P . V o n H e r z e n , S a m p l i n g D e f o r m e d , I n t e r s e c t in g

    Surfaces wi th Quadtrees, M a s t e r ' s T h e s i s , C a l t e c h , 1984.[ V O N H E R Z E N 8 8 ] B r i a n V o n H e r z e n , A p p l i c a t io n s o f S u r f a c e N e t w o r k s t oS a mp l i n g Pro b l ems i n C o mp u t er Gra p h i cs , C a l t e c h P h D T h e s i s.

    3 0 6