[ODE] Problem with rolling

gero.mueller@cloo.de gero.mueller at cloo.de
Sat Oct 7 11:40:03 MST 2006

```As you say yourself: you have to put the yaw to the end of the matrix
multiplications.
Try to set yaw to zero in the dRFromEulerAngles-function. and create
another quat with pitch and roll set to zero. then multiply the yaw
quat from the right t the oitch/roll quat and continue.

Thats what i would do.

Good luck
Gero
p.s. my first post here :-P

Lubomir Kazasov <nebemore at gmx.net> schrieb:

>   hello
>
> i'm trying to rotate body in my scene, but there is a problem with
> rolling.
>
> I store the current rotation of the body in quaternion (rotQuat). by
> key-input i compute the new rotation using Euler Angles and store the
> result in another Quaternion (newQuat).
>
> After that i multiply the quaternions:
>
> /bodyQuat = newQuat * bodyQuat;/(1)
>
> and apply the bodyQuat on the body using /dBodySetQuaternion/. When I
> pitch and after that yaw, the body yaws around the local z
> Axis(x,y,z-up).it's normal. But I want the body to yaw always around
> the world z Axis. So i changed the order in (1) to
>
> /bodyQuat = bodyQuat * newQuat ;/(2)
>
> and it works for yaw and pitch perfect. The big problem is the roll.
> When I roll after that is everything wrong. (in both cases)
>
> What is the best way to become the body yawing always around the
> global z-axis independent from the pitch and the roll. By pitch and
> roll the body have to rotate around local axes x(for pitch) and y(for
> roll).
>
> Any ideas?
>
> here a piece of code:
>
> dMatrix3 matrixEuler;
> dRFromEulerAngles (matrixEuler, stepPitch, stepRoll, stepYaw);
>   //stepPitch/Roll/Yaw are set by user input. for examlpe stepPitch=0,
> stepRoll=0, stepYaw=angle;
>
> //transform matEuler to Quaternion
> dRtoQ(matrixEuler, newQuat);
>
> //multiply like in formula (2)
> dQMultiply0(bodyQuat, bodyQuat, newQuat );
>
> //set new Quaternion
> dBodySetQuaternion (bodyId, newQuat);

```