Skip to content

Distance Between a Point and a Line

Definition

The distance between a point A\boldsymbol{A} and a line ℓ(t)\boldsymbol{\ell}(t) is the shortest distance between A\boldsymbol{A} and all points on the line.


Interpretation

The distance from a point to a line is the length of the shortest route from the point to the line. That shortest route is the perpendicular segment: the closest point on the line is the foot F\boldsymbol{F} of the perpendicular from A\boldsymbol{A}.

A line through a point B with direction v, a point A off the line, and the perpendicular from A to its foot F on the line; the length of AF is the distance.

The line passes through B=ℓ(0)\boldsymbol{B}=\boldsymbol{\ell}(0) in the nonzero direction v\boldsymbol{v}. The vector A−B\boldsymbol{A}-\boldsymbol{B} splits into a part along v\boldsymbol{v} (dashed, from B\boldsymbol{B} to F\boldsymbol{F}) and a part perpendicular to v\boldsymbol{v} (green, from F\boldsymbol{F} to A\boldsymbol{A}), and the distance is the length d=∥A−F∥d=\|\boldsymbol{A}-\boldsymbol{F}\| of the second part, where

F=B+(A−B)⋅vv⋅v v.\boldsymbol{F}=\boldsymbol{B}+\frac{(\boldsymbol{A}-\boldsymbol{B})\cdot \boldsymbol{v}}{\boldsymbol{v}\cdot \boldsymbol{v}}\,\boldsymbol{v}.

The foot is the closest point because of Pythagoras. For any other point P\boldsymbol{P} on the line, A−F\boldsymbol{A}-\boldsymbol{F} is orthogonal to F−P\boldsymbol{F}-\boldsymbol{P}, so

∥A−P∥2=∥A−F∥2+∥F−P∥2,\|\boldsymbol{A}-\boldsymbol{P}\|^2=\|\boldsymbol{A}-\boldsymbol{F}\|^2+\|\boldsymbol{F}-\boldsymbol{P}\|^2,

which is larger than ∥A−F∥2\|\boldsymbol{A}-\boldsymbol{F}\|^2 when P≠F\boldsymbol{P}\neq\boldsymbol{F}. The same answer comes from minimizing the quadratic function t↦∥ℓ(t)−A∥2t\mapsto\|\boldsymbol{\ell}(t)-\boldsymbol{A}\|^2 with a derivative. Both arguments work in every Rn\mathbb{R}^n. In R3\mathbb{R}^3 there is also the formula d=∥(A−B)×v∥∥v∥d=\dfrac{\|(\boldsymbol{A}-\boldsymbol{B})\times \boldsymbol{v}\|}{\|\boldsymbol{v}\|}, where a×b=(a2b3−a3b2, a3b1−a1b3, a1b2−a2b1)\boldsymbol{a}\times \boldsymbol{b}=(a_2b_3-a_3b_2,\,a_3b_1-a_1b_3,\,a_1b_2-a_2b_1) is the cross product.

For a plane in R3\mathbb{R}^3 through B\boldsymbol{B} the roles swap: the distance from A\boldsymbol{A} to the plane is the length of the part of A−B\boldsymbol{A}-\boldsymbol{B} along a normal vector, not the part perpendicular to a direction.

A common slip is to take ∥A−B∥\|\boldsymbol{A}-\boldsymbol{B}\|, the distance to the given point B\boldsymbol{B} of the line. It is only an upper bound for dd, reached when B\boldsymbol{B} happens to be the foot.


Key Results

  • The distance is zero if and only if the point lies on the line.
  • In coordinates, the distance can be found by minimizing ∥ℓ(t)−A∥\|\boldsymbol{\ell}(t)-\boldsymbol{A}\|.

Examples

  • For ℓ(t)=(1+t,2t,−1,2−t)\boldsymbol{\ell}(t)=(1+t,2t,-1,2-t), a point on the line gives minimum distance 00.
  • A point not on the line has positive distance.

Prerequisites

Sources

Aliases: point-line distance, distance from a point to a line Symbols: real numbers

Last updated: 27 October 2026 11:52