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

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

问题描述

我很困惑于如何将世界空间坐标相机坐标。

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 =向上(0,1,0)×N(标准化)

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

V =的N×U

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

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

推荐答案

让我们假设:

  • 眼位电子邮件 =(e_x,e_y,e_z),
  • 查看方向ð =(D_X,d_y,d_z)
  • 向上矢量 UP =(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 =二维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 |
  •   
  • | 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 |
  •   
  • | 1, 0, 0, -e_x |
  • | 0, 1, 0, -e_y |
  • | 0, 0, 1, -e_z|
  • | 0, 0, 0, 1|

在结束全球的全面转换矩阵凸轮COORDS是:

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点-E)|
  •   
  • | U_x,U_y,U_z,(U点-E)|
  •   
  • | -D_x,-D_y,-D_z,(D点E)|
  •   
  • | 0.0,0.0,0.0,1.0 |
  •   
  • | 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 dot E)|
  • | 0.0, 0.0, 0.0, 1.0|

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

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