0
101 Aug 22, 2006 at 10:07

Hi,

I’m using a rotation matrices to represent the orientation of an object, but I need the 3 Euler angles, represented by this matrix. If I m applying my rotation matrix to the ModelviewMatrix before drawing the object (OpenGL) everything works fine. But if I apply the 3 angles independently in a:

gl.glRotated(yaw, 0.0, 1.0, 0.0);
gl.glRotated(pitch, 1.0, 0.0, 0.0);
gl.glRotated(roll, 0.0, 0.0, -1.0);


the whole orientation of the object gets messed up!
I extract the 3 angles from my 3x3 matrix the following way:

yaw = Math.atan2(-m[6], m[0]);
pitch = Math.atan2(-m[5], m[4]);
roll = Math.asin(m[3]);


Does anyone got any idea on this? It seems that some sources are advising not to use this kind of conversion, but I can’t understand why. The problem is that once I ‘roll’ my object 90 degrees to the left, a pitch maneuver will ‘yaw’ the object etc…

#### 2 Replies

0
167 Aug 22, 2006 at 20:39

http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/

There’s some conditionals relating to pole singularities that you have to deal with. Euler angles are very messy, best not to use them at all if you can in any way avoid them. What do you need the angles for?

0
101 Aug 23, 2006 at 10:27

Hey,

I took care already of the singularities, so that shouldn’t be any problem. The thing is that I m using my system to apply physics to a rigid body, using UVN vectors, easily convertible to a rotation matrix. But for the rendering I have to use a package that draws an object, according to the 3 Euler angles. The drawing is very much like the

gl.glRotated(yaw, 0.0, 1.0, 0.0);
gl.glRotated(pitch, 1.0, 0.0, 0.0);
gl.glRotated(roll, 0.0, 0.0, -1.0);


so… My main concern is that my brain is about to explode, trying to visualise why

yaw = Math.atan2(-m[6], m[0]);
pitch = Math.atan2(-m[5], m[4]);
roll = Math.asin(m[3]);

wont give me the same information as my rotation matrix… :wallbash:
(It’s not a gimbal locking problem. The problem is that the order in which i apply different rotational forces has an impact on the yaw-pitch-roll representation, but not on the matrix representation).