# Distance from a point to a plane

(Redirected from Point on plane closest to origin)

In Euclidean space, the point on a plane ${\displaystyle ax+by+cz=d}$ that is closest to the origin has the Cartesian coordinates ${\displaystyle (x,y,z)}$, where

${\displaystyle \displaystyle x={\frac {ad}{a^{2}+b^{2}+c^{2}}},\quad \quad \displaystyle y={\frac {bd}{a^{2}+b^{2}+c^{2}}},\quad \quad \displaystyle z={\frac {cd}{a^{2}+b^{2}+c^{2}}}}$.[citation needed]

The distance between the origin and point ${\displaystyle (x,y,z)}$ is ${\displaystyle {\sqrt {x^{2}+y^{2}+z^{2}}}}$.

If what is desired is the distance from a point not at the origin to the nearest point on a plane, this can be found by a change of variables that moves the origin to coincide with the given point.

## Converting general problem to distance-from-origin problem

Suppose we wish to find the nearest point on a plane to the point (X0, Y0, Z0), where the plane is given by aX + bY + cZ = D. We define x = X - X0, y = Y - Y0, z = Z - Z0, and d = D - aX0 - bY0 - cZ0, to obtain ax + by + cz = d as the plane expressed in terms of the transformed variables. Now the problem has become one of finding the nearest point on this plane to the origin, and its distance from the origin. The point on the plane in terms of the original coordinates can be found from this point using the above relationships between x and X, between y and Y, and between z and Z; the distance in terms of the original coordinates is the same as the distance in terms of the revised coordinates.

## Restatement using linear algebra

The formula for the closest point to the origin may be expressed more succinctly using notation from linear algebra. The expression ${\displaystyle ax+by+cz}$ in the definition of a plane is a dot product ${\displaystyle (a,b,c)\cdot (x,y,z)}$, and the expression ${\displaystyle a^{2}+b^{2}+c^{2}}$ appearing in the solution is the squared norm ${\displaystyle |(a,b,c)|^{2}}$. Thus, if ${\displaystyle \mathbf {v} =(a,b,c)}$ is a given vector, the plane may be described as the set of vectors ${\displaystyle \mathbf {w} }$ for which ${\displaystyle \mathbf {v} \cdot \mathbf {w} =d}$ and the closest point on this plane is the vector

${\displaystyle \mathbf {p} ={\frac {\mathbf {v} d}{|\mathbf {v} |^{2}}}}$.[1][2]

The Euclidean distance from the origin to the plane is the norm of this point,

${\displaystyle {\frac {d}{|\mathbf {v} |}}={\frac {d}{\sqrt {a^{2}+b^{2}+c^{2}}}}}$.

## Why this is the closest point

In either the coordinate or vector formulations, one may verify that the given point lies on the given plane by plugging the point into the equation of the plane.

To see that it is the closest point to the origin on the plane, observe that ${\displaystyle \mathbf {p} }$ is a scalar multiple of the vector ${\displaystyle \mathbf {v} }$ defining the plane, and is therefore orthogonal to the plane. Thus, if ${\displaystyle \mathbf {q} }$ is any point on the plane other than ${\displaystyle \mathbf {p} }$ itself, then the line segments from the origin to ${\displaystyle \mathbf {p} }$ and from ${\displaystyle \mathbf {p} }$ to ${\displaystyle \mathbf {q} }$ form a right triangle, and by the Pythagorean theorem the distance from the origin to ${\displaystyle q}$ is

${\displaystyle {\sqrt {|\mathbf {p} |^{2}+|\mathbf {p} -\mathbf {q} |^{2}}}}$.

Since ${\displaystyle |\mathbf {p} -\mathbf {q} |^{2}}$ must be a positive number, this distance is greater than ${\displaystyle |\mathbf {p} |}$, the distance from the origin to ${\displaystyle \mathbf {p} }$.[2]

Alternatively, it is possible to rewrite the equation of the plane using dot products with ${\displaystyle \mathbf {p} }$ in place of the original dot product with ${\displaystyle \mathbf {v} }$ (because these two vectors are scalar multiples of each other) after which the fact that ${\displaystyle \mathbf {p} }$ is the closest point becomes an immediate consequence of the Cauchy–Schwarz inequality.[1]

## Closest point and distance for a hyperplane and arbitrary point

The vector equation for a hyperplane in ${\displaystyle n}$-dimensional Euclidean space ${\displaystyle \mathbb {R} ^{n}}$ through a point ${\displaystyle \mathbf {p} }$ with normal vector ${\displaystyle \mathbf {a} \neq \mathbf {0} }$ is ${\displaystyle (\mathbf {x} -\mathbf {p} )\cdot \mathbf {a} =0}$ or ${\displaystyle \mathbf {x} \cdot \mathbf {a} =d}$ where ${\displaystyle d=\mathbf {p} \cdot \mathbf {a} }$.[3] The corresponding Cartesian form is ${\displaystyle a_{1}x_{1}+a_{2}x_{2}+\cdots +a_{n}x_{n}=d}$ where ${\displaystyle d=\mathbf {p} \cdot \mathbf {a} =a_{1}p_{1}+a_{2}p_{2}+\cdots a_{n}p_{n}}$.[3]

The closest point on this hyperplane to an arbitrary point ${\displaystyle \mathbf {y} }$ is

${\displaystyle \mathbf {x} =\mathbf {y} -\left[{\dfrac {(\mathbf {y} -\mathbf {p} )\cdot \mathbf {a} }{\mathbf {a} \cdot \mathbf {a} }}\right]\mathbf {a} =\mathbf {y} -\left[{\dfrac {\mathbf {y} \cdot \mathbf {a} -d}{\mathbf {a} \cdot \mathbf {a} }}\right]\mathbf {a} }$

and the distance from ${\displaystyle \mathbf {y} }$ to the hyperplane is

${\displaystyle \left\|\mathbf {x} -\mathbf {y} \right\|=\left\|\left[{\dfrac {(\mathbf {y} -\mathbf {p} )\cdot \mathbf {a} }{\mathbf {a} \cdot \mathbf {a} }}\right]\mathbf {a} \right\|={\dfrac {\left|(\mathbf {y} -\mathbf {p} )\cdot \mathbf {a} \right|}{\left\|\mathbf {a} \right\|}}={\dfrac {\left|\mathbf {y} \cdot \mathbf {a} -d\right|}{\left\|\mathbf {a} \right\|}}}$.[3]

Written in Cartesian form, the closest point is given by ${\displaystyle x_{i}=y_{i}-ka_{i}}$ for ${\displaystyle 1\leq i\leq n}$ where

${\displaystyle k={\dfrac {\mathbf {y} \cdot \mathbf {a} -d}{\mathbf {a} \cdot \mathbf {a} }}={\dfrac {a_{1}y_{1}+a_{2}y_{2}+\cdots a_{n}y_{n}-d}{a_{1}^{2}+a_{2}^{2}+\cdots a_{n}^{2}}}}$,

and the distance from ${\displaystyle \mathbf {y} }$ to the hyperplane is

${\displaystyle {\dfrac {\left|a_{1}y_{1}+a_{2}y_{2}+\cdots a_{n}y_{n}-d\right|}{\sqrt {a_{1}^{2}+a_{2}^{2}+\cdots a_{n}^{2}}}}}$.

Thus in ${\displaystyle \mathbb {R} ^{3}}$ the point on a plane ${\displaystyle ax+by+cz=d}$ closest to an arbitrary point ${\displaystyle (x_{1},y_{1},z_{1})}$ is ${\displaystyle (x,y,z)}$ given by

${\displaystyle \left.{\begin{array}{l}x=x_{1}-ka\\y=y_{1}-kb\\z=z_{1}-kc\end{array}}\right\}}$

where

${\displaystyle k={\dfrac {ax_{1}+by_{1}+cz_{1}-d}{a^{2}+b^{2}+c^{2}}}}$,

and the distance from the point to the plane is

${\displaystyle {\dfrac {\left|ax_{1}+by_{1}+cz_{1}-d\right|}{\sqrt {a^{2}+b^{2}+c^{2}}}}}$.