PDA

View Full Version : Order of x, y, z rotation angles in OpenGL



Lee_Jennifer_82
07-06-2014, 05:58 PM
I have extracted the three rotation angles from a rotation matrix. Now if an object is multiplied by the rotation matrix or the rotation angles, both should give the same result. I followed the following order of rotation and I get the correct result, i.e. multiplying the object with the rotation matrix gives the same result:

glRotatef(y_rotation*180.0)/PI, 0.0, 1.0, 0.0);
glRotatef(z_rotation*180.0)/PI, 0.0, 0.0, 1.0);
glRotatef(x_rotation*180.0)/PI, 1.0, 0.0, 0.0);

Does it imply that OpenGL follows that order or it depends on how the original matrix multiplication is done.

Dark Photon
07-07-2014, 05:58 AM
The latter. There's no right way to build a rotation transform (or right order, if you're going to use euler angles). In fact you may build it without any euler angles involved at all. For instance, using orthonormal basis vectors, or from a quaternion, etc.

GClements
07-13-2014, 07:48 PM
Does it imply that OpenGL follows that order or it depends on how the original matrix multiplication is done.

It implies that the function which "extracts" the angles from a matrix does so assuming that order.

If you used a different order, you'd need a different extraction function.