How to Project a Point Onto a Plane in 3D

How to project a point onto a plane in 3D?


  1. Make a vector from your orig point to the point of interest:

v = point-orig (in each dimension);


  1. Take the dot product of that vector with the unit normal vector n:

dist = vx*nx + vy*ny + vz*nz; dist = scalar distance from point to plane along the normal


  1. Multiply the unit normal vector by the distance, and subtract that vector from your point.

projected_point = point - dist*normal;

Edit with picture:
I've modified your picture a bit. Red is v. dist is the length of blue and green, equal to v dot normal. Blue is normal*dist. Green is the same vector as blue, they're just plotted in different places. To find planar_xyz, start from point and subtract the green vector.

Projection of point onto plane

Vector Projection through a point and onto a plane

So the camera has 3d location vector r and direction vector e. The plane is defined by z=0 which you use on the equation of the line

z = r_z + t * e_z = 0  } t = -r_z/e_z

the coordinate are then

x = r_x + t * e_x
y = r_y + t * e_y

I assume that everything is already expressed in the desired coordinate system with blue along the z-axis.

How do I find the orthogonal projection of a point onto a plane

The projection of a point q = (x, y, z) onto a plane given by a point p = (a, b, c) and a normal n = (d, e, f) is

q_proj = q - dot(q - p, n) * n

This calculation assumes that n is a unit vector.

computational geometry - projecting a 2D point onto a plane to determine its 3D location

If I understood this correctly you want to project points on the 2D plane onto a plane with a different orientation. I’m also going to assume that you are looking for the orthogonal projection (i.e. all points from the xy-plane are to be projected onto the closest point on the target plane).

So we have the equations of the two planes and the point we want to project:

The original 2D plane: z = 0, with the normal vector n1 = (0, 0, 1)

The target plane: ax + by + cz + d = 0 with the normal vector n2 = (a, b, c)

Point P: (e, f, 0) which obviously lies in the xy-plane

Now, we want to travel from point P in the direction of the normal of the target plane (because this will give us the closest point on the target plane). Hence we form an equation for the line which starts at point P, and which is parallel to the normal vector of the target plane.

Line L: (x,y,z) = (e,f,0) + t(a,b,c) = (e+ta, f+tb, tc) , where t is a real valued parameter

Next, we want to find a point on the line L which also lies on the target plane. Hence, we plug the line equation into the equation for the target plane and receive:

a(e+ta) + b(f+tb) + c * tc + d= 0

ae + bf + d + t(a2 + b2 + c 2) = 0

t = - (ae + bf + d) / (a2 + b2 + c 2)

hence the projected point will be:

Pprojected = (e + ka, f + kb, kc), where k = - (ae + bf + d) / (a2 + b2 + c 2)


With all the variables in the solution about, it might be a bit hard to grasp if you are new to the area. But really, it is rather simple. The things you have to learn are:

  • The standard equation for a plane: ax + by + cz + d = 0
  • How to extract the normal vector from the equation of the plane
  • What the normal vector is (a vector which is perpendicular to all position vectors in the plane)
  • The parametric representation of a line: (x, y, z) = u + t*v* , where u is a point which lies on the line, t is a real valued parameter and v is a vector parallel to the line.
  • The understanding that the closest path between a point and a plane will be parallel to the normal of the plane

If you grasped the above concepts, computing the projection is simple:

Compute the normal vector of the target plane. Starting from the point that you want to project, travel parallel to the computed normal vector until you reach the plane.

Projecting 3D points to 2D plane

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

Your target point P must obey the equation:

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

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.

There scalars are found by projections:

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)

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)

such that Dot(n,e_1) = 0 and Dot(n,e_2) = 0 and Dot(e_1, e_2) = 0.

The 2D coordinates of a point P r_P=(1,7,-3) are:

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

and the out of plane separation:

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

Project point on 2D triangle back into 3D?

You can use barycentric coordinates...

So you got 2D triangle q0,q1,q2 and corresponding 3D triangle p0,p1,p2 and want to convert 2D point q into 3D point p

  1. compute barycentric coordinates u,v of q within q0,q1,q2

    see how to compute barycentric coordinates

  2. convert u,v to cartessian using triangle p0,p1,p2

So when put together:

| u |           | (q1.x - q0.x) , (q2.x - q0.x) , q0.x |   | q.x |
| v | = inverse | (q1.y - q0.y) , (q2.y - q0.y) , q0.y | * | q.y |
| 1 | | 0 , 0 , 1 | | 1 |

p.x = p0.x + (p1.x - p0.x) * u + (p2.x - p0.x) * v
p.y = p0.y + (p1.y - p0.y) * u + (p2.y - p0.y) * v
p.z = p0.z + (p1.z - p0.z) * u + (p2.z - p0.z) * v

Projecting a point onto the same plane as a polygon

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.


Related Topics



Leave a reply



Submit