Rotation matrix to euler angles

别说谁变了你拦得住时间么 提交于 2019-12-08 13:07:34

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/25489462/rotation-matrix-to-euler-angles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!