PDA

View Full Version : Rotations Order - Euler Angle

memecs
08-17-2009, 02:14 PM
hello everyone, i got a problem with rotation matrices multiplication and i hope someone could help me tofigure that out...

So say that i want to perform a sequence of rotation in order xyz. Since opengl pre-multiplied it means that it's multiplying in this way:

Rz * Rx * Ry

now i've implemented the matrix Rz * Ry * Rx on my own and it looks exactly like the xyz matrix in the Matrix Table at the bottom of this link:

http://en.wikipedia.org/wiki/Euler_angles

comparing the two rotations i figured out that this matrix perform the following opengl sequence of rotation:

glRotated(az,0,0,1)
glRotated(ay,0,1,0)
glRotated(ax,1,0,0)

How is this possible? Where am I wrong?
thanks a lot

sammie381
08-17-2009, 07:03 PM
I don't know, but you can find out for yourself.
Just print it out and see what it looks like:

float M[16];
glGetFloatv( GL_MODELVIEW, M );

Dark Photon
08-18-2009, 07:54 AM
So say that i want to perform a sequence of rotation in order xyz. Since opengl pre-multiplied it means that it's multiplying in this way:

Rz * Rx * Ry

now i've implemented the matrix Rz * Ry * Rx on my own and it looks exactly like the xyz matrix in the Matrix Table at the bottom of this link ... comparing the two rotations i figured out that this matrix perform the following opengl sequence of rotation:

glRotated(az,0,0,1)
glRotated(ay,0,1,0)
glRotated(ax,1,0,0)

How is this possible? Where am I wrong?
Do what sammie381 says and you'll probably figure it out yourself.

My guess is you're forgetting OpenGL is column-major storage order and C++ is row-storage order.

Keep in mind that pre-multiply with column-major storage order results in exactly the same resulting matrices as post-multiply with row-major storage order.