Started by Mar 24 2011 02:31 AM

,
13 replies to this topic

Posted 24 March 2011 - 02:31 AM

Hello. For normal impulse I used Chris Heckers papers. All works fine, but formula don't take friction into account. I believe that there's equivalent for friction (not just tangent velocity * cof) but I couldn't google it.

Posted 24 March 2011 - 10:28 AM

Friction is complicated. In the naive sense, rigid body dynamics with a Coulombic friction force (which is what you are describing) is not even solvable. The classic and ancient example of this is Painleve's paradox, which has remained unresolved until relatively recently.

As a result, if you want to do friction using the classical Coulomb approximation, you are in for a very rude awakening (as I am sure you have just discovered!) A more well posed way to formulate friction is to use the principle of maximum dissipation. This basically says that the friction force will try to reduce the velocity (ie kinetic energy) as much as possible in the tangent direction to the collision impulse force, subject to some constraints on the magnitude of the velocity. This constraint forms a "cone" shape, and so it is commonly called a "friction cone". To solve this constraint, many LCP solvers use a piecewise linear approximation of the friction cone to ensure the constraint is not violated. For a more precise and careful discussion of these issues, there are some really great papers by David E. Stewart. Here is a good one to start with (in my opinion):

David E. Stewart, (2000) "Rigid Body Dynamics with Friction and Impact", SIAM Review PDF

Posted 24 March 2011 - 11:38 AM

Just take the contact point velocity, V and normal N, form the tangential velocity

T = V - V.N*N

Then create an impulse to remove some portion of this velocity in the same way you did to remove the normal velocity

Cheers, Paul.

T = V - V.N*N

Then create an impulse to remove some portion of this velocity in the same way you did to remove the normal velocity

Cheers, Paul.

Posted 24 March 2011 - 06:26 PM

You may find my post useful:

http://www.gamedev.net/topic/596977-collisions-involving-friction-explained-partly/

I wrote up a description of Brian Mirtich's algorithm. For 2D (non-resting) collisions there isn't a single formula but there's a quick algorithm. For 3D collisions the algorithm involves numeric integration which may be too slow for your application.

http://www.gamedev.net/topic/596977-collisions-involving-friction-explained-partly/

I wrote up a description of Brian Mirtich's algorithm. For 2D (non-resting) collisions there isn't a single formula but there's a quick algorithm. For 3D collisions the algorithm involves numeric integration which may be too slow for your application.

Posted 25 March 2011 - 12:22 AM

In 3d, you usually need 2 tangential direction, which must exist even if the tangential velocity is zero. and then, the impulse calculation is similar to normal impulse calculation, just change the normal vector with tangential vector. And then you relate the friction impulse with the normal impulse

Posted 25 March 2011 - 01:44 AM

Thanks everyone. I was affraid that it's complicated and so it is. I'm certainly investigate papers that you're link, but for now I think I'll take approach that **wildbunny** and **Bow_vernon** said.

And one more question - is it OK that if I take COF (coefficient of friction) zero (like with COR, 0 - is 'full' friction, i.e. no sliding), but tangent velocity decreases not by 100%, but only by some part? I've used same formula as for normal impulse - only normal was changed to tangent direction...

Update: also notice some problem - if two objects fall down (their velocities is like [0; 10] vector) and are close one to another (so collision occurs every frame) then friction decreases velocity and bodies become to fall slowly .

And one more question - is it OK that if I take COF (coefficient of friction) zero (like with COR, 0 - is 'full' friction, i.e. no sliding), but tangent velocity decreases not by 100%, but only by some part? I've used same formula as for normal impulse - only normal was changed to tangent direction...

Update: also notice some problem - if two objects fall down (their velocities is like [0; 10] vector) and are close one to another (so collision occurs every frame) then friction decreases velocity and bodies become to fall slowly .

Posted 25 March 2011 - 05:57 AM

Well you've arrived there. with 0 CoF the object should slide, you gotta relate the friction impulse magnitude with the normal impulse, like:

fMax = fN * CoF

then you clamp the friction so its value is between [-fMax,fMax]. Anyway, how did you calculate the friction impulse? can you show some code?

fMax = fN * CoF

then you clamp the friction so its value is between [-fMax,fMax]. Anyway, how did you calculate the friction impulse? can you show some code?

Posted 25 March 2011 - 06:35 AM

Normal impulse:

e -> f; //cof

n -> t; //tangent normal

It's hard to understand - why shoud we multiply fMax = fN * CoF? How to achieve full friction (i.e. no slide) in this case - suppose I want bodies to stop sliding immidiatelly after first contact?

var jNnum:Number = -(1 + e) * (vab.dot(n)); var jNdenom:Number = bodyA.invMass + bodyB.invMass + rap.cross(n) * rap.cross(n) * bodyA.invInertia + rbp.cross(n) * rbp.cross(n) * bodyB.invInertia; jN = jNnum / jNdenom;Friction impulse is all the same. Only changes are:

e -> f; //cof

n -> t; //tangent normal

It's hard to understand - why shoud we multiply fMax = fN * CoF? How to achieve full friction (i.e. no slide) in this case - suppose I want bodies to stop sliding immidiatelly after first contact?

Posted 25 March 2011 - 07:05 AM

What I do(has been simplified)

jn = kN * -vn; //no bounce jn = Max(0,jn); //no pull fMax = jn * CoF; jt = kT * -vt; //full stop jt = Clamp(jt, -fMax, fMax);Oh and read erin catto's ppt for more info, anyway. Sorry if I didnt help, Im confused @.@

Posted 25 March 2011 - 10:13 AM

Ok. I think I got it. Thank you.

Are you working in 3d, or 2d? 3d is slight more complex than 2d, but still doable

Cheers, Paul.

Posted 25 March 2011 - 01:52 PM

Volgo, what formula did you end up using and how is it working out ? I'm thinking about adding friction to my 2D simulator as well.

Thanks.

Thanks.

Posted 26 March 2011 - 01:54 AM

According to Erin Catto presentation GDC2006 and as **Bow_vernon** said, for 2D friction can be count like this:

1. Get normal impulse - see post #8.

2. Get tangent impulse:

3. You need to clamp friction impulse:

4. Get total impulse as:

1. Get normal impulse - see post #8.

2. Get tangent impulse:

var jTnum:Number = -vab.dot(t); var jTdenom:Number = bodyA.invMass + bodyB.invMass + rap.cross(t) * rap.cross(t) * bodyA.invInertia + rbp.cross(t) * rbp.cross(t) * bodyB.invInertia; jT = jTnum / jTdenom;

3. You need to clamp friction impulse:

if(jT < -jN * cof || jT > jN * cof) { jT = jN * cof; }

4. Get total impulse as:

j = n * jN + t * jT