Rotation matrix to euler angles

n00b

I use the following code to convert a 3X3 rotation matrix to angles :

(_r = double[9] )

double angleZ=atan2(_r[3], _r[4])* (float) (180.0 / CV_PI);
double angleX=180-asin(-1*_r[5])* (float) (180.0 / CV_PI);
double angleY=180-atan2(_r[2],_r[8])* (float) (180.0 / CV_PI);

here is a little helper

_r[0] _r[1] _r[2]
_r[3] _r[4] _r[5]
_r[6] _r[7] _r[8]

does this make any sense ? cause the angles seem too... interdependent ? x y z all react to single pose change...

the rotation matrix is received from opencv cvPOSIT function so the points of interest might be wrong and giving this confusing effect ...

but somehow i think im just doing the conversion wrong :)

I am applying the angles in opengl to a cube :

glRotatef(angleX,1.0f,0.0f,0.0f);
glRotatef(angleY,0.0f,1.0f,0.0f);
glRotatef(angleZ,0.0f,0.0f,1.0f);
oxygene

What you are trying to accomplish is not as easy as you might think. There are multiple conventions as to what the euler angles are called (x,y,z,alpha,beta,gamma,yaw,pitch,roll,heading,elevation,bank,...) and in which order they need to be applied.

The are also some problems with ambiguities in certain positions, see Wikpedia article on Gimbal Lock.

Please read the Euler Angle Formulas document by David Eberly. Its very useful and includes a lot of formulas for various conventions and you probably should base your code on them if you want to have stable formulas even in the corner cases.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Offset Euler Angles using rotation matrix

From Dev

Offset Euler Angles using rotation matrix

From Dev

Computing Euler angles from rotation matrix: boundary cases

From Dev

Does Euler angles -> quaternion -> Euler angles always result in an equivalent rotation?

From Dev

Android rotation matrix sensor to get rotation angles failed

From Dev

How to get the euler-angles from the rotation vector (Sensor.TYPE_ROTATION_VECTOR)

From Dev

using kinect to get rotation of bones (Euler angles for X, Y, Z axis)

From Dev

Rotate a quaternion by Euler angles input

From Dev

How do I compose a rotation matrix with human readable angles from scratch?

From Dev

Euler's angle rotation

From Dev

How to convert direction vector to euler angles?

From Dev

CSS cubic panoramic control with euler angles in javascript

From Dev

Averaging rotations with euler angles or rotational matrices

From Dev

How to convert direction vector to euler angles?

From Dev

Right-Handed Euler Angles XYZ to Left-Handed Euler Angles XYZ

From Dev

Using theta and phi angles for a rotation in Opengl

From Dev

Unity - Clamp Rotation between arbitrary angles

From Dev

Android Rotation Vector and Rotation Matrix

From Dev

Is the rotation matrix unique for a given rotation?

From Dev

How to calculate Euler angles from Forward, Up and Right vectors?

From Dev

How to calculate Euler angles from Forward, Up and Right vectors?

From Dev

Control of Orthographic camera position and orientation from Euler Angles

From Dev

Euler rotation of ellipsoid expressed by coordinate matrices in python

From Dev

Absolute rotation using Matrix?

From Java

Saving rotation Matrix in OpenGL

From Dev

How to undo a rotation on a matrix

From Dev

Matrix manipulation (rotation/rolling)

From Dev

Rotation matrix to quaternion equivalence

From Dev

Essential Matrix: Pure Rotation

Related Related

  1. 1

    Offset Euler Angles using rotation matrix

  2. 2

    Offset Euler Angles using rotation matrix

  3. 3

    Computing Euler angles from rotation matrix: boundary cases

  4. 4

    Does Euler angles -> quaternion -> Euler angles always result in an equivalent rotation?

  5. 5

    Android rotation matrix sensor to get rotation angles failed

  6. 6

    How to get the euler-angles from the rotation vector (Sensor.TYPE_ROTATION_VECTOR)

  7. 7

    using kinect to get rotation of bones (Euler angles for X, Y, Z axis)

  8. 8

    Rotate a quaternion by Euler angles input

  9. 9

    How do I compose a rotation matrix with human readable angles from scratch?

  10. 10

    Euler's angle rotation

  11. 11

    How to convert direction vector to euler angles?

  12. 12

    CSS cubic panoramic control with euler angles in javascript

  13. 13

    Averaging rotations with euler angles or rotational matrices

  14. 14

    How to convert direction vector to euler angles?

  15. 15

    Right-Handed Euler Angles XYZ to Left-Handed Euler Angles XYZ

  16. 16

    Using theta and phi angles for a rotation in Opengl

  17. 17

    Unity - Clamp Rotation between arbitrary angles

  18. 18

    Android Rotation Vector and Rotation Matrix

  19. 19

    Is the rotation matrix unique for a given rotation?

  20. 20

    How to calculate Euler angles from Forward, Up and Right vectors?

  21. 21

    How to calculate Euler angles from Forward, Up and Right vectors?

  22. 22

    Control of Orthographic camera position and orientation from Euler Angles

  23. 23

    Euler rotation of ellipsoid expressed by coordinate matrices in python

  24. 24

    Absolute rotation using Matrix?

  25. 25

    Saving rotation Matrix in OpenGL

  26. 26

    How to undo a rotation on a matrix

  27. 27

    Matrix manipulation (rotation/rolling)

  28. 28

    Rotation matrix to quaternion equivalence

  29. 29

    Essential Matrix: Pure Rotation

HotTag

Archive