Object Intersection

Object Intersection

Object Intersection CSE 681 Object Representation Implicit forms F(x,y,z) = 0 ttitesting Explicit forms Analytic form x = F(y,z) generating Parametric form (x,y,z) = P(t) CSE 681 Ray-Object Intersection Implicit forms F(x,y,z) = 0 Ray: P(t) = (x,y,z) = source + t*direction = s + t*v Solve for t: F(P(t)) = 0 CSE 681 Ray-Sphere Intersection Implicit form for sphere at origin of radius 1 F(x, y, z) = x2 + y 2 + z 2 −1 = 0 Ray: P(t) = (x, y, z) = s + tv = (sx + tvx , sy + tvy , sz + tvz ) Solve: … 2 2 2 F(P(t)) = (sx + tvx ) + (sy + tvy ) + (sz + tvz ) −1 = 0 2 2 2 2 2 2 2 = sx + sy + sz + 2t(sxvx + syvy + szvz ) + t (vx + vy + vz ) −1 = 0 Use quadratic equation… CSE 681 Ray-Sphere Intersection At2 + Bt + C = 0 A = |v|2 B=2sB = 2s·v C = |s|2 -1 − B ± B2 − 4AC t = 2A B2-4AC < 0 => no intersection = 0 => just grazes > 0 = > two hits CSE 681 Axis-Aligned Cuboid (rectangular solid, rectangular parallelpiped) RtiRay equation P(t) = s + tv Planar equations Solve for intersections with planes Y = y2 tx1 = (x1 - sx)/vx Z = z2 t = (x2 - s )/v X = x1 X = x2 x2 x x Z = z1 ty1 = (y1 - sx)/vx Y = y1 … CSE 681 For each iiintersection, note Rectangle whether entering or leavinggq square side of plane: HOW? Ray 2 Ray is inside after last entering and Ray 1 before first exiting CSE 681 Ray-Plane for arbitraryyp plane Generalize from axis-aligned planes to any plane: V V2 ax + by + cz + d = 0 1 n ·P = -d d -n V4 V3 CSE 681 Normal Vector Given ordered sequence of points defining a polygon how do you find a normal vector for the plane? Note: 2 normal vectors to a plane, colinear and one is the negation of the other Ordered: e.g., clockwise when viewed from the front of the face Riggpht hand v. left hand space CSE 681 Normal Vector V1 V2 V3 n = (V1 -V2) x (V3 -V2) V5 V4 V2 V1 V1 V3 V2 V3 V5 V 4 V5 CSE 681 V4 Normal Vector V1 V2 mx = Σ(yi -ynext(i)) (zi -znext(i)) V3 my = Σ(zi -znext(i))() (xi -xnext(i)) mz = Σ(xi -xnext(i)) (yi -ynext(i)) V5 V4 V2 V1 V1 V3 V2 V3 V5 V 4 V5 CSE 681 V4 Ray-Plane Ax + by + cz + d = 0 n ·P = -d P = s + t*v n· (s+t*v) = -d n·s + t*(n·v) = -d t = -(d + n·s)/(n·v) CSE 681 Ray-Polyhedron Polyhedron - volume bounded by flat faces Each face is defined by a ring of edges Each edge is shared by 2 and only 2 faces The pol yhedron can be con ve x or conca ve Faces can be convex or concave CSE 681 Polyhedron Classification Polyhedron Convex Polyhedron Concave Polyhedron Only One or more Only One or more Convex Concave Convex Concave Polygons Polygons Polygons Polygons titriangul ltdated quads midixed titriangul ltdated quads midixed CSE 681 Solid Modeling Modeling of three-dimensional solids Physically realizable objects No infinitelyy, thin sheets, no lines Interior of object should ‘hold water’ - Define a closed volume http://www.gvu.gatech.edu/~jarek/papers/SolidModelingWebster.pdf CSE 681 Polygonal Solid Models Vertices of a face have a consistent ordering (e.g. clockwise) when viewed from the outside side of the face Each edge of a face is shared by one and only one other face Each edge appears oriented one way in one face and the other way in the other face EULER’S FORMULA F – E + V = 2 F – E + V = 2 – 2P CSE 681 Convex Polyhedron volume bounded by finite number of infinite planes Computing intersections is similar to cube but using ray-plane intersection and arbitrary number of planes n· P= -d Use n· v to determine P(t)=s+t*vP(t) = s + t*v Entering/exiting status n· (s+t*)*v) = -d n·s + t*(n·v) = -d t = -(d + n·s)/(n·v) CSE 681 Convex Polyhedron Intersection going from outside to inside Intersection going from inside to outside Record maximum entering intersection - enterMax Record minimum exiting intersection - exitMin If (enterMax < exitMin) polyhedron is intersected CSE 681 Concave Polyhedron Find closest face (if any) intersected by ray Need ray -face ( ray -polygo n) inte rsect io n test CSE 681 Ray-Convex Polygon E Test to see if point is on n ‘inside’ side of each edge n·(VxE) > 0 V VxE Dot product of normal Cross product of ordered edge vector from edge source to point of intersection CSE 681 Ray-Concave Polyhedron 1. Intersect ray with plane 2. Determine if intersection point is inside of 2D polygon A) Convex polygon B) Concave polygon CSE 681 Ray-concave polygon Project plane and point of intersection to 2D plane 2D point-inside-a-polygon test N (lbdf(can also be used for convex po lygons) A PjProject to p lane o f2f 2 B smallest coordinates of normal vector Form semi-infinite ray A’ and count ray-edge intersections B’ CSE 681 2D Point Inside a Convex Polygon p Semi-infinite ray test (py < p1y )&&(py > p2y )|| (py > p1y )&&(py < p1y ) px < p1x + ( p2x − p1x )(py − p1y ) /(p2y − p1y ) Test to see if point is on ‘inside’ side of each edge p2 p Need to know order (CW or CCW) of 2D vertices p11 (px − p1x )(p2 y − p1y )− (py − p1y )(p2x − p1x ) CSE 681 2D point inside a polygon test CSE 681 Special Cases Logically move ray up epsilon N N Y Y CSE 681 2D point inside a polygon test y if (((y < y2 ) & &(y >= y1)) || ((y < y1) & &(y >= y2 ))) CSE 681 Transformeds o ed objecobjects s e.g., Ellipse is transformed sphere Objjpect space WldWorld space Intersect rayjy with transformed object Use inverse of object transformation to transform ray Intersect transformed rayyj with untransformed object CSE 681 Transformed objects r(t) = s + tv World space ray s = [sx , sy , sz ,1] v = [vx ,vy ,vz ,0] M Object to world transform matrix R(t)T = M −1sT + M −1vT Object space ray Intersect ray with object in object space P T = MP T Transform intersection point and world object normal back to world space T −1 T T Nworld = (M ) Nobject CSE 681 Ray-Cylinder Q=sQ = s2 +t+ t2*v2 r P = s1 + t1*v1 At closest points r (P(t1) − Q(t2 ))⋅v1 = 0 (P(t1) − Q(t2 ))⋅v2 = 0 CSE 681 Ray-Cylinder (P(t1) − Q(t2 ))⋅v1 = 0 (P(t1) − Q(t2 ))⋅v2 = 0 (s1 + t1v1 − (s2 + t2v2 ))⋅v1 = 0 (s1 + t1v1 − (s2 + t2v2 ))⋅v2 = 0 CSE 681 Ray-Ellipsoid GiGeometric construct illion: all points p such that a b |p-a|||p + |p-b| = r d1 d2 Algebraic equation – axis aligned, origin centered 2 2 2 ⎛ x ⎞ ⎛ y ⎞ ⎛ z ⎞ ⎜ ⎟ + ⎜ ⎟ + ⎜ ⎟ =1 ⎝ a ⎠ ⎝ b ⎠ ⎝ c ⎠ CSE 681 Ray-Quadidric P(t) = (x, y, z) = s + tv = (sx + tvx , sy + tvy , sz + tvz ) Ax2 + By 2 + Cz 2 + Dxy + Exz + Fyz + Gx + Hy + Iz + J = 0 http://en.wikipedia.org/wiki/Quadric CSE 681.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    32 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us