1
votes

I have looked at three separate formulas and while they are mostly identical, I'm wondering why their signs are different. to illustrate, here are the formulas:

Common Code

float xSin = Math::Sinr (x / 2);
float xCos = Math::cosr (x / 2);

float ySin = Math::Sinr (y / 2);
float yCos = Math::Cosr (y / 2);

float zSin = Math::Sinr (z / 2);
float zCos = Math::Cosr (z / 2);

Euclidean Space

X = xSin * yCos * zCos + xCos * ySin * zSin;
Y = xCos * ySin * zCos + xSin * yCos * zSin;
Z = xCos * yCos * zSin - xSin * ySin * zCos;
W = xCos * yCos * zCos - xSin * ySin * zSin;

Wikipedia

X = xSin * yCos * zCos - xCos * ySin * zSin;
Y = xCos * ySin * zCos + xSin * yCos * zSin;
Z = xCos * yCos * zSin - xSin * ySin * zCos;
W = xCos * yCos * zCos + xSin * ySin * zSin;

Microsoft XNA

X = xSin * yCos * zCos + xCos * ySin * zSin;
Y = xCos * ySin * zCos - xSin * yCos * zSin;
Z = xCos * yCos * zSin - xSin * ySin * zCos;
W = xCos * yCos * zCos + xSin * ySin * zSin;

You can see that the first has + + - -, the second - + - + and the third + - - +. For this I have normalized the yaw pitch and rolls into their proper XYZ counterparts, but I don't understand the difference in signs.

1
There are 12 representations of Euler angels en.wikipedia.org/wiki/Euler_angles And probably your sources uses different onesminorlogic

1 Answers

0
votes

Most likely they are all "right", but there are several sources of ambiguity when just stating "Euler angles" and/or "yaw pitch roll". This likely gives rise to the differences in sign that you are seeing. In particular the axes around which each of the three rotations take place need to be specified.

For going from Euler angles to rotation matrices (if you like those) I found the paper by G. Slabaugh Computing Euler angles from a rotation matrix useful and not too long. You'll still need to convert from rotation matrix to quaternion but this is well defined up to the sign of the quaternion.

Unless you want to go in-depth with the math you are probably best off sticking to the definition used by one software package that can convert back and forth between its preferred Euler angles and quaternions.