Another service from Omega

Distance from a Point to a Plane


*****

How far away is a given point from a given plane?

Let "p" be the position (relative to some origin) vector of the point and let "a" and "n" be the location and normal vectors of the plane. Then we have the following picture,

picture here

Using the inner product between the normal "n" and the vector "(p-a)" we can write the formula for this distance as:
dist = n.(p-a) / |n|

> p := vector([1,1,1]): a:=vector([1,1,0]): n := vector([0,0,1]):
> dist := innerprod(n,p-a)/sqrt(innerprod(n,n));

                                   dist := 1


This is obviously the answer since the projection of the point (1,1,1) onto the line y=x is 1. We can pack this new function into a maple procedure that we call "p2plane" for point to plane.

> p2plane := proc(p,a,n) innerprod(n,p-a)/sqrt(innerprod(n,n)); end;

p2plane := proc(p,a,n) innerprod(n,p-a)/sqrt(innerprod(n,n)) end


and let's test it,

> p2plane(p,a,n);

                                       1


Ok how about the distance from the point with coordinates (-1,sqr(2),5) to the plane 3y-x = 1 ?.. no problem just do:

> p2plane([-1,sqrt(2),5],[-1,0,123],[-1,3,0]);

                                      1/2   1/2
                                3/10 2    10


can you see where the "123" is comming from? try it with "321"...

> evalf(");

                                  1.341640786


Link to the commands in this file
Carlos Rodriguez <carlos@math.albany.edu>
Last modified: Wed Oct 23 13:20:03 EDT 1996