6
\$\begingroup\$

I'm currently developing a small 3D impulse-based physic engine for a CS project. It uses GJK for collision detection and is kind of stable at the moment. Nevertheless, I'm not satisfied with my collision response as rigid bodies appear to gain more and more momentum with each bounce, although only under some configurations.

I use Newton’s Law of Restitution (pictured immediately below) for instantaneous collisions with no friction. I checked this formula again and again, and I also checked if the magnitude of the contact normal is 1, and all seems fine. The direction of the bounce and the induced rotation are convincing but the impulse is just sometimes too strong. Newton’s law of restitution

I think my problem may lie within the impulse application part; in my mind, the impulse is the force necessary to separate two touching points of two bodies plus a certain magnitude depending on the coefficient of restitution (0.7 in my tests). I compute an impulse for each detected contact point and apply it at the contact position.

For example if a cube falls right to the floor, there will be 4 impulses, each one at a vertex of the bottom face of the cube. For each of the four contacts, I do something like this:

J = computeImpulse(contact)
A.applyImpulse(J, contact.pos)
B.applyImpulse(-J, contact.pos)

I'm a bit confused. Is this the correct approach, or should I apply half of the impulse to each body? Or, should I rather apply a fraction of the impulse depending of the mass of the bodies? Or, is the problem just somewhere else (e.g., in the formula)?

I don't know if someone has an easy answer for me, as it's a rather specific problem, but thank you for your help. :)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Damn, I am so glad for my previous mechanics exam I only had to know that resitution = speed of separation/speed of approach :) \$\endgroup\$ Jun 18, 2011 at 14:21
  • \$\begingroup\$ If something is incrementing or compounding unexpectedly, it could be related to a variable not being localized properly (e.g., its scope is a bit too global and it's not being reset at the right place in your code). It may be beneficial to check into this type of cause to at least rule this out. \$\endgroup\$ Jun 18, 2011 at 14:29

1 Answer 1

6
\$\begingroup\$

As you already suggested, you have to take the mass of the objects into account to calculate the change of velocity caused by the impulse. Namely, divide the impulse by the mass for each object.

You can find this and much more information in this paper "Impulse-based Dynamic Simulation of Rigid Body Systems" from Brian Vincent Mirtich.

Page 60 shows it in detail:

p       -> impulse
delta_v -> change of velocity caused by the impulse
m       -> mass

     p(t)       = m * delta_v(t)
so:  delta_v(t) = p(t) / m

Here is another paper about it called "A Real-time Capable Impulse-based Collision Response Algorithm for Rigid Body Dynamics" from Florian Schornbaum. You can find that calculation at Page 23.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .