[ODE] Re: Angle Rotation
Alexander Bussman
buxman at telia.com
Sun Jun 13 01:11:36 MST 2004
On Saturday 12 June 2004 23:08, Matthew D. Hancher wrote:
> It would appear that what you are trying to do here is rotate the Geom
> relative to its current position, instead of just setting its absolute
> orientation. Adding angles, like you suggest above, only works if
> the two rotations (in this case, the one you are trying to apply and
> the implied one that puts the Geom in the orientation it's in now) are
> both rotations about the same axis. In general this isn't going to be
> the case.
>
> The tool you want is quaternion multiplication; ODE supports it through
> the function dQMultiply0(result, q1, q2), which sets result = q1 * q2.
> The order of multiplication (which quaternion is q1 and which is q2)
> depends on whether your axis of rotation is measured in the global
> coordinate system or the current local coordinate system of the Geom.
> I'll assume it's the former. In that case you want something like:
>
> dQuaternion q, q1, q2;
> dGeomGetQuaternion(obj->GetGeom(), q2);
> dQFromAxisAndAngle(q1, ax, ay, az, angle);
> dQMultiply0(q, q1, q2);
> obj->SetQuaternion(q);
>
> Hopefully something along those lines will do the trick for you.
> If you're more familiar with rotation matrices than with quaternions,
> note that the way you combine rotations by multiplication is the same
> in the two cases.
>
> mdh
>
> Matt Hancher
Thanks Matt, that solved my problem!
I need to look into some quaternion math, it seams like quaternions is more
then just neat.
// Alexander Bussman
More information about the ODE
mailing list