将点投影到与多边形相同的平面上 [英] Projecting a point onto the same plane as a polygon

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

问题描述

我无法理解如何执行此操作.我有一个由三个点定义的多边形.我在太空的某个地方也有一个观点.我想将空间中的某个点移动到与多边形相同的平面上.据我所知,如何做到这一点是众所周知的.不过,我对它并不熟悉.

I'm having trouble grasping how to do this. I have a polygon defined by three points. I also have a point somewhere in space. I want to move the point somewhere in space to be on the same plane as the polygon. From what I understand, it is well-known how to do this. However, it is not well-known by me.

我找不到任何直接的算法或关于如何完成的可靠解释.

I can't find any straight forward algorithms or solid explanations of how this is done.

我一直在看这个:http://www.odeion.org/pythagoras/pythag3d.html

但这会给我距离而不是顶点的点.如果多边形仅限于 2d,我可以看到这会有什么用处,但在我的情况下,它可能有任何方向.

But that will give me distances to rather than points of the vertices. I can see how that would be useful if the polygon was limited to 2d, but in my case, it may have any orientation.

不幸的是,我的数学相当薄弱,但我非常愿意学习.

Unfortunately my math is fairly weak, but I'm more than willing to learn.

推荐答案

第一个有用的概念步骤是有一种方法来确定一个点是否与多边形中描述该点的三个点位于同一平面上飞机.一种方法是计算平面的法向量——称之为 n——并使用 n 和三个点之一(称之为点r0).

The first conceptual step that will be helpful is to have a way to determine if a point lies on the same plane as the three points from your polygon that describe the plane. One approach to doing this is to compute a normal vector for the plane -- call it n -- and define the plane using n and one of the three points (call that point r0).

可以通过多种方式计算平面的法线向量(请参阅此处).对于这种情况,最方便的方法是取平面内两个向量的叉积(使用定义多边形中的点找到两个向量).

Computing a normal vector for the plane can be done in several ways (see here). For this situation, the most convenient approach is taking the cross product between two vectors that are in the plane (find two vectors using the points from the defining polygon).

一旦你知道n,你就可以测试一个点r是否位于n和向量之间的点积的平面上(r0 - r).请参阅此处了解更多说明.

Once you know n, you can then test if a point r lies in the plane with the dot product between n and the vector (r0 - r). See here for more explanation.

然后您可以在任何点上使用正交投影来获得平面上的新点.

You can then use orthogonal projection on any point to get a new point that is on the plane.

假设我有三点:

  • p1: [1, 1, 1]
  • p2: [1.5, 6, 3]
  • p3:[2, -1, 5].

让我们首先创建一个与由这些点创建的平面垂直的向量.让

Let's first create a vector that is normal to the plane created by these points. Let

  • v1 = p1 - p2 = [-0.5, -5, -2]
  • v2 = p1 - p3 = [-1, 2, -4].

这两个的法向量就是

  • n = v1 x v2 = [24, 0, -6].

为了方便起见,让我们对 n 进行归一化,所以现在 n = [0.9701425, 0, -0.24253563].

For the sake of convenience, let's normalize n, so now n = [0.9701425, 0, -0.24253563].

现在我们用 n 定义平面,让 r0 = p1.

Now we define the plane by n and let r0 = p1.

我们引入一个新的点,r,它不在平面内(你可以通过取n和(r0 - r):

Lets introduce a new point, r, that is not in the plane (you can verify by taking the dot product of n and (r0 - r):

  • r = [4, 4, 4]
  • r = [4, 4, 4]

移动"r 到平面上的一种方法是将它滑动"到法向量上,直到它在平面上(这是正交投影).这是通过确定向量 v3 = (r0 - r)(称为 标量投影).在这种情况下标量投影产生新向量 v3m = [-0.88235294, -3, -3.52941176].这是由 v3 - n*dot(n, v3).您可以验证这是在平面中,因为它与 n 正交.

One way to "move" r to be on the plane is to "slide" it down the normal vector until it is on the plane (this is orthogonal projection). This is done by determining how much of n is in vector v3 = (r0 - r) (called scalar projection). Scalar projection in this case yields the new vector v3m = [-0.88235294, -3, -3.52941176]. This is computed by v3 - n*dot(n, v3). You can verify this is in the plane because it is orthogonal to n.

我们现在可以恢复点:

  • rm = r0 - v3m = [1.88235294, 4, 4.52941176].

你可以验证这个点确实在平面上:

You can verify this point is indeed in the plane:

  • dot(r0 - rm, n) = 0.
  • dot(r0 - rm, n) = 0.

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

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