将 3D 点转换为 2D

发布于 2024-11-14 02:45:12 字数 156 浏览 0 评论 0原文

我有一组点 (x1, x2,..xn) 位于由 Ax+ By+Cz+d=0 定义的平面上。 我想找到转换矩阵来平移和旋转到 XY 平面。因此,新的点坐标将为 x1'=(xnew, ynew,0)。

很多答案给出四元数、点或叉积矩阵。我不确定哪一种是正确的方法。

谢谢

I have a set of points (x1, x2,..xn) that lie on the plane define by Ax+ By+Cz+d=0.
I would like to find the transformation matrix to translate and rotate to XY plane. So, the new point coordinate will be x1'=(xnew, ynew,0).

A lot of answer give quaternion, dot or cross product matrix. I am not sure which one is the correct way.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落墨 2024-11-21 02:45:12

首先,除非在你的平面方程中,d=0,否则没有线性变换你可以申请。您需要执行仿射变换

实现此目的的一种方法是确定要旋转的角度和矢量,以使点集位于与 XY 平面平行的平面中(即,变换后的点集的 Z 分量都具有相同的值)。然后您只需删除 Z 分量即可。

为此,让 V 为包含点的平面的标准化平面法线。为了方便起见,从上面的平面方程定义 Ax+By+Cz+d=0:

V = (A, B, C)
V' = V / ||V|| = (A', B', C')
Z = (0, 0, 1)

其中

A' = A / ||V||
B' = B / ||V||
C' = C / ||V||
||V|| = (A2+B2+C2)1/2

角度将简单地为:

θ = cos-1(ZV / ||V||)
  = cos-1(ZV')
  = cos-1(C')

围绕其旋转的轴 R 只是标准化平面法线的叉积 < b>V' 和 Z。也就是说,

R = V'×Z
  = (B', -A', 0)

您现在可以使用此角度/轴对来构建旋转所有所需的四元数旋转将数据集中的点映射到与 XY 平面平行的平面。然后,正如我之前所说,只需放下 Z 分量即可在 XY 平面上执行正交投影。

更新: antonakos 在使用 API 获取轴/角度对之前对 R 进行归一化提出了很好的观点。

First of all, unless in your plane equation, d=0, there is no linear transformation you can apply. You need to instead perform an affine transformation.

One way to do this is to determine an angle and vector about which to rotate to make your pointset lie in a plane parallel to the XY plane (ie. the Z component of your transformed pointset to all have the same values). Then you simply drop the Z component.

For this, let V be the normalized plane normal for the plane containing your points. For convenience define from your plane equation above Ax+By+Cz+d=0:

V = (A, B, C)
V' = V / ||V|| = (A', B', C')
Z = (0, 0, 1)

where

A' = A / ||V||
B' = B / ||V||
C' = C / ||V||
||V|| = (A2+B2+C2)1/2

The angle will simply be:

θ = cos-1(ZV / ||V||)
  = cos-1(ZV')
  = cos-1(C')

The axis R about which to rotate is just the cross product of the normalized plane normal V' and Z. That is

R = V'×Z
  = (B', -A', 0)

You can now use this angle / axis pair to build the quaternion rotation needed to rotate all of the points in your dataset to a plane parallel to the XY plane. Then, a I said earlier, just drop the Z component to perform an orthogonal projection onto the XY plane.

Update: antonakos makes a good point about normalizing the R before using an API taking axis / angle pairs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文