Sign in to follow this  

Impulse with friction

This topic is 4836 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

Hi. I'm messing around with impulse based physics system, and already got frictionless response working. I'm using the following formula to calc it: j = - (1 + e) * (v . n) / { M1 + M2 + I1 * ((r1 x n) x r1) + I2 * ((r2 x n) x r2) }; where: j - impulse (scalar) e - restitution coefficient v - relative velocity n - collision normal M - body masses r - contact points (relative to mass center) I - inverse body inertia tensors So for frictionless response i simply apply (n * j) impulse to the body. I've looked at every doc i've found on inet, but still can't figure how to add the friction. Here on forums i've found that i should apply this impulse: ( n * j + t * f * j ). Where t is friction tangent and f - friction coefficient. It seems to work ok when f is lower than ~0.7, but explodes after it gets larger. Not to mention that i can't get a rolling box, it always seems to slide on the side and stop. I guess that the (n * j) part should get smaller as the friction grows. I've tried a simple change: (n * j * (1 - f) + t * f * j) and it adds a little more real behavior (the box is sliding/rolling etc), but still explodes with higher friction coefficient. So how do you guys do it correctly? Any ideas?

Share this post


Link to post
Share on other sites
I'm using the friction model described in this paper.

However, you are maybe more Maths inclined than I am, and might be able to tell me if (indice T) in their impulse calculations has any meaning... I'm used to it meaning transpose but first, it's not working and then what would a vector transpose be?

Share this post


Link to post
Share on other sites
I'm just doing what you are already doing at the moment. My physics stuff is not advanced at all. And yes, it does not like high coeffs of friction. I'm also using a euler integrator, most of the times at 30 Hz, which does not help.

I would recommend that paper if I actually got off my arse and tried to implement the stuff in it. All I can say, it looks good. Should be fun to try it, with say, just a ball rolling on a plane at first, and see if I can get it right.

Share this post


Link to post
Share on other sites
i can derive every aspect of the equation above (i did this on my own, with a lot of extra work on my part because physics for game developers sucks)...basically, for friction, you quantify the friction force similarly to the equations above (instead of components in the direcdtion of the normal, you use components in the direction of the tangent), then you make sure it is proportional to the normal impulse, and the coefficient of friction.

then, you just apply the tangential impulse, which will change the linear and angular velocities.

Share this post


Link to post
Share on other sites
b34r, vector transponation just "rotates" vector 90 degrees. Thus, if you have vertical vector and transpose it, you will get horizontal vector. This has only meaning when matrix is multiplied by vector or vice versa.

Share this post


Link to post
Share on other sites
shadow, do you have something like this in your mind:

n - at first collision normal
t - friction tangent normal
f - friction coefficient

n = normalize(n + t * f)

j = - (1 + e) * (v . n) / { M1 + M2 + I1 * ((r1 x n) x r1) + I2 * ((r2 x n) x r2) };

and then apply (n * j) impulse? Not sure if the above thing makes any sense, but it works much better, and doesn't explode with higher friction coefficients and seems more stable in different situations.

Share this post


Link to post
Share on other sites
trinka, I think we are somewhat on the same wavelength. You've got the right idea, now that you've added the tangent vector direction (which means it is normalized, as is the normal), but there's a problem with this equation:

EDIT: I think the crucial thing you might not have realized is that when there is a collision, there are really 2 impulses that must be considered: the impulse along the normal, and the impulse along the tangent. They are perpendicular to each other, and both are prevalent. The magnitude of the tangential impulse is proportional to the coefficient of friction, the magnitude of the impulse along the normal direction, and also the relative velocities of the colliding points (which is the same equation you have posted for quantifying the magnitude of the impulse along the normal direction).

Quote:

j = - (1 + e) * (v . n) / { M1 + M2 + I1 * ((r1 x n) x r1) + I2 * ((r2 x n) x r2) };

You see, you've got, for example, v . n, which means these are components in the direction of the normal. You need a method to quantify the magnitude of the impulse along the tangent. What you need to do looks something like this:

1-compute magnitude of impulse in direction of normal
2-use the same equations as above, but instead of components in the direction of the normal, they must be *components in the direction of the tangent vector*. So, instead of v . n, it's going to be v . t.
3-take the result from part 2, and multiply it by the magnitude of the normal impulse, and then by the coefficient of friction. This makes sense because whenever you push down harder on something, the force of friction also increases
4-at this point you have the magnitude and direction of the tangential force, so just apply the force which results in a change in linear and angular velocity, in the direction of the tangent.

Share this post


Link to post
Share on other sites

This topic is 4836 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