Collisions%20using%20separating-axis%20tests - PowerPoint PPT Presentation

About This Presentation
Title:

Collisions%20using%20separating-axis%20tests

Description:

float &min, float &max) { min = max = Dot(axis, o.getVertex(0) ... Consider the Minkowski difference C of A and B. ... come from A, from B, or from sweeping the ... – PowerPoint PPT presentation

Number of Views:71
Avg rating:3.0/5.0
Slides: 25
Provided by: jami132
Category:

less

Transcript and Presenter's Notes

Title: Collisions%20using%20separating-axis%20tests


1
Collisions using separating-axis tests
Christer EricsonSony Computer EntertainmentSlid
es _at_ http//realtimecollisiondetection.net/pubs/
2
Problem statement
  • Determine if two (convex) objects are
    intersecting.
  • Possibly also obtain contact information.

?
!
3
Underlying theory
  • Set C is convex if and only if the line segment
    between any two points in C lies in C.

4
Underlying theory
  • Separating Hyperplane Theorem
  • States two disjoint convex sets are separable by
    a hyperplane.

5
Underlying theory
  • Nonintersecting concave sets not generally
    separable by hyperplane (only by hypersurfaces).
  • Concave objects not covered here.

6
Underlying theory
  • Separation w.r.t a plane P ? separation of the
    orthogonal projections onto any line L parallel
    to plane normal.

7
Underlying theory
  • A line for which the projection intervals do not
    overlap we call a separating axis.

8
Testing separation
  • Compare absolute intervals

Separated if or
9
Testing separation
  • For centrally symmetric objects compare using
    projected radii

Separated if
10
Code fragment
  • void GetInterval(Object o, Vector axis,
  • float min, float max)
  • min max Dot(axis, o.getVertex(0))
  • for (int i 1, n o.NumVertices() i lt n
    i)
  • float value Dot(axis, o.getVertex(i))
  • min Min(min, value)
  • max Max(max, value)

11
Axes to test
  • But which axes to test?
  • Simplification
  • Deal only with polytopes
  • Convex hulls of finite point sets
  • Planar faces

12
Axes to test
  • Handwavingly
  • Look at the ways A and B can come into contact.
  • In 3D, reduces to vertex-face and edge-edge
    contacts.
  • Vertex-face
  • a face normal from either polytope will serve as
    a separating axis.
  • Edge-edge
  • the cross product of an edge from each will
    suffice.

13
Axes to test
  • Theoretically
  • Consider the Minkowski difference C of A and B.
  • When A and B disjoint, origin outside C,
    specifically outside some face F.
  • Faces of C come from A, from B, or from sweeping
    the faces of either along the edges of the other.
  • Therefore the face normal of F is either from A,
    from B, or the cross product of an edge from
    either.

14
Axes to test
  • Four axes for two 2D OBBs

15
Axes to test
3D Objects Face dirs (A) Face dirs (B) Edge dirs (AxB) Total
SegmentTri 0 1 1x3 4
SegmentOBB 0 3 1x3 6
AABBAABB 3 0(3) 0(3x0) 3
OBBOBB 3 3 3x3 15
TriTri 1 1 3x3 11
TriOBB 1 3 3x3 13
16
Code fragment
  • bool TestIntersection(Object o1, Object o2)
  • float min1, max1, min2, max2
  • for (int i 0, n o1.NumFaceDirs(), i lt n
    i)
  • GetInterval(o1, o1.GetFaceDir(i), min1,
    max1)
  • GetInterval(o2, o1.GetFaceDir(i), min2,
    max2)
  • if (max1 lt min2 max2 lt min1) return
    false
  • for (int i 0, n o2.NumFaceDirs(), i lt n
    i)
  • GetInterval(o1, o2.GetFaceDir(i), min1,
    max1)
  • GetInterval(o2, o2.GetFaceDir(i), min2,
    max2)
  • if (max1 lt min2 max2 lt min1) return
    false
  • for (int i 0, m o1.NumEdgeDirs(), i lt m
    i)
  • for (int j 0, n o2.NumEdgeDirs(), j lt
    n j)
  • Vector axis Cross(o1.GetEdgeDir(i),
    o2.GetEdgeDir(j))
  • GetInterval(o1, axis, min1, max1)
  • GetInterval(o2, axis, min2, max2)
  • if (max1 lt min2 max2 lt min1)
    return false

17
Moving objects
  • When objects move, projected intervals move

18
Moving objects
  • Objects intersect when projections overlap on all
    axes.
  • Objects are in contact over the interval maxi
    tifirst, mini tilast, where tifirst and
    tilast are time of first and last contact on axis
    i.
  • No contact if maxi tifirst gt mini tilast

19
Moving objects
  • Optimization 1
  • Consider relative movement only.
  • Shrink interval A to point, growing interval B by
    original width of A.
  • Becomes moving point vs. stationary interval.
  • Optimization 2
  • Exit as soon as maxi tifirst gt mini tilast

20
Nonpolyhedral objects
  • Spheres, capsules, cylinders, cones, etc.
  • E.g. sphere vs. OBB

Closest point on OBB to sphere center
21
Nonpolyhedral objects
  • Capsule tests
  • Split into three features
  • Test axes that can separate features of capsule
    and features of second object.

22
Robustness warning
  • Cross product of edges can result in zero-vector.

Typical test
if (Dot(foo, axis) gt Dot(bar, axis)) return false
Becomes, due to floating-point errors
if (epsilon1 gt epsilon2) return false
Results in Chaos!
23
Contact determination
  • Covered by Erin Catto (later)

24
References
  • Ericson, Christer. Real-Time Collision Detection.
    Morgan Kaufmann 2005. http//realtimecollisiondete
    ction.net/
  • Levine, Ron. Collisions of moving objects.
    gdalgorithms-list mailing list article, November
    14, 2000. http//realtimecollisiondetection.net/fi
    les/levine_swept_sat.txt
  • Boyd, Stephen. Lieven Vandenberghe. Convex
    Optimization. Cambridge University Press, 2004.
    http//www.stanford.edu/boyd/cvxbook/
  • Rockafellar, R. Tyrrell. Convex Analysis.
    Princeton University Press, 1996.
Write a Comment
User Comments (0)
About PowerShow.com