10: MULTIPLE CONTACT RESOLUTION

10: MULTIPLE CONTACT RESOLUTION
22/02/2016
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
2
Image © 2003 E. Guendelman, R. Bridson and R. Fedkiw
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
3
COMPLEX CONTACT MANIFOLDS
Most contacts usually not just a single point colliding but contact manifold
Contact Force and Equivalence Principle [Erleben05] :
 Equivalent forces or impulses exist such that when they are applied to the
convex hull of the contact region, the same resulting motion is obtained,
which would have resulted from integrating the true contact force or
impulse over the actual contact region
[Erleben05] Erleben, K., Sporring, J., Henriksen, K., and Dohlman, H., Physics Based Animation. Charles River Media, August 9, 2005.
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
Images © 2014 John Dingliana
22/02/2016
4
CONTACT REDUCTION
Contacts reduced to those on
the convex hull of the manifold.
Then further reduce those that
cause minimal change to the
hull area
Use K-means clustering
and cluster reduction
Pre-process features in a scene
making edges inactive if not
important for collisions e.g. interior
edges, concave edges
Use initial guess and then warm
starting in subsequent frames
exploiting temporal coherency.
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
[Morvanszky04] Morvanszky and Terdiman. Fast Contact Reduction for Dynamics
Simulation. Game Programming Gems 4. Charles River Media. 2004. pp 253-263
22/02/2016
5
PENALTY METHODS
Amongst the earliest solutions and still widely used
Easy to implement compared to other methods
Some problems for rigid objects
 Objects too springy →not plausible
 Increase stiffness → leads to instability
for large time steps
 Increase # timesteps →
computationally expensive
Images © Erleben et al & Charles River Media 2005.
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
6
PENALTY METHODS: STABILITY ISSUES
Ambiguous configuration: which is correct way
to apply non-interpenetration spring forces?
Possible Oscillation
Instability – direction of spring forces changes
suddenly between two relatively similar frames
Current frame info insufficient. “History”
required to determine direction of penalty
springs
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
Increase sampling in the hopes of
reducing this : has a computational
cost
Images © Erleben et al & Charles River Media 2005.
22/02/2016
7
IMPULSE-BASED METHODS
Theory [Mirtich95]: Every interaction can be modelled through (micro)
collision impulses including:
 Colliding contact,
 Resting contact,
 Sliding contact
 Rolling
[Mirtich95] Mirtich, B. & Canny, J., Impulse-based simulation of rigid bodies Proceedings of the
1995 symposium on Interactive 3D graphics
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
8
IMPULSE-BASED METHODS
We have largely been looking at impulse based rigid body simulation.
Two ways of dealing with multiple collisions:
 Sequential Collision Impulses
 Simultaneous Collision Processing
Refers to order of processing not actual time
In theory, no method is actually better. We can set up configurations
where either one outdoes the other [Mostermann07]
[Mostermann07]: Mostermann P.J.: On the normal component of centralized frictionless collision sequences.
Journal of applied mechanics. vol. 74, no. 5, pp. 908-915. 2007.
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
9
SEQUENTIAL PROBLEM#1 : INFINITE LOOP
Two balls on a plane causing sequential collision solver to enter an infinite loop
Images © Erleben et al & Charles River Media 2005.
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
10
PROBLEM #2: INDETERMINACY OF ORDER
B
A
C
D
Sequential processing error: 4 contact points – depending on
order of processing box may acquire some rotational velocity.
Order of processing determines how this will rotate.
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
11
ROBUST SEQUENTIAL PROCESSING
To eliminate infinite looping: Keep track of each contact and count
number of times it needs to be resolved
To remove indeterminacy: Contact points sorted based on some
physical property e.g. their relative normal contact velocities
Also reduce by:
 Conservative advancement (Adaptive Timesteps)
 Time of impact calculation (Retroactive Detection)
 Higher sampling
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
12
SEQUENTIAL IMPULSE PROCESSING IN BOX 2D
Apply an impulse at each contact point.
Continue applying impulses for several iterations.
Terminate after:
 fixed number of iterations
 impulses become small
Update Position Last
P1
P2
P1
P2
[Catto] Erin Catto. Fast and Accurate Sequential Impulses, GDC 2006 Talk
https://code.google.com/p/box2d/downloads/list
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
SIMULTANEOUS CONTACT PROCESSING
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
14
MULTIPLE COLLIDING CONTACTS
Single point collision: between two bodies,
A&B
 At time of collision Multiple contact: For any point i in
contact between bodies A and B
 At time of collision  Our assumption for each contacting
point on each body: influences
which influences
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
15
RECALL: COLLISION IMPULSE
Newton’s third law
J A  jnˆ
and
J B   jnˆ
From previous lectures
Newton’s law of restitution
and
For single contact point collision we had:
1
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
16
MULTIPLE CONTACTS
Looking at just the linear velocity we
require either…
 A must stop
 A must bounce upwards
A
B
C
Considering angular velocity the answer
is not so obvious
Sequential impulse solution:
 Apply impulse at
:
 Body moves to the right penetrating into
C
 Apply impulse at
 Body moves towards left penetrating
into B
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
A
B
C
A rotates clockwise
22/02/2016
17
SIMULTANEOUS CONTACTS
 We used Newton’s law of restitution for
frictionless collisions:
 But this doesn’t readily extend to
multiple point collisions
B
C
 We need “looser” assumptions:
 Assume coefficient of restitution relates to each collision point
individually
 Bodies may be pushed away from each other by a third more powerful
simultaneous collision
 Rewrite Newton’s restitution law to account for this : OR
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
0
22/02/2016
18
SIMULTANEOUS IMPULSE EQUATION
Using
∆
∆
= ∆
and substituting:
∆
From previous lectures
and

Reformulate post collision velocity equation to account for
simultaneous 1 points of contact on body

∑
∑
Putting this in the equation of relative velocity at point
direction, i.e.
, we get:
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
in the normal
22/02/2016
19
SIMULTANEOUS IMPULSE EQUATION
Rewrite as:
 or:
0 we get
Putting this into
0
 or:
1
Which can be written as
1
and Main points to note: multiple impulses considered,
solve a system of equations with an inequality
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
0
0
where
0
For details see: [Giang03] Giang, T. Bradshaw, G. O’Sullivan, C. Complementarity
Based Multiple Point Collision Resolution. Eurographics Ireland 2003.
22/02/2016
20
SIMULTANEOUS IMPULSE EQUATION
So we need to solve a linear system of equations of the form
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
 The vector here is the list of unknown impulse magnitudes
be solved for
which is to
 The calculated impulse magnitudes are then applied to rigid body states
to change rigid body momenta appropriately
To solve the problem typically formulate as a Linear Complementarity
Problem (LCP) and solve using an LCP solver
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
21
LINEAR COMPLEMENTARITY PROBLEM
A frequently encountered in mathematical optimization theory.
 NP-Complete in general. But solvable if matrix
is Positive-Semidefinite.
Given a known matrix and known vector , seek vectors and
which satisfy the following constraints:

Let

Since


then
0
0 since the impulses
0forall
Complementarity Condition:
inner product is zero
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
0
’s must be repulsive
since
for
conservation of kinetic energy
For detail see [Eberley03] David Eberly Game Physics. Sec. 6.6.2 p 491Simultaneous Processing of Collision Points. Morgan Kaufmann
22/02/2016
22
LCP SOLVERS
Some solutions used in Animation/Physics Engines:
 Newton Methods: Quadratic convergence, O(n3) work per iteration
 e.g. PATH by Michael Ferris: http://pages.cs.wisc.edu/~ferris/path.html
 Direct methods (pivoting methods): Work per iteration O(n2)
 e.g. Featherstone, Dantzig LCP, Lemke O(n3) e.g. WildMagic by Eberly:
 http://cdserv.wbut.ac.in/81-8147-617-4/Linux/MagicSoftware/WildMagic2/Physics.html
 Iterative methods: linear convergence, O(n) work per iteration (if upper
bound is placed on iterations), trade off accuracy vs. speed
 e.g. Projected Gauss Seidel (PGS), Conjugate Gradient
 Believed to be used by many popular physics engines1 : Havok, Novodex
(now PhysX), Open Dynamics Engine (ODE)
 Several solvers provided by INRIA:
http://siconos.gforge.inria.fr/Numerics/LCPSolvers.html
1: Bullet Physics forum: Which LCP solvers have been used by popular physics engines
http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?p=&f=&t=265
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
23
FURTHER INFO: SIMULTANEOUS PROCESSING
[Erleben13] Kenny Erleben. Numerical Methods for Linear Complementarity Problems in PhysicsBased Animation.
 Siggraph 2013 Course Notes:
http://image.diku.dk/kenny/download/erleben.13.siggraph.course.notes.pdf
 VRIPHYS Slides: http://image.diku.dk/kenny/download/vriphys10_course/lcp.pdf
Games-related
references
Other references:
 [Eberley03] David Eberly. Simultaneous Processing of Collision Points. In Game Physics. (Sec. 6.6.2
p 491- )Morgan Kaufmann, 2003.
 [Kipfer] GPU Gems 3: Chapter 33. LCP Algorithms for Collision Detection Using CUDA;
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch33.html
 [Hecker04] The mixed linear complementarity problem. GDC 2004 Talk:
http://chrishecker.com/The_Mixed_Linear_Complementarity_Problem
 [Coumans14] Exploring MLCP Solvers and Featherstone, GDC 2014 Talk : http://goo.gl/84N71q
 [Neumann 04] Erik Neumann, Collision Handling Lab (web tutorial). For comparing different types
of simultaneous collision resolution: http://www.myphysicslab.com/Collision-methods.html
 [Murty88] Katta G. Murty. Linear Complementarity, Linear and Nonlinear Programming.
Helderman-Verlag, 1988. For the detailed mathematical theory behind it. Free BOOK:
http://ioe.engin.umich.edu/people/fac/books/murty/linear_complementarity_webbook/
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016
24
SOURCES (PRIVATE)
Billups & Murty – LCP
 http://www-personal.umich.edu/~murty/LCPart.pdf
Patil – Contact (lecture)
 http://www.cs.unc.edu/~lin/COMP768-F07/LEC/20.pdf
Baraff – Contact Force computation
 http://www.cs.cmu.edu/~baraff/papers/sig94.pdf
Wikipedia – Complementatity
 http://en.wikipedia.org/wiki/Complementarity_theory
Erleben – Siggraph course notes
 http://image.diku.dk/kenny/download/erleben.13.siggraph.course.notes.
pdf
CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE
22/02/2016