Collision Detection
Part 2. Narrow Phase Collision Detection
Collision Detection Part 2. Narrow Phase Collision Detection The - - PowerPoint PPT Presentation
Collision Detection Part 2. Narrow Phase Collision Detection The Narrow Phase Exact collision detection: Where precisely have objects touched, where to apply forces, torques? Collision Response The following is an equation for Rigid Body
Part 2. Narrow Phase Collision Detection
Exact collision detection: Where precisely have objects touched, where to apply forces, torques?
Constants RB State variables Derived values Contact variables p is the contact point Associated with a contact direction n
The following is an equation for Rigid Body Impulsive collision response (see Baraff et al, we will discuss in detail next week)
See collision response notes for details.
At point of contact two smooth surfaces will have coinciding tangent planes – plane of contact The normal of this plane is defined on each object is the contact normal The point on an each object that we need to apply the appropriate force is the point of collision
We won’t always have one idealised point of collision Simulation often leads to more than just a point of contact – more like a surface or contact manifold
In ideal situations a single contact point usually where distance between objects is zero
i.e. p = pA = pB
In practice, the distance is slightly non zero due to numerical (floating point) imprecision and timestep limitations.
Normally consider a collision envelope e +/- 10-7 or 10-15 We can take the mean of the closest points as the point of collision
2
B A
p p p
p
Let us assume that we are usually dealing with polygonal models Contacts are represented in terms of features – one from each polyhedra A principal Contact a.k.a. Point of contact p is computed based on the closest points between the two colliding features
On each of the features we want to evaluate a closest point to the colliding feature on the opposite object
Three features V, E, F (vertex, edge face) leads to six types of contacts V-V, V-E, V-F, E-E, E-F, F-F
N.B. Unique contact point is not always defined
V-V Collision Take vertices as closest points Q: What is the collision plane/normal?
V-E Collision Project V onto edge E Say E defined as start point o and direction u (a normal vector)
If projection is outside the endpoints, then take closest endpoint of E
u)u
((v
V-F Collision Project V onto edge F Say F defined as normal n and arbitrary point f
n)n f) ((v v pF
If projection is outside the polygon, then use VE case to find closest point
E-E Collision For E1 defined as start point o1 and direction u1
and E2 defined as start point o2 and direction u2
1 2 2 1 1 2 1
1 ) ( ) (
1
u u u
k k
E 2 1 u
u k where
Assume we know closest point pE1 and pE2 Then they would have to satisfy Similar to V-E case Substituting gives Or
2 1 u
u k where
Remaining cases can be solved by decomposing into a set of the previously defined cases E-F Collision: If O and D are endpoints of E and boundary edges of F are given by { E0, E1, E2... } Then F-F Collision: If boundary edges of F1 are given by and F2 given by Then In fact only three cases are really required : (V-E), (E-E), (V-F) Exercise: Why?
...} ), ( ), ( ), ( ), {( ) (
1
E E E E F D F O F E
... , , ,
2 2 2 1 2
E E E
... , , ,
1 2 1 1 1
E E E
...} ), ( ), ( , ... ), ( ), {( ) (
1 2 1 1 2 2 1 1 2 1 2 1
F E F E F E F E F F
Intersection of two objects For polyhedra, this is a polygonal area consisting of:
Single points Line segments
We should be able to represent the contact region by the vertices of the intersecting polygonal regions
Concave objects
In real-life we expect a common contact plane and normal This is not always the case with polyhedral objects (normal not defined on an infinitesimal point) Solution:
Choose normal of feature with higher dimension or if the same then pick a random one of the two Take a line between closest points Average
Possible stability issues
Now that we have a contact region what do we do with it? -> Ready for collision response Net or component forces can be calculated based on the contact manifold
Suggestions
Use net force (possibly ok for convex-only collisions) Use earliest impact Integrate force over collision manifold Solve simultaneous contacts (e.g. LCP)
Mirtich, B. “Rigid Body Contact: Collision Detection to Force Computation”. MERl TR-98-01. 1998
Back-tracking time control Track closest features, determine closest points – apply forces If interpenetrating – indicates missing contact point Identify potential contact features – backtrack till they are disjoint and add these to contact formulation CF
Key Types Techniques:
Bounding Volume Hierarchies + Spatial Partitioning Feature-based Simplex-based Volume-based
Otaduy & Lin Siggraph 2003 For haptic rendering
requirement of >kHz framerates
Hierarchical multiresolution based on filtered edge collapse perception of geometric features depends on ratio between contact area and feature – not absolute size
Similar to Multiresolution for display Simplification must preserver local convexity
Pauly et al: Quasi-rigid
2004 Contact model is essentially Inside-outside test with Point cloud representation of object Also store degree of penetration -> deformation requires some measure of this
Galoppo et al, SCA 2006: Dynamic Deformation Textures GPU extraction of contact manifold for deformable
Some Problems (particularly in non-regular BVH) Solution: cache normals on BV node related to the underlying geometry
Ok case Bad case
Set up a potentially colliding set (PCS) of objects or sub-objects S Object O is are removed from PCS if it is not fully visible with respect to S
Govindaraju et. al. “CULLIDE: Interactive Collision Detection Between Complex Models in Large Environments using Graphics Hardware”, Graphics Hardware 2003
Lin-Canny V-Clip Basic Principles
Based on features: vertex (V), edge(E), face(F) Closest Features Tracking Proximity Query Based on Voronoi Regions
Pairwise Collision Detection for Convex Polytopes Tracks closest points between pairs of convex polytopes Gives closest features even if
References: Ming C. Lin. “Efficient Collision Detection for Animation and Robotics”. PhD thesis, University of California, Berkeley, December 1993. Available as I-COLLIDE (along with a dimension reduction broad-phase and methods for managing hierarchies of convex objects)
first finding the closest features
– Let A and B be two convex polyhedra and let P be a feature from A and Q be a feature from B. – Now let the points p Є P and q Є Q be the closest points between P and Q. – If p belongs to the voronoi region of Q and q belongs to the voronoi region of P then no other points from A and B lie closer to each other than p and q. – In which case we say that P and Q are the closest features between A and B.
A Voronoi region, associated with each feature of an object, is the set of points that are closer to that feature than any
http://www.personal.kent.edu/ ~rmuhamma/Compgeometry/ MyCG/CG- Applets/VoroDiagram/vorocli.ht m
Face Edge 1 Edge 2 Edge 3 Vert 1 Vert 2 Vert 3
Feature Voronoi region examples (2D Case)
Face Edge Vertex A convex 3D object Regions are bounded by planes in 3D
Iterative procedure:
Start with previous closest features (exploit coherence) Test each feature against other’s Voronoi region If an error, walk to neighboring feature and repeat (Greedy Search: locally optimal solution)
Voronoi regions are built as a pre-process, but this is not an expensive task, so could be done in real time
Voronoi regions and closest point
Find the closest point by finding out which Voronoi region the test point lies in
Closest features algorithm finds the shortest distance between two convex objects by first finding the closest features
The objects must be convex for the closest point to be uniquely defined Convexity also makes greedy search sure to succeed Closest features may be vertex-vertex, vertex-edge, vertex-face, edge-edge; other cases are degenerate
Lin-Canny was originally proposed as an algorithm. There are some practical implementation problems
infinite looping under some cases inability to handle penetration (later extended by internal pseudo Voronoi Regions*) general instability
The problem is in choosing which region to step to next V-Clip by Brian Mirtich improves on Lin Canny
* Lin, M. and Manocha, D. “Collision detection between geometric models: a survey”. In Proc. Of IMA Conference on Mathematics and Surfaces”. 1998.
V-Clip fixes the problems with Lin-Canny by rethinking the rules for transitioning from one region to the next
Uses derivative information to figure out which region to walk to next Works in cases of penetration (detects it and returns negative distance)
Much robust than Lin-Canny
But it’s patented, so legally you cannot use it without a license from Mitsubishi Electric
Performs a greedy search for two features (X, Y) that fulfill the closest feature pair theorem Keep track of current feature pair (which is an estimate of closest proximity between two polyhedra) and closest distance D(X,Y) In each iteration, replace either X or Y with one of their respective neighbours IFF
Replacement decreases currently estimated minimum distance OR improves upon localisation of closest points
) dim( ) dim( ) , ( ) , ( ) dim( ) dim( ) , ( ) , ( ) , ( ) , ( X Z if Y X D Y Z D X Z if Y X D Y Z D Y Z Y X
Lower Dimensional update: (F,E) -> (E’E) improving localization of closest points Higher Dimensional update (V,E) -> (E’, E) or (E’’, E) improving minimum distance
Core of V-Clip is based on edge-clipping to determine which neighbouring feature with which to perform an update
X should be updated with it’s neighbouring feature vertex Z and not W.
Edge clipping used as heuristic that guides greedy search of neighbouring features with which to update current feature pair (X,Y) An edge E is clipped against the voronoi region VR(X) Any intersections are potential updates
particularly if coherence exists
– Higher frame rates lead to greater coherence
convex rigid bodies
– Could be used as the base case for algorithms like OBB-Trees
polygonal, closed objects. Concave objects must be represented as union of convex sub-parts.
Ming Lin “Fast Proximity Queries for Large Game Environments”
http://www.gamasutra.com/features/gdcarchive/2000/lin.doc
Brian Mirtich “V-Clip: Fast and Robust Polyhedral Collision Detection” MERL Tech. Report TR1997-005
http://www.merl.com/projects/vclip/
Following slides based on Siggraph 2004 Slides by Christer Ericson
0-simplex 1-simplex 2-simplex 3-simplex simplex
Given two convex polyhedra
Computes distance d Can also return closest pair of points PA, PB
A
B
GJK: An iterative technique for calculating distance between polytopes
Generalized for arbitrary convex objects
As long as they can be described in terms of a support mapping function
A
B
The supporting (or extreme) point p for a direction d returned by a support mapping function SC is the point most distant in direction d
) (d p
C
S
) (d p
C
S
d
For sphere: SC(d) = O + r * ||d||. For convex polyhedron, SC returns the vertex most distant in direction d N.B. this I not necessarily unique
Gilbert’s Algorithm
For two (potentially colliding polytopes), find the simplex subset of each polytope that contains a point closest to
Initialize with 2 arbitrary simplices, Johnson’s algorithm returns closest points between simplices and possibly a lower dimensional simplex
Johnson’s algorithm Given a polytope Return V(p) є P that is closest to the origin Designed to be efficient when point set is small (at most 4 points in 3-space) Returns closest point and simplex containing that point
1 n m 1 R P v v v P
n m 2 1
, } , ... , , {
Point set C Convex hull, CH(C)
Initialize the simplex set Q with up to d+1 points from C (in d dimensions) Compute point P of minimum norm in CH(Q) If P is the origin, exit; return 0 Reduce Q to the smallest subset Q’ of Q, such that P in CH(Q’) Let V=SC(–P) be a supporting point in direction –P If V no more extreme in direction –P than P itself, exit; return ||P|| Add V to Q. Go to step 2
INPUT: Convex polyhedron C given as the convex hull of a set of points
Initialize the simplex set Q with up to d+1 points from C (in d dimensions)
1 2
1
2
1 2
1
2
2. Compute point P of minimum norm in CH(Q)
If P is the origin, exit; return 0 Reduce Q to the smallest subset Q’ of Q, such that P in CH(Q’)
1 2
1
2
Let V=SC(–P) be a supporting point in direction –P
1 2
1
2
( )
C
V S P
If V no more extreme in direction –P than P itself, exit; return ||P|| Add V to Q. Go to step 2
1
1 2
2
1 2
1
2
2. Compute point P of minimum norm in CH(Q)
If P is the origin, exit; return 0 Reduce Q to the smallest subset Q’ of Q, such that P in CH(Q’)
2,
2
Let V=SC(–P) be a supporting point in direction –P
2
C
2,
If V no more extreme in direction –P than P itself, exit; return ||P||
2,
2
– Finds point on triangle closest to a given point
A
B
C
AB
AC
BC
region point lies in
A
AB
– No change to the algorithm! – Relies on the properties of the Minkowski difference of A and B
– The sweeping of one convex object with another
–
–
–
– Distance between A and B given by point of minimum norm in A–B!
– Distance between A and B given by point of minimum norm in A–B!
computing support mapping for A and B separately!
–
( ) ( )
C A B
S S
d d
A B A B
A
B
A
B
A B
Fairly easy to implement – requires care to make it robust Simpler data structures than V-Clip with comparable performance Can be extended for continuous collision detection
Approximate displacement as linear between two successive frames
Minkowski difference explained (with applet):
http://www.pfirth.co.uk/minkowski.html
Original GJK Paper (somewhat difficult):Gilbert, Johnson, Keerthi, “A fast procedure for computing the distance between complex
automation 4(2) 1988 Gino Van den Bergen; “A fast and Robust GJK Implementation for Collision Detection of Convex Objects” Journal of Graphics Tools 4(2), 1999 FreeSOLID Collision library: includes GJK and AABB
http://www.win.tue.nl/~gino/solid/