从旋转矩阵Y轴旋转 [英] Y rotation from rotation matrix

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

问题描述

下面是我的轴。我不知道该怎么称呼它。 (它是ZXY?) (这是摄像头看到的)

Here are my axes. i dont know what to call it. (is it ZXY?) (this is what camera sees)

我想知道绕Y轴的平面旋转。目前,它是绕Y 0度。

i want to know plane rotation around Y axis. Currently it is 0 degree around Y.

下面是我做的,

Matrix33 orientmatrix = body->getGlobalOrientation();
return Degree(-asin(orientmatrix[2][0]));

这将返回不正确的角度,逆时针:  0..45..90..45..0 ..- 45 ..- 90 ..- 45..0

this returns incorrect angles, in counterclockwise: 0..45..90..45..0..-45..-90..-45..0

应该是: 0 ... 45..90..135..180 ..- 45 ..- 90 ..- 135..0

it should be: 0...45..90..135..180..-45..-90..-135..0

我在做什么错了?

感谢你。

(这是OGRE,code是C ++)

(this is OGRE, code is C++)

推荐答案

你在做什么错的是你正在使用 ASIN 。它返回-pi / 2之间的值至+ pi / 2之间,或-90度到90度。

What you are doing wrong is that you are using asin. It returns a value between -pi/2 to +pi/2, or -90 degrees to +90 degrees.

如果你想有一个值,跨越360度,你需要使用 ATAN2 。假设你的方向的确是一个关于Y轴旋转,你可以使用

If you want a value that spans 360 degrees you need to be using atan2. Assuming your orientation truly is a rotation about y, you could use

Degree(atan2(orientmatrix[0][2], orientmatrix[0][0]))

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

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