[ODE] movement force conversion

SJS ode at pulsecode.net
Sun Apr 10 13:37:36 MST 2005

> Now for some reasons I'm setting forces/torques manualy. With forces
> it works idealy all translations given from animation works, but when
> I try with rotations then comes troubles: everything works to fast and
> output rotation looks strange.
> I'm calculating torques like this:
> old_angle = get_euler_angles (old_transform);
> new_angle = get_euler_angles (new_trandform);
> new_ang_vel = (new_angle - old_angle) / delta_time;
> old_ang_vel = body->get_angle_vel ();
> torque = Inertia * (new_ang_vel - old_ang_vel) / delta_time;
> any help?
>  Piotr Obrzut

Using Euler angles like that won't get you the correct angular velocity (are
you just subtracting them in your code, as you are in your pseudo code in
your posting?)

You need to get a "delta quaternion"-- qdelta = (q0^-1 * q1), where 'q0' is
the original quaternion, and 'q1' is your desired quaternion.  Convert
qdelta to axis-angle, multiply the axis by (angle/timestep) to get the
angular velocity that you use above.
qdelta = (q0^-1 * q1)
qdelta -> to axis angle (axis, angle)
new_ang_vel = axis * (angle / dt)

Also, if your quaternions are already normalized (which they probably are),
the inverse is just the conjugate (reverse the signs of the x, y, and z
components).  Conjugate ~q0 is cheaper than inverse q0^-1.


More information about the ODE mailing list