# friction

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

## Recommended Posts

How do I stop a sphere from spinning? Everything work just fine except for spin friction or whatever it's called. I have implemented a nice friction model using this. But without damping the sphere never stops rolling or spinning. What would be the most realistic way of dealing with this?

##### Share on other sites
Well I didn't read that link, but what I would do is set up a speed variable that rotates the sphere every frame and every frame lessen the speed a little.

##### Share on other sites
damping you mean ...That is what I have done now. Each time a contact with static friction is handled then the ang velocity is damped 10% ..but I realy want more realistic friction.

##### Share on other sites
damping...dynamic friction, its pretty much the same.

static friction however is a completely other thing, and a tad more complicated at that.

im not really sure what the most practical approach to it is, i believe usually a static contact is formed below a certain speed treshold, which is only broken when the force it supports lies outside of the friction cone.

##### Share on other sites
Well, rolling friction:

http://webphysics.davidson.edu/faculty/dmb/PY430/Friction/rolling.html

and

http://www.roymech.co.uk/Useful_Tables/Tribology/co_of_frict.htm

Similarly, I'd expect the "spinning friction" to result in a friction moment around the spin axis that is simply proportional to the normal force (i.e. the sphere weight). I'd also expect there to be a static/dynamic coefficicent, like for normal linear friction.

##### Share on other sites
I think I know how it works ...well take a look at this code sample and you'll get a better view of what I have done so far:

// static friction is used to prevent motion// and kinetic friction only slows it down.// total velocity at collision pointVector vel; // vel comes from the impulse calculationVector impulse; // the impulse from the collision ofcoursefloat	cofs = 0.8f; // cof staticfloat	cofk = 0.5f; // cof kinetic/////////////////////////////////////////////////// coefficient of frictionfloat cof = cofk;// velocity in tangent directionVector	vt = contact->data[0].normal * (contact->data[0].normal * vel) - vel;// if tangent velocity is low enough use static frictionif ( vt.length2() <= 0.04f ) {	// force relative to collision normal	Vector rfn = contact->data[0].normal * (contact->data[0].normal * b->force);		// the force² pressing the two surfaces togheter (only mg in this case)	float fp = (rfn * cofs).length2();	// the force² that is trying to put the body in motion	float fm = (b->force - rfn).length2();	// if friction greater then prevent all sliding motion	if ( fp > fm ) cof = 1.0f;}// add friction to impulseimpulse += cof * vt * b->mass;

##### Share on other sites
Quote:
 Original post by Eelcodamping...dynamic friction, its pretty much the same.

No, because if you damp by simply multiplying your velocity by some factor (e.g. 0.99) every frame, this is like applying a (dynamic) frictional force that is proportional to the velocity. In reality, the dynamic frictional force is pretty much independant of the velocity.

##### Share on other sites
Incidently glSmurf:

1. impulses only make sense if they're applied immediately - it doesn't (generally) make sense to "accumulate" impulses and apply them all in one go, since the magnitude of each impulse generally depends on the actual velocity - i.e. on all the impulses that happened before it having been applied. Impulses should be applied _outside_ of (i.e. before or after, not during!) the integration of the equations of motion, since they introduce discontinuities that invalidate the assumptions that go into the derivation of the integration scheme (i.e. the Taylor's theorem expansion which is used to derive Euler, Range-Kutta etc schemes)

2. You'd still get friction even in zero-gravity from the impulsive collisions - i.e. a frictional impulse should be derived from the collision impulse. Frictional forces would be derived from forces (e.g. resting contact forces) in a separate step (depends how your system is all put together). So, although I haven't looked really closely, I don't think your code is correct.

##### Share on other sites
Quote:
 Original post by MrRowlIncidently glSmurf:1. impulses only make sense if they're applied immediately - it doesn't (generally) make sense to "accumulate" impulses and apply them all in one go, since the magnitude of each impulse generally depends on the actual velocity - i.e. on all the impulses that happened before it having been applied. Impulses should be applied _outside_ of (i.e. before or after, not during!) the integration of the equations of motion, since they introduce discontinuities that invalidate the assumptions that go into the derivation of the integration scheme (i.e. the Taylor's theorem expansion which is used to derive Euler, Range-Kutta etc schemes)2. You'd still get friction even in zero-gravity from the impulsive collisions - i.e. a frictional impulse should be derived from the collision impulse. Frictional forces would be derived from forces (e.g. resting contact forces) in a separate step (depends how your system is all put together). So, although I haven't looked really closely, I don't think your code is correct.

1. I'm not the first to add friction to the impulse (See the friction demo at http://www.darwin3d.com/gdm1999.htm). Now I know the code is not completely correct but that is why I asked for help. It look quite realistic though (atleast with spheres)

2. my code will give friction in a zero-gravity enviroment too ...but for now mg is the only force affecting the sphere. If I remove gravity and apply forces to the sphere myself it will give an equal result.

The collision realy looks realistic and when the sphere comes to rest, a user force will prevent the sphere from sliding along the plane and it will start to roll. If I disable rolling (angvel = 0,0,0 each frame) then the user force must be greater than mg*cofs (from the link in my initial post) to put the sphere in motion.

mg*cofs realy is (mg+userforce)*cofs

##### Share on other sites
If I may quote myself =)
Quote:
 Original post by glSmurfEverything work just fine except for spin friction or whatever it's called.

It realy works great except for the rolling part.

For instance if I apply an angualar velocity around the z axis (z = up) then the sphere will keep spinning for ever.

Don't realy know if there is friction on a spinning sphere though. Maybe it's the airfriction that slowes it down?

Hmm is there friction (except for air friction) on a rolling sphere?

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 95
• 11
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009635
• ### Who's Online (See full list)

There are no registered users currently online

×