Collision Detection Part 2. Narrow Phase Collision Detection The - - PowerPoint PPT Presentation

collision detection
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Collision Detection

Part 2. Narrow Phase Collision Detection

slide-2
SLIDE 2

The Narrow Phase

Exact collision detection: Where precisely have objects touched, where to apply forces, torques?

slide-3
SLIDE 3

Collision Response

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.

slide-4
SLIDE 4

Modelling Contact

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

slide-5
SLIDE 5

Contact Manifolds

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

slide-6
SLIDE 6

Inexact contact

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

slide-7
SLIDE 7

Point of Contact

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

slide-8
SLIDE 8

Types of contact

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

slide-9
SLIDE 9

Closest Points Determination

V-V Collision Take vertices as closest points Q: What is the collision plane/normal?

slide-10
SLIDE 10

Closest Points Determination

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

  • pE

   

slide-11
SLIDE 11

Closest Points Determination

V-F Collision Project V onto edge F Say F defined as normal n and arbitrary point f

  • n face, then

n)n f) ((v v pF    

If projection is outside the polygon, then use VE case to find closest point

slide-12
SLIDE 12

Closest Points Determination

E-E Collision For E1 defined as start point o1 and direction u1

and E2 defined as start point o2 and direction u2

pE2 determined as in V-E case (pE1 - E2)

1 2 2 1 1 2 1

1 ) ( ) (

1

u u u

  • p

            k k

E 2 1 u

u   k where

slide-13
SLIDE 13

Quick Aside: Proof of E-E case

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

slide-14
SLIDE 14

Closest Points Determination

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      

slide-15
SLIDE 15

Contact Regions

Intersection of two objects For polyhedra, this is a polygonal area consisting of:

Single points Line segments

  • r Closed polygons (possibly with holes if non-convex)
slide-16
SLIDE 16

Contact Formation

We should be able to represent the contact region by the vertices of the intersecting polygonal regions

slide-17
SLIDE 17

Contact Regions

Concave objects

slide-18
SLIDE 18

Contact Normal

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

slide-19
SLIDE 19

Applying the Contact Model

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

slide-20
SLIDE 20

Multiple contacts

Suggestions

Use net force (possibly ok for convex-only collisions) Use earliest impact Integrate force over collision manifold Solve simultaneous contacts (e.g. LCP)

slide-21
SLIDE 21

Contact Tracking

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

slide-22
SLIDE 22

Narrow Phase Optimisation

slide-23
SLIDE 23

Narrow Phase

Key Types Techniques:

Bounding Volume Hierarchies + Spatial Partitioning Feature-based Simplex-based Volume-based

slide-24
SLIDE 24

Contact Levels of Detail

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

  • f the feature
slide-25
SLIDE 25

Contact Levels of Detail

Similar to Multiresolution for display Simplification must preserver local convexity

slide-26
SLIDE 26

Contact Manifolds

Pauly et al: Quasi-rigid

  • bjects in contact, SCA

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

slide-27
SLIDE 27

Contact Manifolds

Galoppo et al, SCA 2006: Dynamic Deformation Textures GPU extraction of contact manifold for deformable

  • bjects
slide-28
SLIDE 28

Volumetric Models & BVH

slide-29
SLIDE 29

Volumetric Models

Some Problems (particularly in non-regular BVH) Solution: cache normals on BV node related to the underlying geometry

Ok case Bad case

slide-30
SLIDE 30

CULLIDE

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

slide-31
SLIDE 31

Feature-based Algorithms

Lin-Canny V-Clip Basic Principles

Based on features: vertex (V), edge(E), face(F) Closest Features Tracking Proximity Query Based on Voronoi Regions

slide-32
SLIDE 32

Lin-Canny

Pairwise Collision Detection for Convex Polytopes Tracks closest points between pairs of convex polytopes Gives closest features even if

  • bjects do not intersect

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)

slide-33
SLIDE 33

Closest Features

  • Find the shortest distance between two convex objects by

first finding the closest features

  • Based on the following theorem:

– 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.

slide-34
SLIDE 34

Voronoi Regions

A Voronoi region, associated with each feature of an object, is the set of points that are closer to that feature than any

  • ther

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)

slide-35
SLIDE 35

Voronoi Regions

slide-36
SLIDE 36

Voronoi Regions of 3D Features

Face Edge Vertex A convex 3D object Regions are bounded by planes in 3D

slide-37
SLIDE 37
slide-38
SLIDE 38

Lin-Canny

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

slide-39
SLIDE 39

Lin-Canny

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

slide-40
SLIDE 40

Lin-Canny Limitations

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.

slide-41
SLIDE 41

V-Clip (Mirtich 98)

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

slide-42
SLIDE 42

V-Clip Overview

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 

slide-43
SLIDE 43

Feature Update Examples

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

slide-44
SLIDE 44

Voronoi Clipping

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.

slide-45
SLIDE 45

Voronoi Clipping

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

slide-46
SLIDE 46

V-Clip Analysis

  • Very fast if the conditions for using it can be met,

particularly if coherence exists

– Higher frame rates lead to greater coherence

  • Can be very easily modified to handle deforming objects
  • It is really a primitive collision test - the primitives are

convex rigid bodies

– Could be used as the base case for algorithms like OBB-Trees

  • Both V-Clip and Lin-Canny only work for convex,

polygonal, closed objects. Concave objects must be represented as union of convex sub-parts.

slide-47
SLIDE 47

References

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/

slide-48
SLIDE 48

GJK – A Simplex based algorithm

Following slides based on Siggraph 2004 Slides by Christer Ericson

slide-49
SLIDE 49

A Simplex Based Algorithm

0-simplex 1-simplex 2-simplex 3-simplex simplex

slide-50
SLIDE 50

Gilbert Johnson Keerthi (GJK)

Given two convex polyhedra

Computes distance d Can also return closest pair of points PA, PB

d

A

P

B

P

GJK: An iterative technique for calculating distance between polytopes

slide-51
SLIDE 51

GJK

Generalized for arbitrary convex objects

As long as they can be described in terms of a support mapping function

d

A

P

B

P

slide-52
SLIDE 52

Support Mapping

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

C

) (d p

C

S 

C

) (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

slide-53
SLIDE 53

GJK

Gilbert’s Algorithm

For two (potentially colliding polytopes), find the simplex subset of each polytope that contains a point closest to

  • ther polytope

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

     , } , ... , , {

slide-54
SLIDE 54

Terminology 3(3)

Point set C Convex hull, CH(C)

slide-55
SLIDE 55

The GJK algorithm

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

slide-56
SLIDE 56

GJK example 1(10)

C

INPUT: Convex polyhedron C given as the convex hull of a set of points

slide-57
SLIDE 57

GJK example 2(10)

Initialize the simplex set Q with up to d+1 points from C (in d dimensions)

Q

 

1 2

, , Q Q Q Q 

C

1

Q

2

Q

slide-58
SLIDE 58

GJK example 3(10)

 

1 2

, , Q Q Q Q 

1

Q Q

2

Q P

2. Compute point P of minimum norm in CH(Q)

slide-59
SLIDE 59

GJK example 4(10)

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

, Q Q Q 

1

Q Q P

2

Q

slide-60
SLIDE 60

GJK example 5(10)

Let V=SC(–P) be a supporting point in direction –P

 

1 2

, Q Q Q 

1

Q

2

Q P

( )

C

V S P  

slide-61
SLIDE 61

GJK example 6(10)

If V no more extreme in direction –P than P itself, exit; return ||P|| Add V to Q. Go to step 2

1

Q

 

1 2

, , Q Q Q V 

2

Q V

slide-62
SLIDE 62

GJK example 7(10)

 

1 2

, , Q Q Q V 

1

Q

2

Q V P

2. Compute point P of minimum norm in CH(Q)

slide-63
SLIDE 63

GJK example 8(10)

If P is the origin, exit; return 0 Reduce Q to the smallest subset Q’ of Q, such that P in CH(Q’)

 

2,

Q Q V 

2

Q V P

slide-64
SLIDE 64

GJK example 9(10)

Let V=SC(–P) be a supporting point in direction –P

2

' ( )

C

S Q V P   

 

2,

Q Q V 

V P

slide-65
SLIDE 65

GJK example 10(10)

If V no more extreme in direction –P than P itself, exit; return ||P||

V P

DONE!

 

2,

Q Q V 

2

Q

slide-66
SLIDE 66

Closest point on triangle

B C A

  • ClosestPointOnTriangleToPoint()

– Finds point on triangle closest to a given point

P Q

slide-67
SLIDE 67

Closest point on triangle

B C A F

A

V

B

V

C

V

AB

E

AC

E

BC

E

  • Separate cases based on which feature Voronoi

region point lies in

slide-68
SLIDE 68

Closest point on triangle

A B C X

A

V

slide-69
SLIDE 69

Closest point on triangle

B C X A

AB

E

slide-70
SLIDE 70

GJK for two objects

  • What about two polyhedra, A and B?
  • Reduce problem into the one solved

– No change to the algorithm! – Relies on the properties of the Minkowski difference of A and B

  • Brief description follows
slide-71
SLIDE 71

Minkowski sum & difference

  • Minkowski sum

– The sweeping of one convex object with another

  • Defined as:

slide-72
SLIDE 72
  • Minkowski difference, defined as:

  • Can write distance between two objects as:

  • A and B intersecting iff A–B contains the origin!

– Distance between A and B given by point of minimum norm in A–B!

Minkowski sum & difference

slide-73
SLIDE 73

The generalization

  • A and B intersecting iff A–B contains the origin!

– Distance between A and B given by point of minimum norm in A–B!

  • So use previous procedure on A–B!
  • Only change needed: computing
  • Support mapping separable, so can form it by

computing support mapping for A and B separately!

( ) ( )

C A B

S S

 d d

slide-74
SLIDE 74

Minkowski Difference

A B A B

slide-75
SLIDE 75

A

v

B

v

GJK for moving objects

slide-76
SLIDE 76

A

v

B

v

A B

  v v v Transform the problem…

slide-77
SLIDE 77

v

…into moving vs stationary

slide-78
SLIDE 78

GJK Analysis

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

  • f two polyhedra

Approximate displacement as linear between two successive frames

slide-79
SLIDE 79

References

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

  • bjects in Three-dimensional Space” IEE journal of robotics and

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/