Ry surfce intersections Some primitives Finite primitives: polygons spheres, cylinders, cones prts of generl qudrics Infinite primitives: plnes infinite cylinders nd cones generl qudrics A finite primitive is often n intersection of n infinite with n re of spce 1
Intersecting rys with objects Generl pproch: Use whenever possible the implicit eqution F(q) = 0 of the object or object prts. Use prmetric eqution of the line of the ry, q = p+vt. Solve the eqution F(p+vt) = 0 to find possible vlues of t. Find the miniml nonnegtive vlue of t to get the intersection point (checking tht t is nonegtive is importnt: we wnt intersections with the ry strting from p, not with the whole line! Polygon-ry intersections Two steps: intersect with the plne of the polygon check if the intersection point is inside the polygon We know how to compute intersections with the plne (see prev. lecture). Let q=[q x,q y,q z ] be the intersection point. q
Polygon-ry intersections Possible to do the whole clcultion using 3d points, but it is more efficient to use d points. Converting to the coordintes in the plne is computtionlly expensive. Ide: project to coordinte plne (XY, YZ, or XZ) by discrding one of the vector coordintes. We cnnot lwys discrd, sy, Z, becuse the polygon my project to n intervl, if it is in plne prllel to Z. Choose the coordinte to discrd so tht the corresponding component of the norml to the polygon is mximl. E.g. if n x > n y nd n x > n z, discrd X. D Polygon-ry intersections Now we cn ssume tht ll vertices v i nd the intersection point q re D points. v 4 v 3 q v v 1 Assume tht polygons re convex. A convex polygon is the intersection of set of hlf-plnes, bounded by the lines long the polygon edges. To be inside the polygon the point hs to be in ech hlf-plne. Recll tht the implicit line eqution cn be used to check on which side of the line point is. 3
D Polygon-ry intersections Eqution of the line through the edge connecting vertices v i nd v i+1 : y y x x x y ( v v )(x v ) + ( v v )(y v 0 i i+ 1 i i+ 1 i i ) = If the quntity on the right-hnd side is positive, then the point (x,y) is to the right of the edge, ssuming we re looking from v i to v i+1. Algorithm: if for ech edge the quntity bove is nonnegtive for x = q x, y = q y then the point q is in the polygon. Otherwise, it is not. In the formuls x nd y should be replced by x nd z if y coord. ws dropped, or by y nd z if x ws dropped. Infinite cylinder-ry intersections v p r Infinite cylinder long y of rdius r xis hs eqution x + z - r = 0. The eqution for more generl cylinder of rdius r oriented long line p + v t: (q - p - (v,q - p )v ) - r = 0 where q = (x,y,z) is point on the cylinder. 4
Infinite cylinder-ry intersections To find intersection points with ry p + vt, substitute q = p + vt nd solve: (p - p + vt - (v,p - p + vt)v ) - r = 0 reduces to with A = B= C = At where p = p- p + Bt + C = 0 ( v (v,v )v ) ( v (v,v )v, p ( p,v )v ) ( p ( p,v )v ) r Cylinder cps A finite cylinder with cps cn be constructed s the intersection of n infinite cylinder with slb between two prllel plnes, which re perpendiculr to the xis. To intersect ry with cylinder with cps: intersect with the infinite cylidner; check if the intersection is between the plnes; intersect with ech plne; determine if the intersections re inside cps; out of ll intersections choose the on with miniml t 5
Cylinder-ry intersections POV -ry like cylinder with cps : cp centers t p 1 nd p, rdius r. Infinite cylinder eqution: p = p 1, v = (p - p 1 )/ p - p 1 The finite cylinder (without cps) is described by equtions: (q - p - (v,q - p )v ) - r = 0 nd (v, q- p 1 ) > 0 nd (v, q- p ) < 0 p r The equtions for cps re: (v, q- p 1 ) = 0, (q- p 1 ) < r bottom cp (v, q- p ) = 0, (q- p ) < r top cp p 1 Cylinder-ry intersections Algorithm with equtions: Step 1: Find solutions t 1 nd t of At + Bt + C = 0 if they exist. Mrk s intersection cndidtes the one(s) tht re nonnegtive nd for which (v, q i - p 1 ) > 0 nd (v, q i - p ) < 0, where q i =p+v t i Step : Compute t 3 nd t 4, the prmeter vlues for which the ry intersects the upper nd lower plnes of the cps. If these intersections exists, mrk s intersection cndidtes those tht re nonegtive nd (q 3 - p 1 ) < r (respectively (q 4 - p ) < r ). In the set of cndidtes, pick the one with min. t. 6
Infinite cone-ry intersections v p α p Infinite cone long y with pex hlf-ngle α hs eqution x + z - y = 0. The eqution for more generl cone oriented long line p + v t, with pex t p : cos α (q - p - (v,q - p )v ) - sin α (v,q - p ) = 0 where q = (x,y,z) is point on the cone, nd v is ssumed to be of unit length. Infinite cone-ry intersections Similr to the cse of the cylinder: substitute q = p+vt into the eqution, find the coefficients A, B, C of the qudrtic eqution, solve for t. Denote p = p- p. cos α (vt + p - (v, vt + p )v ) - sin α (v, vt + p ) = 0 A = cos α B = cos C = cos α ( v (v,v )v ) sin α(v,v ) α( v (v,v )v, p ( p,v )v ) ( p ( p,v )v ) sin α( p,v ) sin α(v,v )( p,v ) 7
Cone-ry intersections A finite cone with cps cn lso be constructed s intersection of n infinite cone with slb. Intersections re computed exctly in the sme wy s for the cylinder, but insted of the qudrtic eqution for the infinite cylinder the eqution for the infinite cone is used, nd the cps my hve different rdii. Both for cones nd cylinders intersections cn be computed somewht more efficiently if we first trnsform the ry to coordinte system ligned with the cone (cylinder). This requires extr progrmming to find such trnsformtion. Cone-ry intersections POV-ry cone: cp centers (bse point nd cp point) t p 1 nd p, cp rdii r 1 nd r. Then, ssuming r 1 not equl to r (otherwise it is cylinder) in the eqution of the infinite cone p pex: p = p 1 + r 1 (p - p 1 )/(r 1 - r ); xis direction: v = (p - p 1 )/ p - p 1 ; pex hlf-ngle: tg α = (r 1 - r )/ p - p 1 r p v p 1 r 1 8
Generl qudrics A generl qudric hs eqution Ax + By + Cz + Dxy + Eyz + Fxz + Gx + Hy +Iz + J =0 Intersections with generl qudrics re computed in wy similr to cones nd cylinders: for ry p+ v t, tke x = p x + v x t, y = p y + v y t, y = p z + v z t, nd solve the eqution for t; if there re solutions, tke the smller nonnegtive one. Infinite cones nd cylinders re specil cses of generl qudrics. Generl qudrics Nondegenerte qudrics Ellipsoid x / + y /b + z /c + 1= 0 One-sheet hyperboloid x / - y /b + z /c + 1= 0 Two-sheet hyperboloid x / - y /b + z /c - 1= 0 9
Generl qudrics Nondegenerte qudrics Hyperbolic prbolid x / - z /c - y= 0 Elliptic prbolid x / + z /c - y= 0 cone x / - y /b + z /c = 0 Generl qudrics Degenerte qudrics plnes (no qudrtic terms), pirs of prllel plnes (e.g. x - 1 = 0) pirs of intersecting plnes ( e.g. x -1 = 0) elliptic cylinders (e.g. x +z -1=0) hyperbolic cylinders (e.g. x -z -1=0) prbolic cylinders (e.g. x -z = 0) Possible to get imginry surfces (tht is, with no points)! Exmple: x + 1 = 0 10