3

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.

I've been looking at this: http://www.odeion.org/pythagoras/pythag3d.html

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.

gregghz
  • 3,925
  • 7
  • 40
  • 69

1 Answers1

11

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

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.

Example

Let's say I have three points:

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

The normal vector of these two is then

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

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

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

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]

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.

We can now recover the point:

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

You can verify this point is indeed in the plane:

  • dot(r0 - rm, n) = 0.
David Alber
  • 17,624
  • 6
  • 65
  • 71
  • 2
    It would be good to check that your three points are not collinear. Otherwise great answer! – santiagoIT Jan 16 '12 at 22:50
  • wow, thanks for that. The only part I'm having trouble with is the scalar projection. From what I can gather, if I take the cross product of v3 and n, I'll get a magnitude. Then what do I do with that to obtain v3m? – gregghz Jan 16 '12 at 22:56
  • looks like you've updated your answer already. I'll give it a go. – gregghz Jan 16 '12 at 22:57
  • Good comment santiagoIT, fortunately, for my application, i can guarantee that the points are not colinear. However, if you want a general solution then I think you are spot on. – gregghz Jan 16 '12 at 23:04