一个人如何转换世界坐标相机坐标? [英] How does one convert world coordinates to camera coordinates?

查看:575
本文介绍了一个人如何转换世界坐标相机坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入3D矢量,随着相机的俯仰和偏转。任何人都可以描述或提供一个链接到的资源,这将帮助我了解和实施必要的改造和矩阵映射?

I have an input 3D vector, along with the pitch and yaw of the camera. Can anyone describe or provide a link to a resource that will help me understand and implement the required transformation and matrix mapping?

推荐答案

世界对照相机变换矩阵是相机到世界矩阵的逆。相机到世界矩阵是翻译到相机的位置和旋转到相机的取向的组合。因此,如果 M 的是对应于相机的方位的3×3旋转矩阵的的是相机的位置,则4×4相机到世界矩阵是:

The world-to-camera transformation matrix is the inverse of the camera-to-world matrix. The camera-to-world matrix is the combination of a translation to the camera's position and a rotation to the camera's orientation. Thus, if M is the 3x3 rotation matrix corresponding to the camera's orientation and t is the camera's position, then the 4x4 camera-to-world matrix is:


M00 M01 M02 tx
M10 M11 M12 ty
M20 M21 M22 tz
0   0  0   1

请注意,我已经认为向量是列向量这是乘上执行转换权。如果使用相反的约定,一定要转置矩阵。

Note that I've assumed that vectors are column vectors which are multiplied on the right to perform transformations. If you use the opposite convention, make sure to transpose the matrix.

要查找的 M 的,你可以使用的维基百科的,这取决于你的侧倾,俯仰和偏航特别约定。请记住,这些公式使用的载体是行向量这是乘在左边的约定。

To find M, you can use one of the formulas listed on Wikipedia, depending on your particular convention for roll, pitch, and yaw. Keep in mind that those formulas use the convention that vectors are row vectors which are multiplied on the left.

,一个更有效(与数值稳定)另一种方法是直接计算的世界到摄象机矩阵。要做到这一点,只是反转摄像机的位置(由否定所有3坐标)及其方位(通过否定的滚动,俯仰和偏航角,以及调整它们是在其适当的范围),然后使用相同的计算矩阵算法。

Instead of computing the camera-to-world matrix and inverting it, a more efficient (and numerically stable) alternative is to calculate the world-to-camera matrix directly. To do so, just invert the camera's position (by negating all 3 coordinates) and its orientation (by negating the roll, pitch, and yaw angles, and adjusting them to be in their proper ranges), and then compute the matrix using the same algorithm.

这篇关于一个人如何转换世界坐标相机坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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