[ODE] Naive Pitch/Roll/Yaw rotation questions
Charlie Garrett
charlie.garrett at gmail.com
Tue Mar 15 15:45:36 MST 2005
If you have a body-relative vector (your roll axis) and want to
transform it
into world coordinates, you want to do a matrix-vector multiply of the
body's orientation matrix and the vector.
z' = R * z
If you want to do this in a low level way, extract the body's rotation
matrix
and call dMULTIPLY0_331. But ODE provides the function
dBodyVectorToWorld,
which will do this for you.
dVector3 zPrime;
dBodyVectorToWorld(turtle.body, 0, 0, 1, zPrime);
If you really want to start with your rotation matrix represented as a
quaternion,
you can convert it to a rotation matrix with dQtoR. But for any body,
ODE maintains
both the quaternion and rotation matrix representations internally, so
dBodyVectorToWorld will work immediately after you call
dBodySetQuaternion.
--
Charlie
On Mar 15, 2005, at 11:08 AM, john rieffel wrote:
> Thanks!
>
> Gabriel's advice was particularly useful. The difficulty with
> "letting the physics take care of it" is that my object is disabled,
> and doesn't interact with the environment other than moving around
> (it's not really an airplane, it's more like a print-head, or LOGO
> turtle, if you must know). I need it to move through discrete
> portions of the space, and to send it roll/pitch/yaw commands.
>
> Here's what I've got for Yaw:
>
> // make the local rotation
> dQuaternion localQ;
> dQFromAxisAndAngle(localQ,0,1,0,rot_angle*M_PI/180);
>
> //get the global rotation
> const dReal *globalQ = dBodyGetQuaternion(turtle.body);
> dQuaternion newQ;
>
> //multiply them and set the result as the new body quaternion
> dQMultiply0(newQ,globalQ,localQ);
> dBodySetQuaternion(turtle.body,newQ);
>
> And for pitch, the only change is to the localQ:
>
> dQFromAxisAndAngle(localQ,1,0,0,rot_angle*M_PI/180);
>
> and for roll:
>
> dQFromAxisAndAngle(localQ,0,0,1,rot_angle*M_PI/180);
>
> This seems to work great! Again, thanks gabriel!
>
> Now - howabout the inverse problem, of sorts: given an object's
> quaternion, how do I find which global axis is currently the object's
> "local" roll axis?
>
> Thanks!
> jr
>
>
>
>
>
>
>
> On Tue, 15 Mar 2005 18:48:48 +0100, Anders Olofsson
> <anders.olofsson at biologigrand.ac> wrote:
>> Let the physics take care of rotation, dont call dBodySetRotation
>> more than to
>> initialize your bodies. Roughly speaking, if you for example want to
>> roll your
>> aircraft add an "up" force on one wing and a "down" force on the other
>> wing. Thats
>> what I do anyway.
>>
>> --Anders Olofsson
>>
>> At 17:25 2005-03-15, john rieffel wrote:
>>> I'm comfortable using dBodySetRotation and dRFromAxisAndAngle in
>>> order
>>> to rotate bodies in the global reference frame, but I'm stumped about
>>> how to rotate objects relative to their own frame of reference. I'm
>>> sure that it's a simple matter of quaternion arithmetic, but it
>>> eludes
>>> me.(kicking myself for never having taken any aero/astro classes, or
>>> graphics classes for that matter).
>>>
>>> Imagine, for instance that my body is an airplane - I'd like it be
>>> able to get it to pitch/yaw/roll. To make things even easier, I only
>>> ever want it to pitch/roll/yaw over a 90 degree angle. For
>>> instance,
>>> if the object's current roll axis is the "z" axis, and its yaw axis
>>> is
>>> the "y" axis, then I want a +90 degree yaw to place its roll axis on
>>> the x axis.
>>>
>>> thanks,
>>> jr
>>> _______________________________________________
>>> ODE mailing list
>>> ODE at q12.org
>>> http://q12.org/mailman/listinfo/ode
>>
>>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>
More information about the ODE
mailing list