[ODE] Velocity Damping

Joe Ante joeante at liquiddestiny.com
Mon Mar 3 07:01:01 2003


Hi,

For my physics simulation I need linear and angular velocity damping.

I implemented this by adding a force:

float velocityDamp = .9;
float forceScale = (velocityDamp - 1.0F) / timestep;
const dReal* vel = dBodyGetLinearVel (body);
dBodyAddForce (body, forceScale * vel[0], forceScale * vel[1], forceScale *
vel[2]);

And for angular velocity:

float angularVelocityDamp = .9;
float torqueScale = (angularVelocityDamp - 1.0F) / timestep;
const dReal* angularVel = dBodyGetAngularVel (body);
dBodyAddTorque (body, forceScale * angularVel [0], forceScale * angularVel
[1], forceScale * angularVel [2]);



It seems to work fine for linear velocity. Even if set the velocityDamping =
0.
But it causes instability (The objects spin faster until they reach infinite
angular velocity) for angular damping, if I set the angularVelocityDamp to a
low value or even zero.


Is there anything wrong with the angular Velocity damping formula?

Also it would of course be much nicer to have ode support for linear and
angular velocity damping, so that integration could be made implicit and
prevent instability in all cases. This would also be very easy to do.

Inside moveAndRotateBody you just have to multiply the addition on the
postion by the damping factor. Same for the rotation.

Or is there another way to do velocity damping in a stable way?

Joe Ante