1 / 74

Collision handling: detection and response

Collision handling: detection and response. CSE 3541 Matt Boggus. Collision handling overview. Point collision detection Line segment and ray collision detection Polyhedron-polyhedron collision detection Bounding volume test Vertex inside polyhedron test Concave case

Download Presentation

Collision handling: detection and response

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Collision handling:detection and response CSE 3541 Matt Boggus

  2. Collision handling overview Point collision detection Line segment and ray collision detection Polyhedron-polyhedron collision detection Bounding volume test Vertex inside polyhedron test Concave case Convex case Edge-face intersection test detection Kinematic response Penalty method response

  3. Geometric modeling primitives • Point • Line segment • Polygon

  4. Terminology – convex and concave polygons

  5. Convex and concave – line test

  6. Convex and concave – interior angles

  7. Polygon triangulationsplit into a set of convex polygons

  8. Types of equations • Explicit y = f(x) • Ex: y = mx + b • Implicitf(x,y) = 0 • Ex: x2 + y2 – 1 = 0 • Given values for (x,y), say x = a and y = b, compute f(a,b) = c • c > 0, then (a,b) is “outside” shape f • c = 0, then (a,b) is on the boundary/surface of shape f • c < 0, then (a,b) is “inside” shape f • Parametric form (x,y) = (f(u),g(u)) • Ex: x = f(t) = r cos(t) , y = g(t) = r sin (t) • Given any value for t parameter, compute a point (x,y)

  9. Parametric line equation • P(t)= P0+ t V • P0 is point on line • V is direction (or slope) of line • On line segment with P1, t ranges from (0,1) • x = P0.x + t * (P1 – P0).x • y = P0.y + t * (P1 – P0).y

  10. Point on a line segment • Given (x,y), is it on a line segment (P1 to P0)? • x = P0.x + tx* (P1 – P0).x • y = P0.y + ty* (P1 – P0).y • Plug in x, y, P0, P1, solve for tx and ty • On the segment if 0 ≤ tx = ty ≤ 1

  11. Examples • P0 = (0,0) • P1 = (1,1) • P = (0.5, 0.5) • P = (-1, -1) • P = (2, 2) • P = (5, 0)

  12. Line intersection – two equations • Pa = P0 + ta (P1 – P0) • Pb= P2+ tb(P3– P2) • Set them equal, solve for ta and tb • Note that these are vector equations, not scalars • Line segment intersection if • 0 <= ta <= 1, and • 0 <= tb<= 1

  13. Line intersection – visual example

  14. Point in polygon – ray test

  15. Ray test special cases

  16. Point in convex polygon (y - y0) (x1 - x0) - (x - x0) (y1 - y0) > 0, point is to the left of the line < 0, point is to the right of the line = 0, point is on the line

  17. Point in convex polygon (y - y0) (x1 - x0) - (x - x0) (y1 - y0) For (3,1): (1)(5) – (3)(0) = 5 For (3,0): (0)(5) – (3)(0) = 0 For (3,-1): (-1)(5) – (3)(0) = -5

  18. Polygon Intersection Contained vertex Intersecting edges

  19. Polygon intersection – vertex + edges

  20. Collision detection: point-ground plane p = (x, y, z)

  21. Surface/Polygon normals Images from http://en.wikipedia.org/wiki/Normal_(geometry)

  22. Collision detection: point-plane p = (x, y, z) N = (a, b, c) N Terms: p = point N = normal vector D = distance from origin

  23. Collision detection: time of impact P(ti) P(ti+1) 2 options Consider collision at next time step Compute fractional time at which collision actually occurred Tradeoff: accuracy v. complexity

  24. 3D object collision detection

  25. Collision detection: polyhedra • Order tests according to computational complexity and power of detection 1. test bounding volumes for overlap 2. test for vertex of one object inside of other object 3. test for edge of one object intersecting face of other object

  26. Polygon and polyhedra complexity How many edges? How many points?

  27. Bounding objects • Sphere • Axis aligned bounding box • Oriented bounding box

  28. Bounding volume construction • Given a set of points as input, can we automatically create bounding volumes • Axis aligned bounding box • Sphere • Convex hull

  29. Axis aligned bounding box

  30. Axis aligned bounding box

  31. Bounding sphere

  32. Bounding sphere

  33. Bounding sphere

  34. Bounding sphere

  35. Convex Hull Best fit convex polyhedron to concave polyhedron but takes some (one-time) computation • Find highest vertex, V1 • Find remaining vertex that minimizes angle with horizontal plane through point. Call edge L • Form plane with this edge and horizontal line perpendicular to L at V1 • Find remaining vertex that for triangle that minimizes angle with this plane. Add this triangle to convex hull, mark edges as unmatched • For each unmatched edge, find remaining vertex that minimizes angle with the plane of the edge’s triangle

  36. Convex hull

  37. Convex hull

  38. Convex hull

  39. Convex hull

  40. Convex hull

  41. Convex hull

  42. Convex hull

  43. Bounding Slabs For better fit bounding polyhedron: use arbitrary (user-specified) collection of bounding plane-pairs Is a vertex between each pair?

  44. Sphere vs. Sphere Compare distance (p1,p2) to r1+r2 distance(p1,p2)2 to (r1 + r2)2

  45. AABB vs. AABB

  46. AABB vs. AABB

  47. Oriented bounding boxes and arbitrary polygons • Separating axis theorem • http://gamedev.tutsplus.com/tutorials/implementation/collision-detection-with-the-separating-axis-theorem/ • http://www.sevenson.com.au/actionscript/sat/ • http://www.metanetsoftware.com/technique/tutorialA.html

  48. Sphere vs. AABB

  49. Sphere vs. AABB – clamping

  50. Sphere vs. AABB – closest point

More Related