Home >Documents >2.4. P RIMITIVE T ESTS - C LOSEST POINT Closest point forms of intersection detection.

2.4. P RIMITIVE T ESTS - C LOSEST POINT Closest point forms of intersection detection.

Date post:31-Mar-2015
View:217 times
Download:0 times
Share this document with a friend
  • Slide 1

2.4. P RIMITIVE T ESTS - C LOSEST POINT Closest point forms of intersection detection Slide 2 Finding the closest point between two objects provides a number of benefits. If positive, the objects are separated, if negative, the objects are interpenetrating (and knowledge of the closest point can be used to provide contact information). Two different approaches can be used to find the minimum point: Keeping a record of the closest points between two objects can often be incrementally maintained at a low cost (object coherency), providing fast collision testing. Formulate the test as a minimisation problem and solve it using calculus. Use the geometric properties of the objects to geometrically derive the closest point (considered here). Slide 3 Consult the recommended course text for details of the following tests: Closest Point on Plane to Point Closest Point on Line Segment to Point Closest Point on AABB to Point Closest Point on OBB to Point Closest Point on Triangle to Point Closest Point on Convex Polyhedron to Point Closest Points of Two Lines Closest Points of Two Line Segments Closest Points of a Line Segment and a Triangle Closest Points of Two Triangles Two illustrative forms of closest point test are explored next. Slide 4 Closest point between an OBB and a Point Slide 5 Consider an OBB with centre point C, orthogonal unit vectors (u 0, u 1, u 2 ) and half-width distances (e 0, e 1, e 2 ) and a point P. Slide 6 The closest point on/in the OBB to P can be determined by: 1. Transforming the point P into the local coordinate system of the OBB, 2. Computing the point on the OBB (now effectively an AABB) closest to the transformed point. 3. Transforming the resulting point back into world coordinates Slide 7 1. Transform P into the OBB coordinate system: The transformed point Q is found from: i.e. the distance vector of the point from the centre of the OBB as projected onto each defined OBB axis Q x = (P C) u o Q y = (P C) u 1 Q z = (P C) u 2 C P P-C (P-C) u o u0u0 Slide 8 2. Computing OBB point closest to the transformed point. If the transformed point u 0, u 1, u 2 distances are respectively longer than e 0, e 1, e 2 then clamp to half- width extents 3. Transform the point back into world coordinates Q i = (PC) u i if(Q i >e i ) Q i =e i if(Q iSlide 9 Expressed as code: ClosestPointToOBB(Point point, OBB box, out Point closestPt) { Vector distance = point- box.centre; closestPt = box.centre; for (int i = 0; i < 3; i++) { float length = Dot(distance, box.axis[i]); if (length > box.extent[i]) length = box.extent[i]; if (length < -box.extent[i]) length = -box.extent[i]; closestPt += length * box.axis[i]; } } Initially set closest point as box centre Iterate over box axis Determine projection along axis Clamp if needed Build world location component by moving determine distance along OBB axis Slide 10 The separation (actual or squared) can then be determined simply as: float distance = (closestPt point).length() Somewhat obviously, if all components of the closest OBB point (expressed in OBB space) are less than the half-width extents, then the point is within the OBB. Slide 11 Closest point between a Triangle and a Point Slide 12 Given a triangle defined by points ABC and a point P, assume Q defines the point of ABC closest to P. An efficient means of computing Q is: 1. Determine which triangle Voronoi region P is within (i.e. find which feature P is closest to). 2. Orthogonally project P onto the determined closest feature. A B C A Voronoi region of vertex A Voronoi region of edge CB Slide 13 Intersection with the Voronoi region for vertex A, B and C can be determined as the intersection of the negative half-space of the two planes through that point, e.g. for A each plane passes through A, one with a normal (B- A) and the other with normal (C- A). A A Voronoi region of vertex A C B Slide 14 The Voronoi region of each triangle edge can be efficiently computed by determining the triangle barycentric coordinates of P. Assuming n is the normal of triangle ABC and R is the projection of P onto the triangles plane, i.e. R = P tn some for t, the barycentric coordinates of R (R = uA + vB + wC) are given by: B C A Voronoi region of edge CB n = (B-A)(C-A) rab = n ((A-P)(B-P)) rbc = n ((B-P)(C-P)) rca = n ((C-P)(A-P)) abc = rab + rbc + rca u = rbc/abc, v = rca/abc, w = rab/abc Aside: the barycentric coordinates of R are given as the ratios of the signed areas of triangles RAB, RBC, and RCA to the signed area of ABC Slide 15 To determine if P is within a triangle edge Voronoi region the following conditions must hold: Aside: It is not sufficient just to test if P is outside AB, in that for a triangle with an obtuse angle at A, P could be outside AB and actually be located in the Voronoi region of edge CA (see figure). B C A B (X-A) (B-A) > 0 (X-B) (A-B) > 0 1. Calculated area of the barycentric region must be = 0.0f) return b + unom / (unom + udenom) * bc; float vb = Dot(n, Cross(c - p, a - p)); if (vb = 0.0f && tdenom >= 0.0f) return a + tnom / (tnom + tdenom) * ac; float u = va / (va + vb + vc); float v = vb / (va + vb + vc); float w = 1.0f - u - v; // = vc / (va + vb + vc) return u * a + v * b + w * c; } Determine if P is outside (or on) edge AB by finding the area formed by vectors PA, PB and the triangle normal. A scalar triple product is used. If P is outside of AB (signed area

Popular Tags:

Click here to load reader

Reader Image
Embed Size (px)