PDA

View Full Version : ModelView Matrix Angle XYZ



bobGL
11-05-2007, 04:06 PM
I getting back the modelview matrix using glGetFloatv( GL_MODELVIEW_MATRIX, ...

My question is how can I get back the rotation angle XYZ???

I know that the position is on 12, 13, 14 but what about the rotation It seems that I can't found it back....

Tks in advance!

T101
11-06-2007, 04:01 AM
1) You cannot get the individual rotations back, since the matrix is the result of a whole bunch of transformations, including the camera rotation and position.

2) having said that, for a simple scheme including one rotation matrix and one translation, I believe the matrix calculations would look something like:
X Y Z W
RXx RYx RZx Tx X'
RXy RYy RZy Ty Y'
RXz RYz RZz Tz Z'
You can probably look up the details in the redbook.

With W usually set to 1 (since you normally supply a vector of three components).
RX, RY and RZ are the unit vectors of the set of rotations.

Assuming you want Euler angles, you'll have to start with the "forward" and "up" vectors and determine the three angles one at a time (probably using the atan2 function), rotating the unit vectors back.