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!


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


See Here to see how it is done in javascript. The method is the same, it converts a 3x3 matrix into a quaternion, just convert the code to java and away you go.

链接地址: http://www.djcxy.com/p/81796.html

上一篇: 使用四元数的OpenGL多维数据集旋转

下一篇: Android OpenGL 3x3矩阵到四元数