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

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

问题描述

我试图计算3D世界中4D点的位置。我从2D开始尝试将其扩展到3D,然后再扩展到4D。首先,我发现它很容易计算线上2D点的投影位置。



 哎呀,第一个等式中应该有():x /( a + y)

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

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

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

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

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



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



感谢您的帮助!

解决方案


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

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


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

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


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

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


  • ......等等




<或者,可以使用参数形式计算线和超平面的交点,其中为lin e描述如下:

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

其中参数t是任意数字



超平面描述如下:

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

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

  [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)可以解决,除非该线与超平面平行。



上述想法受中的分析几何影响4D (其中w组件代表一个独立的维度),它们不应与齐次坐标混合(其中 w 组件用于将翻译/投影整合到 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)

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);

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);

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...

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)...

Thanks for any help!

解决方案

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

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

  • 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)
    

  • 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]

where the parameter t is any number

A hyperplane is described by:

[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]

or more explicit:

[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]

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.

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天全站免登陆