矩阵的OpenGL旋转向量 [英] OpenGL rotation vector from matrix
问题描述
好的,这就是我所拥有的:
Ok, so here is what I have:
-
我在框架中制作的抽象对象"类,将其用作所有3D对象的基类.
an abstract "Object" class which I made in a framework to use it as a base class for all 3D objects.
此类的Matrix4成员,其唯一目的是存储对象的旋转信息.
a Matrix4 member of this class which has the sole purpose of storing rotation info for the object.
一些将矩阵相乘的函数:对于每个偏航,俯仰&滚动(全局和局部),我制作了一种将上述旋转矩阵与新矩阵相乘的方法.
some functions that multiply the matrix: for each of the yaw, pitch & roll rotations (both global and local), I made a method that multiplies the above rotation matrix with a new matrix.
例如:如果您在逆时针方向上将对象局部偏航45度,则
e.g.: if you locally yaw the object by 45 degrees in CCW direction, then
rotMatrix = newRotationZMatrix(45) * rotMatrix;
我想知道的是将对象的整体旋转作为矢量的最佳方法是什么-一般而言,如何从包含JUST的变换矩阵中获得围绕X,Y和Z的旋转角度旋转.
What I would like to know is what is the best way of getting the global rotation of the object as a vector - generally speaking, how do you get the rotation angles around X,Y and Z from a transformation matrix that contains JUST rotations.
推荐答案
有一些技术可以做到这一点,只要从旋转矩阵中获得欧拉角,就需要一些数学运算. 在这里,您可以阅读它.
There are techniques to obtain that, just get the euler angles from a rotation matrix, it involves a bit of math. Here you can read about it.
这篇关于矩阵的OpenGL旋转向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!