Y rotation from rotation matrix

拟墨画扇 提交于 2019-12-24 14:22:36

问题


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

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

here is what i do,

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

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

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

what am i doing wrong?

thank you.

(this is OGRE, code is C++)


回答1:


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.

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


来源:https://stackoverflow.com/questions/10971558/y-rotation-from-rotation-matrix

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