• Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

# Rigid Body collision response

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1cnboy0212  Members   -  Reputation: 166

Like
0Likes
Like

Posted 17 August 2012 - 04:45 PM

I am writing a 2D physics engine right now. The dynamics and the collision detection works fine. And I can solve its velocity with impulse, no problem. My questions is: what is a good way to solve interpenetration? I looked up the Box2D slides that talked about sequential impulse, but I think it's assuming that the interpenetration is already resolved (or maybe I got it wrong, since I don't completely understand the whole idea of sequential impulse, if someone could explain, that would be nice). Chris Hecker's paper had nothing over interpenetration either. I know I can simply move both object half of the penetration away from each other, but what about rotation? And most of the time 2 objects that are colliding should have different mass and moment of Inertia, how do i account for that?

### #2Inferiarum  Members   -  Reputation: 631

Like
0Likes
Like

Posted 17 August 2012 - 05:07 PM

The sequential impulse method does not assume interpenetration to be solved. If you check the slides there are some equations with a parameter beta, which controls the speed in which interpenetration is solved. Impulses are applied such that the constraints are fulfilled. Where the constraints also include interpenetration constraints. The parameter beta adds some additional impulse to not only keep the bodies from penetrating further, but to move them apart.

### #3cnboy0212  Members   -  Reputation: 166

Like
0Likes
Like

Posted 17 August 2012 - 05:18 PM

The sequential impulse method does not assume interpenetration to be solved. If you check the slides there are some equations with a parameter beta, which controls the speed in which interpenetration is solved. Impulses are applied such that the constraints are fulfilled. Where the constraints also include interpenetration constraints. The parameter beta adds some additional impulse to not only keep the bodies from penetrating further, but to move them apart.

thanks, i've been wondering for a while now rather sequential impulse only solve for velocity or both velocity and interpenetration. I guess i will look over the slides again

### #4Aressera  Members   -  Reputation: 896

Like
0Likes
Like

Posted 18 August 2012 - 11:57 PM

Let me clarify a few things:

The vanilla sequential impulse method doesn't deal with interpenetration, though it is a natural outcome of discrete time step simulation (even with CCD, since that can't always detect all future penetrations).

In order to resolve penetrations and push intersecting objects away from each other you need to know the current penetration distance D. Most physics engines will use a velocity-based correction method ('bias' velocity). The difference between bias velocity and normal velocity is that bias velocity is only valid for a single frame, it gets reset to 0 after each simulation step. This keeps objects from continuing to move away from each other after they have separated.

The bias velocity is the accumulation of bias impulses computed in order to counteract any penetration, they behave and are computed exactly like regular normal-direction impulses except that they satisfy a different constraint. Most systems will compute the magnitude of the bias impulse for a particular 2-body pair to be enough to push them say 50% of the way apart in one timestep (not 100% because that can cause bouncy simulations).

So:
biasImpulse = 0.5*D*normalMass / timestep;

where normalMass is the combined inertia of the two bodies along the normal direction. The stability can be improved even more if you disregard penetrations smaller than a certain amount (say a few mm).

Thus, your integration loop will look something like this (with a symplectic Euler integrator):
[source lang="cpp"]Vec force = computeForces( object );object.velocity += (force/object.mass)*timestep;object.biasVelocity = 0;findCollisions(); // Finds contact points, normals, and penetration distances.solveCollisions() // This is where the sequential impulse constraints get solved.object.position += (object.velocity + object.biasVelocity)*timestep;[/source]

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS