世界空间到相机空间 [英] World space to camera space

查看:44
本文介绍了世界空间到相机空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对如何将世界空间坐标转换为相机坐标感到困惑.

I am confused on how to convert world space coordinates to camera coordinates.

我目前的理解是我需要计算相机空间向量在哪里

My current understanding is that I would need to calculate the camera space vector where

n = 眼点 - 观察

n = eyepoint - lookat

u = up(0,1,0) X n(归一化)

u = up(0,1,0) X n(normalized)

v = n X u

然后一旦我有 <U、V、N > 我会简单地将每个点乘以吗?

Then once I have < U, V, N > would I simply multiply each point by ?

推荐答案

让我们假设:

  • 眼睛位置E=(e_x, e_y, e_z),
  • 观看方向D=(d_x, d_y, d_z)
  • 向上向量向上=(up_x, up_y, up_z)
  • Eye position is E=(e_x, e_y, e_z),
  • Viewing direction is D=(d_x, d_y, d_z)
  • Up-Vector is UP=(up_x, up_y, up_z)

现在首先构造一个正交框架:

Now first construct an orthonormal frame:

  • R = D X UP
  • U = R X D
  • 现在对 D、R、U 进行标准化,您就有了相机的正交框架 (D、R、U)

为了将全局坐标系转换为凸轮坐标系,您可以应用以下矩阵M_R:

In order to transform the global coord frame into the cam-coord frame you can apply the following matrix M_R:

  • |R_x, R_y, R_z, 0 |
  • |U_x, U_y, U_z, 0 |
  • |-D_x, -D_y, -D_z, 0|
  • |0.0, 0.0, 0.0, 1.0|

如果您的摄像头未定位在全球原点,您还必须应用翻译M_T:

If your cam is not positioned at global origin you also have to apply a translation M_T:

  • |1, 0, 0, -e_x |
  • |0, 1, 0, -e_y |
  • |0, 0, 1, -e_z|
  • |0, 0, 0, 1|

最后,从全局到凸轮坐标的完整转换矩阵是:

In the end your complete transformation matrix from global to cam-coords is:

  • M = M_R * M_T
  • M = M_R * M_T
  • |R_x, R_y, R_z, (R dot -E) |
  • |U_x, U_y, U_z, (U dot -E) |
  • |-D_x, -D_y, -D_z, (D 点 E)|
  • |0.0, 0.0, 0.0, 1.0|

这篇关于世界空间到相机空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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