如何从方向向量计算偏航俯仰和滚转?
我正在处理一些 3D 图形,但遇到了问题。我有在世界中移动的模型。这些模型有一个基类,其中包含三个正交单位向量形式的方向,即 Direction、Up 和 Right。它们分别指向模型正面的方向,即向上和向右的方向。
模型的AI通过相应地改变模型的Direction向量和所有其他方向向量来追踪目标,从而模拟模型指向目标。
我无法跟踪 AI 更改方向向量的角度,因为 AI 文件已经预编译,我无法更改它们。此外,AI 使用模型的位置坐标和目标的位置坐标来更改矢量。
我的问题是如何从方向向量中获取 yaw、pitch 和 roll 以便创建旋转矩阵来旋转整个模型所需的方向?
感谢您的任何帮助。
[编辑] 感谢给定的答案,我发现了这一点:
X Y Z W
- -
Right | Rx Ry Rz Rw |
Up | Ux Uy Uz Uw |
-Forward |-Fx -Fy -Fz -Fw |
Translation | Tx Ty Tz Tw |
- -
这就是应该如何设置矩阵以使用方向向量获取世界矩阵(无需缩放:要缩放,只需创建一个缩放矩阵并将其乘以该矩阵)。
[已解决]
I'm working with some 3D graphics and I encountered a problem. I have models that move in a world. The models have a base class that contains their orientation in the form of three orthogonal unit vectors namely Direction, Up, and Right. They point to where the front of the model is directed, the up and the right directions respectively.
The AI of a model pursues a target by changing the Direction vector of the model and all other orientation vectors accordingly, so that it simulates that the model is pointing to the target.
I cannot keep track of the angles that the AI changes the orientation vectors by because the AI files were already pre-compiled and I cannot change them. Also, the AI changes the vectors using the position coordinates of the model and the position coordinates of the target.
My question is how can I obtain yaw, pitch and roll from the orientation vectors in order to create a rotation matrix to rotate the whole model in the desired orientation?
Thanks for any help.
[EDIT]
Thanks to the given answer I found this:
X Y Z W
- -
Right | Rx Ry Rz Rw |
Up | Ux Uy Uz Uw |
-Forward |-Fx -Fy -Fz -Fw |
Translation | Tx Ty Tz Tw |
- -
This is how the matrix should be set up to obtain the world matrix using the orientation vectors (without scaling: to scale, just create a scale matrix and multiply it by this).
[SOLVED]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要偏航、俯仰和滚动。三个正交单位向量 Direction、Up 和 Right 给出旋转矩阵的行。就是这么简单。
请参阅Android 设备上的传感器融合:运动处理的革命中的 41:58 开始。
顺便说一下,你很容易在偏航、俯仰和滚转方面遇到麻烦,从 38:25 开始看。
You do not need yaw, pitch and roll. The three orthogonal unit vectors Direction, Up, and Right give you the rows of the rotation matrix. It is that simple.
See from 41:58 in Sensor Fusion on Android Devices: A Revolution in Motion Processing.
By the way, you can easily get into trouble with yaw, pitch and roll, see from 38:25.