to eAlerts

for Geom Site



Planes and Distance of a Point to a Plane

by Dan Sunday



Here we present several basic methods for representing planes in 3D space, and how to compute the distance of a point to a plane.


A surface is that which has length and breadth only. [Book I, Definition 5]
The extremities of a surface are lines. [Book I, Definition 6]
A plane surface is a surface which lies evenly with the straight lines on itself. [Book I, Definition 7]

If two straight lines cut one another, they are in one plane, and
every triangle is in one plane. [Book XI, Proposition 2]

If two planes cut one another, their common section is a straight line. [Book XI, Proposition 3]

From the same point two straight lines cannot be set up at right
angles to the same plane on the same side. [Book XI, Proposition 13]
[Euclid, 300 BC]

Although Euclid defined a plane in Book I as the third primitive after the point and line, he did not prove anything about planes until much later in Book XI. And even then, he did not appeal to the definition from Book I in his proofs of Propositions in Book XI [Heath, 1956]. In modern times, [Coxeter, 1989a] has given a more exact definition of a plane as:

Definition. If A, B, C are three non-collinear points, the plane ABC is the set of all points collinear with pairs of points on one or two sides of the triangle DELTAABC.

which is used to prove properties of incidence in a plane. Nevertheless, Euclid's Propositions XI.2 and XI.13 make it clear the Greeks knew that a plane is uniquely determined by any of the following data:

  1. by three non-collinear points,
  2. by two straight lines meeting one another,
  3. by a straight line and a point not on that line, and
  4. a point and a line perpendicular to the plane.

Plane Equations

Implicit Equation

Thus, there are many ways to represent a plane P. Some methods work in any dimension, and some work only in 3D. In any dimension, one can always specify 3 non-collinear points V0=(x0,y0,z0), V1=(x1,y1,z1), V2=(x2,y2,z2) as the vertices of a triangle, the most primitive planar object. In 3D, this uniquely defines the plane of points P=(x,y,z) satisfying the implicit equation:

represented as a determinant.

Normal Implicit Equation

In 3 dimensions, another popular and useful representation for a plane P is the normal form that specifies an origin point V0 on P and a “normal” vector n which is perpendicular to P . This representation is useful for computing intersections, resulting in compact and efficient formulas. But, this representation only works in 3D space. In a higher n-dimensional space, this representation defines an (n–1)-dimensional linear subspace. We will not pursue this further here except to say that many of the results for planes in 3D carry over to hyperplanes of n-D space (see [Hanson, 1994] for further information).

In 3D, a normal vector n for P can be computed from any triangle DELTA-V0V1V2 of points on P   as the cross-product n=uxv=... Then, any point P on the plane satisfies the normal implicit equation:



For n=(a,b,c), P=(x,y,z) and d = –(n V0), the equation for the plane is:


So, the xyz-coefficients (a,b,c) of any linear equation for a plane P always give a vector which is perpendicular to the plane. Also, when d = 0, the plane passes through the origin 0 = (0,0,0).

It is often useful to have a unit normal vector for the plane which simplifies some formulas. This is easily done by dividing n by |n|. Then, the associated implicit equation ax+by+cz+d=0 is said to be “normalized. Further, when |n| = 1, the coordinates (a,b,c) of n are also the direction cosines of the angles that the vector n makes with the xyz-axes. Additionally, d is then the perpendicular distance from the origin 0 to the plane, as we will show in the next section.

Parametric Equation

Also in any dimension, similar to the parametric line equation, one can replace either or both of the two specified points V1 and V2 by direction vectors u=V1-V0 and v=V2-V0. Then, given one point V0 on P  and two nonparallel line direction vectors u and v, there is a natural parametric equation for ponts on the plane P ; namely:


where s and t are real numbers which are coordinates within the plane relative to the origin V0 and the basis vectors u and v. And, when s.ge-0, t.ge-0, and s+t.le-1, then P=V(s,t) is inside the triangle T = DELTA-V0V1V2.


The pair of parameters (s,t) is referred to as the parametric coordinate of P=V(s,t) relative to T. The point P is on an edge of T whenever one of the conditions s = 0, t = 0, or s + t = 1 is true (each condition corresponds to one edge). And, the vertices of T are given by: V0=V(0,0), V1=V(1,0), and V2=V(0,1).

Barycentric Coordinates

A similar representation is given by the barycentric coordinates [Coxeter, 1989b] of a point P relative to the triangle T = DELTA-V0V1V2. This method associates a triple (b0,b1,b2) with the centroid of three masses b0, b1, and b2 located at the triangle's three vertices. Negative numbers are treated as negative masses (like helium balloons). This gives:


The triple (b0,b1,b2) is called a “homogeneous barycentric coordinate” for points P relative to the triangle T. The normalized triple (a0,a1,a2) satisfying a0+a1+a2=1 is called the “areal barycentric coordinate” of P. Clearly Eqn_barycentric_areal when a0+a1+a2=1, and thus any triple (a0,a1,a2) which sums to 1 is a valid areal coordinate. Further, there is a one-to-one correspondence between areal coordinates and all points on the plane P . This can be seen by noting the equivalence of areal barycentric and parametric coordinate representations gotten by setting: a0 = (1–st), a1 = s, and a2 = t.

Areal coordinates have a number of useful properties with respect to the triangle T. For example, the point P lies inside T only when all components of its areal barycentric coordinate are nonnegative, that is a0.ge.0, a1.ge.0, and a2.ge.0. Further interesting properties, especially ones related to area ratios, are given by [Coxeter, 1989b].

Representation Conversions

One can convert from any of these representations to another when convenient. For example, given two direction vectors for lines on a plane, their cross-product gives a normal vector. Conversely, given a normal vector, one can easily find two other independent vectors perpendicular to it. For example, given n=(a,b,c) with a.ne.0, then u = (–b, a, 0) and v = (–c, 0, a) are perpendicular to n since both n u = 0 and n v = 0. Further, three non-collinear points on the plane are: V0, V0 + u, and V0 + v. Most other conversions are at least as easy as these. But, one conversion is a bit more difficult; namely, finding the parametric or barycentric coordinates relative to a given triangle.

Barycentric Coordinate Computation

We want to find the parametric or barycentric coordinates (defined above) of a given 3D point P=(x,y,z) relative to a triangle T = DELTA-V0V1V2 in the plane. We start by putting u=V1-V0 and v=V2-V0 as before, as well as w=P-V0. Then, we find the parametric coordinates (s, t) of P as the solution of the equation: w=su+tv. This solution exists and is unique whenever P lies in the plane of T. Further, the areal barycentric coordinates of P=a0V0+a1V1+a2V2 are: a0 = (1–st), a1 = s, and a2 = t which satisfy: a0+a1+a2=1.

To solve the equation w=su+tv, we first define a 3D generalization of Hill's “perp operator” [Hill, 1994].

Definition. Given a 2D plane P embedded in 3D space with a unit normal vector n, and given any vector v in the plane (that is, v satisfies n v = 0), define the “generalized perp operator perp_op on P   by: perp_op-3D_define.

Then, perp_v is another vector in the plane P (since n_dot_perp-v=0), and it is also perpendicular to v (since v_dot_perp-v=0). Additionally, this embedded perp operator is linear for vectors in P ; that is, perp_assoc_rule where v and w are vectors in P, and a and b are scalar numbers. Also, if is the 2D xy-plane (z = 0) with n = (0,0,1), then our 3D perp operator is exactly the same 2D perp operator given by [Hill, 1994]; since we have: perp3D_xy0=xy0-cross-001=-yx0.

We will now solve the equation: w=su+tv for s and t. First, take the dot product of both sides with perp_v to get perp_param_eqn1, and solve for s. Similarly, taking the dot product with perp_u, we get: perp_param_eqn2, and solve for t. Then we have:





The denominators are nonzero whenever the triangle T is nondegenerate (that is, has a nonzero area). When T is degenerate, it is either a segment or a point, and in either case does not uniquely define a plane.

Altogether we have used 3 cross products (one to compute n=u-cross-v) which is a lot of computation. But, we can simplify this with the formula for left association of the cross product; namely, for any three 3D vectors a, b, and c, then cross_prod_left_assoc_abc. [Note: the cross product is not associative, and so there is a different (but similar) formula for right association]. Applying this formula results in the simplifications:


We can now compute the solutions for s and t using only dot products as:



with 5 distinct dot products. The two denominators are the same and only need to be calculated once.

Distance of a Point to a Plane

The distance d(P0,P) from an arbitrary 3D point P0=(x0,y0,z0) to the plane P  given by ax+by+cz+d=0, can be computed by using the dot product to get the projection of the vector P0-V0 onto n as shown in the diagram:


which results in the formula:


When |n| = 1, this formula simplifies to:


showing that d is the distance from the origin 0 = (0,0,0) to the plane P .

This formula gives a signed distance which is positive on one side of the plane and negative on the other. So, one has to take the absolute value to get an absolute distance. Otherwise, the distance is positive for points on the side pointed to by the normal vector n. Because of this, the sign of d(P0,P) can be used to simply test which side of the plane a point is on. For example, if P0P1 is a finite line segment, then it intersects P  only when the two endpoints are on opposite sides of the plane; that is, if Eqn_dP0xdP1.lt.0. Conversely, when Eqn_dP0xdP1.gt.0, there cannot be an intersection. Also, if Eqn_dP0xdP1=0, then at least one of the endpoints is on P.  When both points are on P ,  the whole segment P0P1 lies in the plane.

To compute the distance to a plane P , we did not calculate the base point of the perpendicular from the point P0 to P , which some authors do. If one just wants the distance, then directly computing it without going through an intermediate calculation is fastest.

Nevertheless, there are situations where one wants to know the orthogonal (perpendicular) projection of P0 onto P . It can be computed by taking a line through P0 that is perpendicular to P  (that is, one which is parallel to n), and computing it's intersection with the plane. The simplest such line is given by: P(s)=P0+sn . This line intersects P  when P(s) satisfies the equation of the plane; namely, n_dot_(P(s)-V0)=0. Solving this for s at the intersection point, we get:


And the base of the perpendicular is the intersection point:


For the special case when P0 = 0 = (0,0,0), one has Eqn_plane-0-proj-pt as the orthogonal projection of the origin onto the plane. Then  Eqn_plane-0-proj-dist, and when n is a unit normal  Eqn_plane-0-proj-dist2.


Here are some sample "C++" implementations of these algorithms.

// Copyright 2001 softSurfer, 2012 Dan Sunday
// This code may be freely used and modified for any purpose
// providing that this copyright notice is included with it.
// SoftSurfer makes no warranty for this code, and cannot be held
// liable for any real or imagined damage resulting from its use.
// Users of this code must verify correctness for their application.

// Assume that classes are already given for the objects:
//    Point and Vector with
//        coordinates {float x, y, z;}
//        operators for:
//            Point  = Point Vector
//            Vector = Point - Point
//            Vector = Scalar * Vector    (scalar product)
//    Plane with a point and a normal vector {Point V0; Vector  n;}

// dot product (3D) which  allows vector operations in arguments
#define dot(u,v)   ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z)
#define norm(v)    sqrt(dot(v,v))  // norm = length of  vector
#define d(P,Q)     norm(P-Q)        // distance = norm of difference

// dist_Point_to_Plane(): get distance (and perp base) from a point to a plane
//    Input:  P  = a 3D point
//            PL = a  plane with point V0 and normal n
//    Output: *B = base point on PL of perpendicular from P
//    Return: the distance from P to the plane PL
dist_Point_to_Plane( Point P, Plane PL, Point* B)
    float    sb, sn, sd;

    sn = -dot( PL.n, (P - PL.V0));
    sd = dot(PL.n, PL.n);
    sb = sn / sd;

    *B = P + sb * PL.n;
    return d(P, *B);


Donald Coxeter, "Planes and Hyperplanes" in Introduction to Geometry (2nd Edition) (1989)

Donald Coxeter, "Barycentric Coordinates" in Introduction to Geometry (2nd Edition) (1989)

Euclid, The  Elements, Alexandria (300 BC)

Andrew Hanson, "Geometry for N-Dimensional Graphics" in Graphics Gems IV (1994)

Thomas Heath, The Thirteen Books of Euclid's Elements, Vol 1 (Books I and II) (1956)

Thomas Heath, The  Thirteen Books of Euclid's Elements, Vol 3 (Books X-XIII) (1956)

Francis Hill, "The Pleasures of 'Perp  Dot' Products" in Graphics Gems IV (1994)


© Copyright 2012 Dan Sunday, 2001 softSurfer