Collisions using separating-axis tests

Slides:



Advertisements
Similar presentations
Everything you ever wanted to know about collision detection
Advertisements

Collisions using separating-axis tests Christer Ericson Sony Computer Entertainment
The Gilbert-Johnson-Keerthi (GJK) Algorithm
2.4. Primitive Tests - Closest point
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
Computational Geometry
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
2.3. B OUNDING V OLUMES Bounding volumes of use for collision detection.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
Here is where my object is Here is where my object is going to be Here is where I want my object to be.
고려대학교 그래픽스 연구실 Chapter 6 Collision Detection 6.1~6.4 고려대학교 그래픽스연구실 민성환.
Continuous Collision Detection: Progress and Challenges Gino van den Bergen dtecta
Advanced Computer Graphics Spring 2014
Chapter 12: Surface Area and Volume of Solids
Computational Geometry & Collision detection
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
A Fast Algorithm for Incremental Distance Calculation Paper by Ming C. Ling and John F. Canny Presented by Denise Jones.
By: Andrew Shatz & Michael Baker Chapter 15. Chapter 15 section 1 Key Terms: Skew Lines, Oblique Two lines are skew iff they are not parallel and do not.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to.
1 Terrain Following & Collision Detection. 2 Both of topics are very game-type-oriented Both of topics are very game-type-oriented Terrain Terrain For.
Collision Detection CSE 191A: Seminar on Video Game Programming Lecture 3: Collision Detection UCSD, Spring, 2003 Instructor: Steve Rotenberg.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Collision Detection – Narrow Phase.
Week 13 - Wednesday CS361.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
Chapter 15: Geometric Solids Brian BarrDan Logan.
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Collision handling: detection and response
Week 13 - Friday.  What did we talk about last time?  Ray/sphere intersection  Ray/box intersection  Slabs method  Line segment/box overlap test.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Lesson 1.8 – Space Geometry Homework: Lesson 1.8/1-27 Chapter 1 Test Friday 10/18.
3.4. C ONTACT G ENERATION Generating contacts between rigid bodies.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
1 KIPA Game Engine Seminars Jonathan Blow Ajou University December 6, 2002 Day 10.
Section 12-1 Name the Solids. Prism a 3-dimensional figure with two congruent, parallel faces The bases are congruent, parallel faces. The bases lie in.
1-7 Three Dimensional Figures Surface Area and Volume Day 2 What is surface area? What is volume? How do you know what formulas to use?
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Warm-Up 1) Draw a polygon that is not convex. 2) Find the measure of an exterior angle of a regular decagon. 3) Find the circumference and area of a circle.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
8.2 Surface Area Objectives:
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
An introduction to 3D Figures
Chapter Area, Pythagorean Theorem, and Volume 14 Copyright © 2013, 2010, and 2007, Pearson Education, Inc.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Advanced Computer Graphics Spring 2009
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Week 13 - Wednesday CS361.
Polyhedra and Prisms.
Surface Area and Volume
Collision Detection Spring 2004.
Parts of these slides are based on
Collision handling: detection and response
2.4. Primitive Tests - Closest point
2.5. Basic Primitive Intersection
Computer Animation Algorithms and Techniques
Collision Detection.
Quantum Foundations Lecture 3
David Johnson Cs6360 – Virtual Reality
3.3: Rectangle Collisions
GPAT – Chapter 7 Physics.
Presentation transcript:

Collisions using separating-axis tests Christer Ericson Sony Computer Entertainment Slides @ http://realtimecollisiondetection.net/pubs/

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

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

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

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

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

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

Testing separation Compare absolute intervals Separated if or

Testing separation For centrally symmetric objects: compare using projected radii Separated if

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 But which axes to test? Simplification: Potentially infinitely many! Simplification: Deal only with polytopes Convex hulls of finite point sets Planar faces

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 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 test Four axes for two 2D OBBs:

Axes to test Segment–Tri 1 1x3 4 Segment–OBB 3 6 AABB–AABB 0(3) 0(3x0) 3D Objects Face dirs (A) Face dirs (B) Edge dirs (AxB) Total Segment–Tri 1 1x3 4 Segment–OBB 3 6 AABB–AABB 0(3) 0(3x0) OBB–OBB 3x3 15 Tri–Tri 11 Tri–OBB 13

Code fragment Note: here objects assumed to be in the same space. 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); 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); return true; Note: here objects assumed to be in the same space.

Moving objects When objects move, projected intervals move:

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 objects Optimization 1: Optimization 2: 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 What about: Spheres, capsules, cylinders, cones, etc? Same idea: Identify all ‘features’ Test all axes that can possibly separate feature pairs!

Nonpolyhedral objects Sphere tests: Has single feature: its center Test axes going through center (Radius is accounted for during overlap test on axis.)

Nonpolyhedral objects Capsule tests: Split into three features Test axes that can separate features of capsule and features of second object.

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 objects For sphere-OBB, all tests can be subsumed by a single axis test: Closest point on OBB to sphere center

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 Covered by Erin Catto (later)

References Ericson, Christer. Real-Time Collision Detection. Morgan Kaufmann 2005. http://realtimecollisiondetection.net/ Levine, Ron. “Collisions of moving objects.” gdalgorithms-list mailing list article, November 14, 2000. http://realtimecollisiondetection.net/files/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.