Search code examples
androidopengl-esmatrixquaternions

Android OpenGL 3x3 Matrix to Quaternion


I want to rotate a 3D cube using a 3x3 matrix. I manage to get the matrix but OpenGL needs a quaternion to rotate the cube using

glRotatef (float angle, float x, float y, float z);

How can I go from a 3x3 matrix to a quaternion to use this method properly ?

Thanks!


Solution

  • glRotatef doesn't expect a quaternion, but an axis and angle (in degrees). Have a look at:

    http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm