4D转3D透视投影 [英] 4D to 3D perspective projection

查看:34
本文介绍了4D转3D透视投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算 3D 世界中 4D 点的位置.我从 2D 开始,并尝试将其扩展到 3D,然后再扩展到 4D.首先,我发现计算二维点在直线上的投影位置很容易.

Im trying to calculate the position of 4D point in 3D world. I started with 2D and tried to extend it to the 3D and then to 4D. Firstly, I found out that its easy to calculate the projected position of 2D point on the line.

Whoops, there should be () in the first equation: x/(a+y)

现在我发现如果我将 P(X,Y,Z) 拆分为 P1(X,Z) 和 P2(Y,Z),计算它们的 Q,然后构建它们,那么同样适用于 3D 世界P'(Q1,Q2) 的一个点(假设我从 C(0,-a) 点看 Z 轴正无穷远并渲染到 XY 平面).

Now I figured out that the same will apply in the 3D world if I split the P(X,Y,Z) to the P1(X,Z) and P2(Y,Z), calcualte their Q and then build a point of P'(Q1,Q2) (Assuming Im looking Z axis positive infinity from C(0,-a) point and rendering to the XY plane).

nx = (a*x)/(a+z);
ny = (a*y)/(a+z);

然后我认为它就像添加下一个点P3一样简单,并想出了

Then I thought its just as simple as adding next point P3, and came up with

nx = (a*x)/(a+z);
ny = (a*y)/(a+z);
nw = (a*w)/(a+z);

我觉得这很奇怪,因为 W(新轴)实际上只影响最后一点的 Z,并且指的是 tesseract 它应该影响所有维度......

I felt it was weird, becouse W (new axis) actually affects only Z of the last point, and referring to the tesseract it should affect all dimensions...

这行不通,所以我想问你是否可以提供一些我做错了什么的细节.我很确定它是点分裂"问题,方程应该更复杂.请不要用矩阵和四元数攻击我.我只想在 (0,-1) 处有一个简单的静态相机,看着 (0,0)...

This isn't working, so I'd like to ask if you can possibly provide some details of what Im doing wrong. Im pretty sure that its the "point splitting" problem, and the equation should be more complex. Please, don't attack me with matrixes and quaternions. I just want to have a simple static camera at (0,-1) looking at (0,0)...

感谢您的帮助!

推荐答案

  • 2D (x,y) y=0 上的投影表示线与线的交点:

    • in 2D (x,y) a projection on y=0 means intersection of line with line:

      x'/a = x/(a+y)
      

    • 3D (x,y,z) 中,z=0 上的投影表示线与平面的交点:

    • in 3D (x,y,z) a projection on z=0 means intersection of line with plane:

      for y=0: x'/a = x/(a+z)
      for x=0: y'/a = y/(a+z)
      

    • 4D (x,y,z,w) 上的投影到 w=0 意味着线与超平面的交点:

    • in 4D (x,y,z,w) a projection onto w=0 means intersection of line with hyperplane:

      for y=0, z=0: x'/a = x/(a+w)
      for x=0, z=0: y'/a = y/(a+w)
      for x=0, y=0: z'/a = z/(a+w)
      

    • ...等等

    • ...and so on

      或者,可以使用参数形式计算一条线和一个超平面的交点,其中一条线描述为:

      Alternatively one could calculate the intersection of a line and a hyperplane using the parameter form, where a line is described by:

      [px,py,pz,pw] = [p0x,p0y,p0z,p0w] + t * [p1x,p1y,p1z,p1w]
      

      其中参数 t 是任意数字

      where the parameter t is any number

      超平面的描述如下:

      [hx,hy,hz,hw] = [h0x,h0y,h0z,h0w] + a * [h1x,h1y,h1z,h1w] + b * [h2x,h2y,h2z,h2w] + c * [h3x,h3y,h3z,h3w]
      

      现在可以通过求解找到交点:

      Now the intersection point can be found by solving:

      [px,py,pz,pw] = [hx,hy,hz,hw]
      

      或更明确:

      [p0x,p0y,p0z,p0w] + t * [p1x,p1y,p1z,p1w] = [h0x,h0y,h0z,h0w] + a * [h1x,h1y,h1z,h1w] + b * [h2x,h2y,h2z,h2w] + c * [h3x,h3y,h3z,h3w]
      

      除非直线平行于超平面,否则有 4 个方程(每个维度 x、y、z、w 一个)和 4 个未知数(a、b、c、t)可以求解.

      There are 4 equations (one for each dimension x,y,z,w) and 4 unknowns (a,b,c,t) which can be solved unless the line is parallel to the hyperplane.

      上述想法受 4D 中解析几何的约束(其中 w 分量代表自己的独立维度),不应将它们与齐次坐标(其中 w 组件用于将平移/投影集成到 4D 矩阵中,并在接近图形管道末端时被透视分割丢弃).

      The thoughts above are subject to analytical geometry in 4D (where the w component represents an own separate dimension) and they should not be mixed up with homogeneous coordinates (where the w component is used to integrate the translation/projection into 4D matrices and is discarded near the end of graphics pipeline by the perspective divide).

      这篇关于4D转3D透视投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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