Jump to content


- - - - -

Extract euler from rotation matrix


2 replies to this topic

#1 Yannik Klich

    New Member

  • Members
  • Pip
  • 3 posts

Posted 22 August 2006 - 10:07 AM

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...

many thanks in advance!

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5309 posts
  • LocationSanta Clara, CA

Posted 22 August 2006 - 08:39 PM

http://www.euclidean.../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?
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 Yannik Klich

    New Member

  • Members
  • Pip
  • 3 posts

Posted 23 August 2006 - 10:27 AM

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).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users