[ODE] Damping

Nate W coding at natew.com
Thu Mar 27 14:42:01 2003


The following question comes up quite a bit, so I think the answer should
go into the Wiki FAQ.  

--

Q: How do I stop things from rolling off into infinity, or pendulums from
swinging forever?

A: You can accomplish that pretty well with damping.  It works about like
this:

1) Compute the velocity of the object that's supposed to slow down.

2) Multiply that velocity by a "damping coefficient." This is typically a
small number, like 0.01 for example.

3) Change the sign on the velocity vector, and you get your damping force.

4) Apply that force with dBodyAddForce.

Tweak the damping coefficient to get the object to slow down at the
rate you want.

You can also do the same thing with angular velocity rather than plain old
linear velocity, and dBodyAddTorque rather than dBodyAddForce.

For air resistance, it would be better to use the cube of the velocity,
because that's how drag works in reality.  The force should also be
applied at the objects, aerodynamic center rather than at the body
location.  The center of the object's cross section would probably be
close to the aerodynamic center, at least for non-engineering purposes.  
In any case, dBodyAddForceAtRelPos will allow you to apply the force at a
specific point in the body's frame of reference.

--

Did I get it right? :-) Any comments before I put this into the FAQ?

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com