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

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

3) 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; v dot normal = length of blue and green (dist above). Blue is normal*dist. Green = blue * -1 : to find planar_xyz, start from point and add the green vector.

enter image description here


This is really easy, all you have to do is find the perpendicular (abbr here |_) distance from the point P to the plane, then translate P back by the perpendicular distance in the direction of the plane normal. The result is the translated P sits in the plane.

Taking an easy example (that we can verify by inspection) :

Set n=(0,1,0), and P=(10,20,-5).

enter image description here

The projected point should be (10,10,-5). You can see by inspection that Pproj is 10 units perpendicular from the plane, and if it were in the plane, it would have y=10.

So how do we find this analytically?

The plane equation is Ax+By+Cz+d=0. What this equation means is "in order for a point (x,y,z) to be in the plane, it must satisfy Ax+By+Cz+d=0".

What is the Ax+By+Cz+d=0 equation for the plane drawn above?

The plane has normal n=(0,1,0). The d is found simply by using a test point already in the plane:

(0)x + (1)y + (0)z + d = 0

The point (0,10,0) is in the plane. Plugging in above, we find, d=-10. The plane equation is then 0x + 1y + 0z - 10 = 0 (if you simplify, you get y=10).

A nice interpretation of d is it speaks of the perpendicular distance you would need to translate the plane along its normal to have the plane pass through the origin.

Anyway, once we have d, we can find the |_ distance of any point to the plane by the following equation:

enter image description here

There are 3 possible classes of results for |_ distance to plane:

  • 0: ON PLANE EXACTLY (almost never happens with floating point inaccuracy issues)
  • +1: >0: IN FRONT of plane (on normal side)
  • -1: <0: BEHIND plane (ON OPPOSITE SIDE OF NORMAL)

Anyway,

enter image description here

Which you can verify as correct by inspection in the diagram above