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

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

问题描述

我使用以下代码将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,α,β,γ,偏航角,俯仰,倾角,滚动,航向,高程,倾斜等)以及需要按什么顺序应用

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.

在某些位置上也存在歧义问题,请参见Wikpedia文章,网址为云台锁.

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天全站免登陆