friction

Started by
26 comments, last by glSmurf 18 years, 10 months ago
Just realized that there are no MAX kin fric as I thought...velocity change the kinetic friction abit but not enough to be mentioned how much in the literature.

kinectic friction = cofk * N
(but not greater than the force that is trying to move the body)

so in my code:
friction = cof * vt * mass

cof must be set in proportion to vt so that the impulse will give the correct result.

[Edited by - glSmurf on June 15, 2005 9:23:41 AM]
Advertisement
...// if tangent velocity is low enoughif ( vt.length2() <= 0.04f ) // static friction model{ ...}else // kinetic friction model{  // total force  Vector rf = b->acceleration.linear * b->mass.total; // (b.force - b2.force);  // force relative to collision normal  Vector rfn = contact->data[0].normal * (contact->data[0].normal * rf);				  // kinetic force  real kf = (rfn * cofk).length2();  // compute an impulse that give the correct effect  // or use a force b->apply_force(collision_point, (rfn * cofk));}



Static friction can easily be solved using an friction impulse with cof 1. But I have no clue how to solve kinetic frition in a correct way using impulses. I could apply it as a force(not impulse).

force b->apply_force(collision_point, vt.normalized() * (rfn * cofk).length());

[Edited by - glSmurf on June 15, 2005 10:34:18 AM]
Quote:Original post by glSmurf
Static friction can easily be solved using an friction impulse with cof 1. But I have no clue how to solve kinetic frition in a correct way using impulses. I could apply it as a force(not impulse).


In a simulator:

linM += force*dt // Force application. Will be applied over time. d(mv) = F*dt
linM += force // No time scale, apply 100% immediately: impulse. Required for collisions; can also be used for friction and multiple contacts. d(mv) = F

If you have a routine such as pointMomentumInDir():

Quote:
// Particle
// normalDir must be unit length (normalized).
Vec3 pointMomentumInDir(Vec3 vel,float mass,Vec3 normalDir,float coeffRest) {
return mass*(1+coeffRest)*normalDir*(normalDir dot vel)
} // pointMomentumInDir

// ^ = dot
// % = cross

// RigidBody
Vec3 pointMomentumInDir(const Vec3 & dir,const Vec3 & ip,flt coeffRest) const {
Vec3 rp; // relative position
Vec3 pVel = pointVel(ip,rp);
flt vRel = dir ^ pVel;
if (vRel >= 0.f) return Vec3(0); // Resting or moving away
Vec3 rpDir = rp % dir;
flt angM = dir ^ (scaleLocal(rpDir,rotMassIdealInv,(Mat3 &)pos) % rp);
// flt angM = dir ^ (scaleLocal(rpDir,rotMassInv,(Mat3 &)pos) % rp);
// flt angM = dir ^ ((rotMassInvWorld ^ rpDir) % rp);
flt numerator = (-(1.f + coeffRest))*vRel;
flt j = numerator / (linMassInv + angM);
return dir * j;
} // pointMomentumInDir

You can model both static and kinetic (dynamic) friction using the concepts of momentum and impulse. Again, in a simulator, force is an impulse scaled by time (and in general, F = d(mv)/dt), d(mv) = F*dt. In your API you'll apply changes in momentum either through time (as a force) or immediately (as an impulse: no time scale).

Example code and impulse/momentum equations to compute static and kinetic (dynamic) friction using the concepts of momentum and impulse:

Practical implementation of friction for simulators.

Momentum and Impulse concepts in action (demo, videos).

These concepts are easily applied to any type of integration scheme (Euler, Verlet, RK2, RK4, etc.).
Quote:Original post by John Schultz
In a simulator:

linM += force*dt // Force application. Will be applied over time.
linM += force // No time scale, apply 100% immediately: impulse. Required for collisions; can also be used for friction and multiple contacts.

Here we go again mixing the bananas, the oranges and the coconuts, all in one nice juicy fruit punch.

Quote:Original post by John Schultz
Example code and impulse/momentum equations to compute static and kinetic (dynamic) friction using the concepts of momentum and impulse:

Practical implementation of friction for simulators.

Momentum and Impulse concepts in action (demo, videos).

These concepts are easily applied to any type of integration scheme (Euler, Verlet, RK2, RK4, etc.).

I wonder for and impulse can be integrated. What would the area of a spike.
and the battle continues... why post anonymously all the time? Maybe more people would listen to you if you didn't.
Quote:Original post by John Schultz
In a simulator:

linM += force*dt // Force application. Will be applied over time. d(mv) = F*dt
linM += force // No time scale, apply 100% immediately: impulse. Required for collisions; can also be used for friction and multiple contacts. d(mv) = F


Thanks again John .. it realy can't be that hard. too much sun for me today I think. Applying kinetic force as a force didn't do it for me.. it worked pretty well decreasing the linear vel, but some bug prevented the sphere from rolling at more than medium velocity =/ The original code in my second or third post is the most realistic so far, and after reading through a few more articles it's time to pick up the pencil and go back to the drawing board again.

Quote:Original post by glSmurf
cof must be set in proportion to vt so that the impulse will give the correct result.


Just one thing - the word "coefficient" is generally used to mean some kind of constant in an equation. For example:

coefficient of friction, where the value is constant for any pair of materials

coefficient of drag - a constant for a given shape in a given fluid, relating drag force to some power of the speed

coefficient of lift... of restitution.... of diffusion etc

People (including yourself in a couple of weeks when you look at the code again!) will get confused if you use the word coefficient to include some parameter/variable that changes all the time.
yeah I know =) ...the var name 'cof' wasn't that suiting. should have given it another name. It is still under construction though, even though I have figured out how to solve my last problems. (got stuck watching mythbusters all afternoon.. damnit!)

I gonna have a go at it again now ...and then add a box primitive to the simulation to see if the friction looks realistic on that too. (as if that's the only reason for adding it =p)

Thanks all for giving me a little more insight on the subject.

This topic is closed to new replies.

Advertisement