6
\$\begingroup\$

In my amateur 2D rigid body physics engine for a game I react on collisions between two bodies with an impulse j (formula 11) as explained here.

To calculate this impulse I need one contact point P between the two colliding bodies and the perpendicular normal n of the edge the contact point of A is colliding with.

img
(source: myphysicslab.com)

That works wonderful. At least as far as I don't have multiple contact points. But what to do if this is not the case?

Should I calculate an impulse for each of the contact points or is there a way to reduce multiple contact points to a single one if this is a correct solution?

As an example I have following two situations, where two bodies collide. The x denotes the center of mass and the tips of each triangle pointing down an vertice of A that is colliding with the edge underneath:

    _____________________                        _____________________
   |                     |                      |                     |
A  |          x          |                   A  |                     |
   |    _____________    |                      |         x  ______   |
    \  /             \  /                       |           /      \  /
     \/               \/                        |    __    /        \/
    _____________________                        \  /  \  / ___________ 
   |                     |                        \/    \/ /           |
B  |          x          |                   B   _________/    x       |
   |_____________________|                      |______________________|

In the left situation its intuitively pretty clear that I can reduce the two collision points to one exactly in the middle between both since the this would be collinear to both centers of mass. Also as normal n the perpendicular vector of the edge both vertices are colliding with can be chosen.

But what to do in the right situation?

\$\endgroup\$
6
\$\begingroup\$

Your solver needs multiple iterations (aka sequential impulse) over its contacts.

Treat each contact point independently and calculate the impulse to resolve its contact constraint for that iteration. This may cause previously resolved contact points to be pushed back into the colliding object, but not by as much as the initial penetration.

Perform multiple iterations over the contacts. Each iteration will get you closer to the correct result. The number of iterations you use is something you need to tweak based on your needs and performance envelope and how numerically stable your solver is.

Here is an article by Allen Chou on sequential impulse solvers. You should read his whole series on game physics.

\$\endgroup\$
  • 1
    \$\begingroup\$ This GDC presentation from Erin Catto clearyfies a lot of the math and context. \$\endgroup\$ – Sebastian Barth Mar 4 '14 at 17:57
  • 1
    \$\begingroup\$ And this is the corresponding paper to the presentation. \$\endgroup\$ – Sebastian Barth Mar 4 '14 at 22:30
  • \$\begingroup\$ Another presentation from Richard Tonge (Nvidia) also easy to understand. \$\endgroup\$ – Sebastian Barth Mar 5 '14 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.