Sign in to follow this  

Impulse based physics: Derivation of Impulse

This topic is 3738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've finally managed to get my first interactive rigid body simulation to work properly. Avi Not entirely sure if the result is correct though (I could only compare it with 3ds max reactor(havok), but it doesn't have ellipsoidal bounding volume). Do you think the result is acceptable (realistic enough)? Chris Hackers articles were more than helpful, although I don't understand the impulse derivation entirely. I've also referred to the book "Physics for Game Developers" For rigid bodies that cannot rotate, the relative velocity (for center of masses) after impact is proportional to the relative velocity before impact. This is justifiable as no angular effects are considered and total system momentum is dependent only on linear velocities. So the total momentum is conserved. However with angular effects, the impulse derivation uses the same principle of keeping the relative velocities before and after impact proportional, but this time the velocities at the point of contact are considered. How will such an impulse conserve total angular momentum? Am I missing something here? Thanks for your help.

Share this post


Link to post
Share on other sites
What impulse are you refering to? The general solution goes as follows:

1) You integrate the system forward in time without considering the constraints
2) Now you seek impulses P such that post-velocities v' satisfy the velocity constraints. Note that P or v are vector quantities containing all velocities of the rigid bodies, e.g. v = ( v1, w1, ..., vn, wn ) where v is the linear and w the angular velocity vector. In terms of the formulation this is relatively simple:


a) Apply an impulse P...
v' = v + M^1 * P

b) ...such that the post-velocities satisfy the velociyt constraints...
J * v' = 0

c) ... also knowing the direction of the impulse...
P = Transpose( J ) * lambda


J is the Jacobian matrix of the constraints and lambda are the Lagrange multipliers. The Jacobian is found through derivation of position constraint. If you look at Shabana or Erin Catto's slides the ususal way goes like this:

C(p1, R1, p2, R2) = 0
dC/dt = del_C/del_x * dx/dt + del_C/del_t

here del means the partial derivative. The formula above is the total differential of the constraint equation. This looks awful, but in practise this is quite easy. Take for example the distance constraint between two particles:

C(p1, p2) = |p2 - p1| - L0 = 0

dC/dt = (p2 - p1)/|p2 - p1| * (v2 - v1) = u * v2 - u * v1 = ( -u u ) * Transpose( v1 v2 ) and u being defined as u = (p2 - p1)/|p2 - p1|

So in order to compute the impulses you usually do the following:

1) Write down the position constraint
2) Build the time derivative and find the Jacobian by inspection.
3) Using the formulas from above your impulse is J * M^-1 * Transpose( J ) * lambda = - J * v
4) P = Transpose( J ) * lamba

As an execrise you can take the non-penetration constraint you were actually asking about I belive:

C(p1, R1, p2, R2) = ( (p2 + r2) - (p1 + r1) ) * n where n is the contact normal and r point from the COM to the contact point. You should be able to define the Jacobian and the collision "matrix" (actually a scalar here) which is identical to all the formulas you find in the references (e.g. Baraffs Siggraph lectures)


HTH,
-Dirk





Share this post


Link to post
Share on other sites
I was referring to the impluse derived in Chris Hecker's article
http://chrishecker.com/images/e/e7/Gdmphys3.pdf

Thanks for the explanation, but I couldn't get much of it. Guess my mathematics is not up to that level yet. Can you please suggest some reading material that I could study?

The method you describe seems to be able to handle multiple simultaneous contacts, something that Hecker's articles don't describe. This certainly is the next exercise. Could you kindly suggest some resources (Books, papers ..)

Thanks

Chandan

Share this post


Link to post
Share on other sites
I gave recommendations in these links, both material and how to study it:

http://www.gamedev.net/community/forums/topic.asp?topic_id=462905&whichpage=1�
http://www.gamedev.net/community/forums/topic.asp?topic_id=456919&whichpage=1�

The most valueable resource in my opinion is Box2D and its associated slides from Erin Catto. See www.gphysics.com - I really learned very much from understanding the Box2D code and porting it to 3D and reading the presentations. Just give yourself some time to learn the stuff and don't be to impatient. From the video I saw you already did a good job :-)

If you have questions you might consider posting them on the Bullet forum!

Share this post


Link to post
Share on other sites
What Dirk is talking about is a little different from the impulse based methods. The math behind it is rather complex comparatively, too. It's the ultimate proper way to simulate physics, but it's considerably slower than impulse based methods because you have to invert a matrix. That's O(n^3) where n is the number of constraints.

Compared with O(nlogn) (sometimes called O(n) in practice, since the growth is so slow) for impulse based engines, it's just not practical for large systems, so impulse based methods have their place.

To answer your original question:

Quote:
Original post by chand81
However with angular effects, the impulse derivation uses the same principle of keeping the relative velocities before and after impact proportional, but this time the velocities at the point of contact are considered.
How will such an impulse conserve total angular momentum?
Am I missing something here?

Thanks for your help.


Angular momentum and linear momentum are basically "orthogonal", they can be treated seperately. Hecker's method that doesn't take into account angular effects is still correct, just incomplete. That's important to understand. The equations for linear momentum aren't going to change when you add in angular effects, aside from effecting the (linear) collision velocities of the contact points.

When Hecker adds in angular effects, it's done in two places. First, angular velocity changes the (linear) velocity of every point on a body that's not the center of mass. This is through the familiar "velocity = radius cross angular velocity".

The two contact points can now be looked at in isolation. All that needs to happen to happen is that the points bounce off of each other and obey the coefficient of restitution with their final speeds. Just like with a strictly linear collision. We try to find the impulse (j) that accomplishes this.

As I stated before, the linear momentum works the same here as it did before. No extra terms or anything like that are added. The neat things comes from the knowledge of how to apply the collision impulse to the angular momentum of each body. The strictly linear collision code basically assumes that the bodies collide dead on, and so don't cause any spin. So this new method is the more general case.

If you remember that "torque = force cross radius", you should be able to see that the collision impulse could also produce torque on the body. The odd thing that throws alot of people is that wether the collision is dead center or barely glancing, the change in linear momentum is the same.

So the changes in angular momentum to each body are actually determined indirectly. The real goal is to control the collision points' velocities. Changes to angular momentum occur as a byproduct of the collision impulse happenining off-center.

I hope I answered your question. It wasn't a very formal explanation. If you really wanted to see how angular momentum is conserved mathematically, you could show that the collision impulse depends on the angular momentum of both bodies, and then feeds-back to the angular momentum of either body. But the math might get a little overwhelming unless you have access to something like Maple or Mathematica.

Share this post


Link to post
Share on other sites
Quote:
What Dirk is talking about is a little different from the impulse based methods.


No, actually it is not :-). I just described a general solution how to compute arbitrary momemtum conserving impulses as a function of the constraint function. Whether you solve for all impulses with a direct method or if you compute sequential impulses, it doesn't matter. It all depends on the number of constraints you consider. If you just consider *one* non-penetration constraint the formula give you exactly the formula found in Baraff or other common papers. Of course you could try solve a full contact manifold with up to four points using e.g. Dantzig method...

Share this post


Link to post
Share on other sites
Quote:
Original post by DonDickieD
Quote:
What Dirk is talking about is a little different from the impulse based methods.


No, actually it is not :-).


Let me rephrase. Constraint minimization uses more complex mathematics (partial derivatives and matrix inversion) than a more naive pairwise collision response system. One requires fairly advanced mathematics to understand, while the other doesn't require more than high school algebra to implement.

They both do effectively the same thing. Using a Jacobian is the more "proper" method, but is computationally more expensive, and more difficult to wrap your mind around if you don't have the proper background.

That's all I meant. I thought your explanation was very good, but I could see how it would leave a hobbyist a little confused. I think it's better for most programmers to stick with a simpler pair-wise system until/unless they really want to get into heavy duty stuff. I didn't get that impression from the OP.

Share this post


Link to post
Share on other sites
Quote:
Original post by Numsgil
wether the collision is dead center or barely glancing, the change in linear momentum is the same.


I'm not sure I can agree on that statement.
Although the equation for change in linear velocity is the same even with angular effects considered, the equation for impulse J changes drastically. It now depends on the collision point. So for a dead center collision J will be large and for a barely glancing collision J will be very small unless there is friction (in which case the direction of J changes). And when J changes, so does the change in velocity/momentum.

My question still remains unanswered though: Is there a proof that the total angular momentum (or the total energy) is preserved if we have COR=1?
Or even better, can we derive J based on the principle of conservation of angular momentum?

P.S. I'm always on the lookout for study material - there is always college after school ;-)

Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by chand81
Quote:
Original post by Numsgil
wether the collision is dead center or barely glancing, the change in linear momentum is the same.


I'm not sure I can agree on that statement.
Although the equation for change in linear velocity is the same even with angular effects considered, the equation for impulse J changes drastically. It now depends on the collision point. So for a dead center collision J will be large and for a barely glancing collision J will be very small unless there is friction (in which case the direction of J changes). And when J changes, so does the change in velocity/momentum.


Hmm, I see your point. I made that statement remembering my college physics instead of looking at the equation being used. I'm pretty sure I'm right-- the only thing that changes the corrective impulse is the velocity of the contact points. I'm guessing maybe the position terms cancel in some way, but I don't see how. Either that, or I've been wrong for a long time ;)

Also, if the point of contact mattered beyond determining linear velocity caused by rotation (and maybe the collision normal), wouldn't Hecker have a different equation for 3.6? So I'm not sure. And I'm a little too tired for a formal examination.

As far as conservation of angular momentum... This page might be useful. It's talking about basically the same sort of collision response system. The notation is a little dense, but they show how angular momentum is conserved.

I'm afraid this might be a case where I know a subject well enough for my own purposes, but not well enough to teach it :P

Share this post


Link to post
Share on other sites
Quote:
They both do effectively the same thing.


That was all I wanted to say as well :-) The problem with the pairwise impulse formulation is that you usually get stuck when you want to deal with several simultaineous collisons/contacts. I find it hard to extend the method. It is indeed the best method to understand the problem. You are right, I should have started with this...

I digged out a nice paper for the derivation of the angular impulse. (No Jacobian and the like). I found it very helpful when I began learning this stuff:

http://www.essentialmath.com/AngularImpulse.pdf


I also recommend their book and you can find a lot of other useful stuff on their side - also on physics. See their page and browse around...

http://www.essentialmath.com


HTH,
-Dirk

Share this post


Link to post
Share on other sites
Quote:
Original post by DonDickieD
I digged out a nice paper for the derivation of the angular impulse. (No Jacobian and the like). I found it very helpful when I began learning this stuff:

http://www.essentialmath.com/AngularImpulse.pdf
-Dirk


This is the same derivation as outlined in Chris Heckers articles.

From the paper
=======================
Since momentum is conserved, we can relate incoming and outgoing linear momentum
by:
=======================

What about the angular momentum? Wouldn't that need to be conserved as well?

If a body has linear as well as angular velocity, its total momentum would be linear momentum + angular momentum, isn't it?

Share this post


Link to post
Share on other sites
Don't nail me on this, but from the back of my had this goes similar as described above:

a) We search a (non-centric and frictionless) impulse P such that linear and angular momentum are conserved...

(1) v1' = v1 + M1^-1 * P1
(2) w1' = w1 + I1^-1 * L1 = w1 + I1^-1 * (r1 x P1)

(3) v2' = v2 + M2^-1 * P2
(4) w2' = w2 + I2^-1 * L2 = w2 + I2^-1 * (r2 x P2)

b) ... such that the post-velocities satsify some kinematic constraint, e.g. here I choose the relative post-velocity at the contact along the contact normal n to be zero (aka plastic collision)...

(5) ( v2 + w2 x r2 - ( v1 + w2 x r2 ) ) * n = 0

c) ... also knowing the impulse direction (in the direction of contact normal n)
(6) P1 = -j * n
(7) P2 = j * n


Plugging all the equations together should give you the desired result. Basically we have 7 unknowns (v1', w1', v2', w2', P1, P2, j) and 7 linear indepedant equations. This should be a nice exercise to solve.


HTH,
-Dirk

Share this post


Link to post
Share on other sites
Quote:
Original post by DonDickieD
a) We search a (non-centric and frictionless) impulse P such that linear and angular momentum are conserved...

(1) v1' = v1 + M1^-1 * P1
(2) w1' = w1 + I1^-1 * L1 = w1 + I1^-1 * (r1 x P1)


Thats it, I see how it works now!
At collision we add momentum (linear P1 & angular L1) to the colliding bodies in order to keep them from penetrating. By adding equal and opposite momentums to the two bodies, we make sure that we do not change the total momentum (linear as well as angular) of the system.

Thanks Dirk, the L1 (angular impulse) in your 2nd equation made me think correctly :)

Share this post


Link to post
Share on other sites

This topic is 3738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this