[ODE] Euler angles from ODE bodies
Adam D. Moss
aspirin at ntlworld.com
Tue Apr 8 00:56:01 2003
Dane Appalsammy wrote:
> However, after a step of the simulation, I need to update the
> orientation of the objects in my 3D package. I am limited to using
> Euler anges to set the pan, tilt and roll angles of each 3D object. How
> do I obtain the Euler angles from the ODE body to update my objects in
> the 3D package?
[..]
> I have done some research and found a quaternion class in the book
> "Physics for Game Developers" by David M Bourg
> (http://www.oreilly.com/catalog/physicsgame/). Example code download is
> available for those interested in the class. The quaternion class
> provides conversions from Euler to quaternion and from quaternion to
> Euler. Can I use this class to create a quaternion from Euler angle to
> set the ODE body orientation and then use the class to convert the
> quaternion retrieved from dBodyGetQuaternion() back to Euler angles to
> update my 3D objects?
See http://www.j3d.org/matrix_faq/matrfaq_latest.html
You can use dBodyGetRotation() to get Euler angles or
dBodyGetQuaternion() to get the rotation quaternion. If you're
lucky then ODE's Euler rotation ordering is the same as your
desired ordering so you can quite simply use that returned
value. Otherwise, consult the above URL.
(My code uses Eulers for most things but the ordering of
rotations around the axes is different from ODE's, so I resort
to deriving the Euler angles from the quaternion in a similar
manner to that mentioned on the above page.)
--Adam
--
Adam D. Moss . ,,^^ adam@gimp.org http://www.foxbox.org/ co:3
"Half of the harm that is done in this world is due to people who
want to feel important. They don't mean to do harm. But the harm
does not interest them." -- T. S. Eliot