旋转矩阵到欧拉角 [英] Rotation matrix to euler angles

查看:30
本文介绍了旋转矩阵到欧拉角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码将 3X3 旋转矩阵转换为角度:

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

(_r = double[9])

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

这里有一个小帮手

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

这有意义吗?因为角度看起来太……相互依赖?x y z 都对单个姿势变化做出反应...

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

旋转矩阵是从 opencv cvPOSIT 函数接收的,所以兴趣点可能是错误的,并产生这种混乱的效果......

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

我将 opengl 中的角度应用于立方体:

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

推荐答案

你想要完成的事情并不像你想象的那么容易.关于欧拉角的名称(x,y,z,alpha,beta,gamma,yaw,pitch,roll,heading,elevation,bank,...)以及它们需要应用的顺序有多种约定.

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.

请阅读 David Eberly 撰写的欧拉角公式文档.它非常有用,并且包含许多适用于各种约定的公式,如果您希望即使在极端情况下也有稳定的公式,您可能应该基于它们编写代码.

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.

这篇关于旋转矩阵到欧拉角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆