collisions using separating axis tests
Skip this Video
Download Presentation
Collisions using separating-axis tests

Loading in 2 Seconds...

play fullscreen
1 / 27

Collisions using separating-axis tests - PowerPoint PPT Presentation

  • Uploaded on

Collisions using separating-axis tests. Christer Ericson Sony Computer Entertainment Slides @ Problem statement. Determine if two (convex) objects are intersecting. Possibly also obtain contact information. ?. !. Underlying theory.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Collisions using separating-axis tests' - sirius

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
collisions using separating axis tests
Collisions using separating-axis tests

Christer EricsonSony Computer EntertainmentSlides @

problem statement
Problem statement
  • Determine if two (convex) objects are intersecting.
  • Possibly also obtain contact information.



underlying theory
Underlying theory
  • Set C is convex if and only if the line segment between any two points in C lies in C.
underlying theory4
Underlying theory
  • Separating Hyperplane Theorem
    • States: two disjoint convex sets are separable by a hyperplane.
underlying theory5
Underlying theory
  • Nonintersecting concave sets not generally separable by hyperplane (only by hypersurfaces).
  • Concave objects not covered here.
underlying theory6
Underlying theory
  • Separation w.r.t a plane P  separation of the orthogonal projections onto any line L parallel to plane normal.
underlying theory7
Underlying theory
  • A line for which the projection intervals do not overlap we call a separating axis.
testing separation
Testing separation
  • Compare absolute intervals

Separated if


testing separation9
Testing separation
  • For centrally symmetric objects: compare using projected radii

Separated if

code fragment
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 < n; i++) {

float value = Dot(axis, o.getVertex(i));

min = Min(min, value);

max = Max(max, value);



axes to test
Axes to test
  • But which axes to test?
    • Potentially infinitely many!
  • Simplification:
    • Deal only with polytopes
      • Convex hulls of finite point sets
      • Planar faces
axes to test12
Axes to test
  • Handwavingly:
    • Look at the ways features of A and B can come into contact.
      • Features are vertices, edges, faces.
      • 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.
axes to test13
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.
axes to test14
Axes to test
  • Four axes for two 2D OBBs:
code fragment16
Code fragment

bool TestIntersection(Object o1, Object o2) {

float min1, max1, min2, max2;

for (int i = 0, n = o1.NumFaceDirs(), i < n; i++) {

GetInterval(o1, o1.GetFaceDir(i), min1, max1);

GetInterval(o2, o1.GetFaceDir(i), min2, max2);

if (max1 < min2 || max2 < min1) return false;


for (int i = 0, n = o2.NumFaceDirs(), i < n; i++) {

GetInterval(o1, o2.GetFaceDir(i), min1, max1);

GetInterval(o2, o2.GetFaceDir(i), min2, max2);

if (max1 < min2 || max2 < min1) return false;


for (int i = 0, m = o1.NumEdgeDirs(), i < m; i++)

for (int j = 0, n = o2.NumEdgeDirs(), j < n; j++) {

Vector axis = Cross(o1.GetEdgeDir(i), o2.GetEdgeDir(j));

GetInterval(o1, axis, min1, max1);

GetInterval(o2, axis, min2, max2);

if (max1 < min2 || max2 < min1) return false;


return true;


Note: here objects assumed to be in the same space.

moving objects
Moving objects
  • When objects move, projected intervals move:
moving objects18
Moving objects
  • Objects intersect when projections overlap on all axes.
  • If tifirst and tilast are time of first and last contact on axis i, then objects are in contact over the interval [maxi { tifirst}, mini { tilast}].
  • No contact if maxi { tifirst} > mini { tilast}
moving objects19
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} > mini { tilast}
nonpolyhedral objects
Nonpolyhedral objects
  • What about:
    • Spheres, capsules, cylinders, cones, etc?
  • Same idea:
    • Identify all ‘features’
    • Test all axes that can possibly separate feature pairs!
nonpolyhedral objects21
Nonpolyhedral objects
  • Sphere tests:
    • Has single feature: its center
    • Test axes going through center
    • (Radius is accounted for during overlap test on axis.)
nonpolyhedral objects22
Nonpolyhedral objects
  • Capsule tests:
    • Split into three features
    • Test axes that can separate features of capsule and features of second object.
nonpolyhedral objects23
Nonpolyhedral objects
  • Sphere vs. OBB test:
    • sphere center vs. box vertex
      • pick candidate axis parallel to line thorugh both points.
    • sphere center vs. box edge
      • pick candidate axis parallel to line perpendicular to edge and goes through sphere center
    • sphere center vs. box face
      • pick candidate axis parallel to line through sphere center and perpendicular to face
  • Use logic to reduce tests where possible.
nonpolyhedral objects24
Nonpolyhedral objects
  • For sphere-OBB, all tests can be subsumed by a single axis test:

Closest point on OBB to sphere center

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

Typical test:

if (Dot(foo, axis) > Dot(bar, axis)) return false;

Becomes, due to floating-point errors:

if (epsilon1 > epsilon2) return false;

Results in: Chaos!

(Address using means discussed earlier.)

contact determination
Contact determination
  • Covered by Erin Catto (later)
  • Ericson, Christer. Real-Time Collision Detection. Morgan Kaufmann 2005.
  • Levine, Ron. “Collisions of moving objects.” gdalgorithms-list mailing list article, November 14, 2000.
  • Boyd, Stephen. Lieven Vandenberghe. Convex Optimization. Cambridge University Press, 2004.
  • Rockafellar, R. Tyrrell. Convex Analysis. Princeton University Press, 1996.