将 3D 点投影到 2D 平面 [英] Projecting 3D points to 2D plane

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

问题描述

让 A 成为我拥有 3D 坐标 x、y、z 的点,我想将它们转换为 2D 坐标:x、y.投影应在给定法线定义的平面上正交.普通情况下,法线实际上是轴之一,很容易解决,只需消除一个坐标,但其他情况如何,哪种情况更有可能发生?

Let A be a point for which I have the 3D coordinates x, y, z and I want to transform them into 2D coordinates: x, y. The projection shall be orthogonal on a plane defined by a given normal. The trivial case, where the normal is actually one of the axes, it's easy to solve, simply eliminating a coordinate, but how about the other cases, which are more likely to happen?

推荐答案

如果你有坐标 r_P = (x,y,z) 的目标点 P 和具有法线 n=(nx,ny,nz) 的平面您需要在平面上定义原点,以及 xy 的两个正交方向.例如,如果您的原点位于 r_O = (ox, oy, oz) 并且平面中的两个坐标轴由 e_1 = (ex_1,ey_1,ez_1) 定义, e_2 = (ex_2,ey_2,ez_2) 那么正交性有 Dot(n,e_1)=0, Dot(n,e_2)=0code>, Dot(e_1,e_2)=0(矢量点积).注意所有的方向向量应该被归一化(幅度应该是一).

If you have your target point P with coordinates r_P = (x,y,z) and a plane with normal n=(nx,ny,nz) you need to define an origin on the plane, as well as two orthogonal directions for x and y. For example if your origin is at r_O = (ox, oy, oz) and your two coordinate axis in the plane are defined by e_1 = (ex_1,ey_1,ez_1), e_2 = (ex_2,ey_2,ez_2) then orthogonality has that Dot(n,e_1)=0, Dot(n,e_2)=0, Dot(e_1,e_2)=0 (vector dot product). Note that all the direction vectors should be normalized (magnitude should be one).

你的目标点P必须遵守等式:

Your target point P must obey the equation:

r_P = r_O + t_1*e_1 + t_2*e_2 + s*n

其中 t_1t_2 是沿 e_1e_2s平面和点之间的法线间隔(距离).

where t_1 and t_2 are your 2D coordinates along e_1 and e_2 and s the normal separation (distance) between the plane and the point.

通过投影发现标量:

s = Dot(n, r_P-r_O)
t_1 = Dot(e_1, r_P-r_O)    
t_2 = Dot(e_2, r_P-r_O)

具有平面原点的示例 r_O = (-1,3,1) 和法线:

Example with a plane origin r_O = (-1,3,1) and normal:

n = r_O/|r_O| = (-1/√11, 3/√11, 1/√11)

您必须为二维坐标选择正交方向,例如:

You have to pick orthogonal directions for the 2D coordinates, for example:

e_1 = (1/√2, 0 ,1/√2)
e_2 = (-3/√22, -2/√22, 3/√22)

使得 Dot(n,e_1) = 0Dot(n,e_2) = 0Dot(e_1, e_2) = 0.

点的二维坐标P r_P=(1,7,-3) 是:

t_1 = Dot(e_1, r_P-r_O) = ( 1/√2,0,1/√2)·( (1,7,-3)-(-1,3,1) ) =  -√2
t_2 = Dot(e_2, r_P-r_O) = (-3/√22, -2/√22, 3/√22)·( (1,7,-3)-(-1,3,1) ) = -26/√22

和平面外分离:

s = Dot(n, r_P-r_O) = 6/√11

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

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