如何从滚动、俯仰和偏航中获取相机向上矢量? [英] How to get camera up vector from roll, pitch, and yaw?

查看:26
本文介绍了如何从滚动、俯仰和偏航中获取相机向上矢量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从滚动、俯仰和偏航角度(以度为单位)为相机获取向上向量(以获得正确的外观).我已经尝试了几个小时不同的事情,但没有成功:(.这里的任何帮助将不胜感激!

I need to get an up vector for a camera (to get the right look) from a roll, pitch, and yaw angles (in degrees). I've been trying different things for a couple hours and have had no luck :(. Any help here would be appreciated!

推荐答案

Roll、Pitch 和 Yaw 定义了 3 轴旋转.从这些角度,您可以构建一个 3x3 变换矩阵来表达这种旋转(在这里查看方法)
有了这个矩阵后,你可以使用常规的向上向量,如果 'up' 是 Y 轴,则说 (0,1,0) 并将其与矩阵相乘.你将得到的是变换后的向量.

Roll, Pitch and Yaw define a rotation in 3 axis. from these angles you can construct a 3x3 transformation matrix which express this rotation (see here how)
After you have this matrix you take your regular up vector, say (0,1,0) if 'up' is the Y axis and multiply it with the matrix. What you'll get is the transformed up vector.

编辑-
将变换应用于 (0,1,0) 与取中间行相同.矩阵的 3 行构成了旋转系统的正交基.请注意,3D 图形 API 使用 4x4 矩阵.因此,要从 3x3 旋转矩阵中生成 4x4 矩阵,您需要在 M[3][3](角落)处添加一个1",并在其余部分添加零,如下所示:

Edit-
Applying the transformation to (0,1,0) is the same thing as taking the middle row. The 3 rows of the matrix make up an orthogonal base of the rotated system. Mind you that a 3D graphic API uses 4x4 matrices. So to make a 4x4 matrix out of the 3x3 rotation matrix you need to add a '1' at M[3][3] (the corner) and zeros at the rest like so:

r r r 0
r r r 0 
r r r 0
0 0 0 1

这篇关于如何从滚动、俯仰和偏航中获取相机向上矢量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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