Ma · Mathematics

How to Find the Perpendicular from the Origin to a Line

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify the line

    Write the line as r = a + t d, where a is a point on it and d is its direction vector.

  2. 2. Find the foot

    Set the vector from the origin to the foot perpendicular to d, so its dot product with d is zero.

  3. 3. Solve for the parameter

    Use t = −(a · d)/|d|² to find the point where the perpendicular meets the line.

  4. 4. Calculate the distance

    The distance from the origin to the line is the magnitude of the foot point vector.

A line’s direction vector and the dot product are enough to find the point on the line closest to the origin. That point is where the perpendicular from the origin meets the line, and its distance from the origin is the shortest distance to the line.

This method works in two or three dimensions. In three dimensions, it identifies the unique closest point; if the line passes through the origin, the distance is zero.

Write the line in vector form

Represent the line as

r=a+td,\mathbf r=\mathbf a+t\mathbf d,

where a\mathbf a is the position vector of a known point on the line, d\mathbf d is a nonzero direction vector, and tt is a real parameter. The point on the line corresponding to tt is a+td\mathbf a+t\mathbf d.

Let h\mathbf h be the position vector of the closest point, or foot of the perpendicular, from the origin to the line. Since h\mathbf h is on the line, it has the form

h=a+td.\mathbf h=\mathbf a+t\mathbf d.

The segment from the origin to this point has direction h\mathbf h. At the closest point, that segment is perpendicular to the line’s direction, so

h⋅d=0.\mathbf h\cdot\mathbf d=0.

This dot-product condition determines the parameter tt.

Derive the parameter and distance

Substitute h=a+td\mathbf h=\mathbf a+t\mathbf d into the perpendicularity condition:

(a+td)⋅d=0,a⋅d+t(d⋅d)=0,t=−a⋅dd⋅d.\begin{aligned} (\mathbf a+t\mathbf d)\cdot\mathbf d&=0,\\ \mathbf a\cdot\mathbf d+t(\mathbf d\cdot\mathbf d)&=0,\\ t&=-\frac{\mathbf a\cdot\mathbf d}{\mathbf d\cdot\mathbf d}. \end{aligned}

Because d⋅d=∣d∣2\mathbf d\cdot\mathbf d=|\mathbf d|^2, the closest-point parameter is

t∗=−a⋅d∣d∣2.t_*=-\frac{\mathbf a\cdot\mathbf d}{|\mathbf d|^2}.

Then calculate the foot and distance:

h=a+t∗d,dist⁡(0,L)=∣h∣.\mathbf h=\mathbf a+t_*\mathbf d, \qquad \operatorname{dist}(0,L)=|\mathbf h|.

The perpendicular segment runs from 0\mathbf 0 to h\mathbf h. If h≠0\mathbf h\ne\mathbf 0, the line through the origin and the foot can be written r=sh\mathbf r=s\mathbf h. Its intersection with the original line is h\mathbf h.

Worked example

Find the foot of the perpendicular from the origin to

r=(2,−1,3)+t(1,2,2),\mathbf r=(2,-1,3)+t(1,2,2),

and find the distance from the origin to the line.

Here a=(2,−1,3)\mathbf a=(2,-1,3) and d=(1,2,2)\mathbf d=(1,2,2). Compute the dot products:

a⋅d=2(1)+(−1)(2)+3(2)=6,∣d∣2=12+22+22=9.\mathbf a\cdot\mathbf d=2(1)+(-1)(2)+3(2)=6, \qquad |\mathbf d|^2=1^2+2^2+2^2=9.

Therefore,

t∗=−69=−23.t_*=-\frac{6}{9}=-\frac{2}{3}.

Substitute this parameter into the line:

h=(2,−1,3)−23(1,2,2)=(43,−73,53).\begin{aligned} \mathbf h&=(2,-1,3)-\frac{2}{3}(1,2,2)\\ &=\left(\frac{4}{3},-\frac{7}{3},\frac{5}{3}\right). \end{aligned}

Check that the foot vector is perpendicular to the direction vector:

h⋅d=43−143+103=0.\mathbf h\cdot\mathbf d=\frac{4}{3}-\frac{14}{3}+\frac{10}{3}=0.

The distance is the length of h\mathbf h:

dist⁡(0,L)=∣h∣=16+49+259=10.\operatorname{dist}(0,L)=|\mathbf h| =\sqrt{\frac{16+49+25}{9}} =\sqrt{10}.

Thus the perpendicular meets the line at (43,−73,53)\left(\frac{4}{3},-\frac{7}{3},\frac{5}{3}\right), and the shortest distance is 10\sqrt{10}.

Common mistakes

  • Using the wrong vector in the dot product: The vector from the origin to a candidate point is a+td\mathbf a+t\mathbf d, not just a\mathbf a. The condition is (a+td)⋅d=0(\mathbf a+t\mathbf d)\cdot\mathbf d=0.
  • Forgetting to square the direction-vector length: The denominator is d⋅d=∣d∣2\mathbf d\cdot\mathbf d=|\mathbf d|^2, not ∣d∣|\mathbf d|.
  • Confusing the parameter with the distance: The value t∗t_* locates the foot on the line. The distance is ∣a+t∗d∣|\mathbf a+t_*\mathbf d|.
  • Assuming the perpendicular through the origin is unique in every case: If the original line passes through the origin, the foot is the origin and the distance is zero. In three dimensions, many lines through the origin are perpendicular to the original line, though the closest point remains uniquely determined.

The same calculation can be viewed as projecting −a-\mathbf a onto the direction d\mathbf d: the parameter shifts from the known point to the foot by the component needed to cancel the part of a\mathbf a along the line.

References

  1. OpenStax, Calculus Volume 3

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.