10: Multiple Contact Resolution 22/02/2016
Total Page:16
File Type:pdf, Size:1020Kb
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. Use K-means clustering Then further reduce those that and cluster reduction cause minimal change to the hull area 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. [Morvanszky04] Morvanszky and Terdiman. Fast Contact Reduction for Dynamics Simulation. Game Programming Gems 4. Charles River Media. 2004. pp 253-263 CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 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” Increase sampling in the hopes of required to determine direction of penalty reducing this : has a computational springs cost Images © Erleben et al & Charles River Media 2005. CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 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 C D A 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 A must stop B C A must bounce upwards Considering angular velocity the answer is not so obvious Sequential impulse solution: Apply impulse at : A Body moves to the right penetrating into C B C Apply impulse at A rotates clockwise Body moves towards left penetrating into B CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 22/02/2016 17 SIMULTANEOUS CONTACTS We used Newton’s law of restitution for frictionless collisions: C But this doesn’t readily extend to B multiple point collisions 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 0 CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 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 in the normal , we get: direction, i.e. CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 22/02/2016 19 SIMULTANEOUS IMPULSE EQUATION Rewrite as: or: Putting this into 0 we get 0 or: 1 0 Which can be written as 0 where 1 and 0 Main points to note: multiple impulses considered, For details see: [Giang03] Giang, T. Bradshaw, G. O’Sullivan, C. Complementarity solve a system of equations with an inequality Based Multiple Point Collision Resolution. Eurographics Ireland 2003. CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 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 which is to be solved for 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 then Since 0 0since the impulses ’s must be repulsive 0 for all 0 since for conservation of kinetic energy Complementarity Condition: inner product is zero For detail see [Eberley03] David Eberly Game Physics. Sec. 6.6.2 p 491- Simultaneous Processing of Collision Points. Morgan Kaufmann CS7057: REALTIME PHYSICS (2015-16) - JOHN DINGLIANA PRESENTED BY MICHAEL MANZKE 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):