Skip to content
Family Table Math
Auto

Distances to Lines and Planes

How far is a point from a plane? How close do two skew lines come? “Distance” here always means the shortest distance, which is measured along a perpendicular. Every formula on this page comes from one of two ideas you already know: vector projections and the area of a parallelogram from the cross product.

Suppose QQ is any point on a plane and PP is a point off it. The vector QP→\overrightarrow{QP} usually points off at an angle. The part of it that points straight away from the plane, along the normal n⃗\vec{n}, is exactly the distance you want. That’s the length of the scalar projection of QP→\overrightarrow{QP} onto n⃗\vec{n}:

d=∣QP→⋅n⃗∣∣n⃗∣d = \frac{\left|\overrightarrow{QP} \cdot \vec{n}\right|}{|\vec{n}|}

The absolute value is there because a distance can’t be negative.

The distance d from P to a plane is the length of the projection of QP onto the normal n Q P foot n QP d plane
The distance dd is the length of the projection of QP→\overrightarrow{QP} onto the normal n⃗\vec{n}.

For the line Ax+By+C=0Ax + By + C = 0, the normal is n⃗=[A,B]\vec{n} = [A, B]. Take P(x1,y1)P(x_1, y_1) and any point Q(x0,y0)Q(x_0, y_0) on the line. Then

QP→⋅n⃗=A(x1−x0)+B(y1−y0)=Ax1+By1−(Ax0+By0)=Ax1+By1+C\overrightarrow{QP} \cdot \vec{n} = A(x_1 - x_0) + B(y_1 - y_0) = Ax_1 + By_1 - (Ax_0 + By_0) = Ax_1 + By_1 + C

because Ax0+By0=−CAx_0 + By_0 = -C (QQ is on the line). Dividing by ∣n⃗∣|\vec{n}| gives the standard formula:

d=∣Ax1+By1+C∣A2+B2d = \frac{|Ax_1 + By_1 + C|}{\sqrt{A^2 + B^2}}

The nice thing: you never actually need to find QQ. Substitute the point into the left side of the equation, take the absolute value, and divide by the length of the normal.

Exactly the same argument in 3-space: for the plane Ax+By+Cz+D=0Ax + By + Cz + D = 0 and the point P(x1,y1,z1)P(x_1, y_1, z_1),

d=∣Ax1+By1+Cz1+D∣A2+B2+C2d = \frac{|Ax_1 + By_1 + Cz_1 + D|}{\sqrt{A^2 + B^2 + C^2}}

Between parallel planes (or parallel lines in 2-space)

Section titled “Between parallel planes (or parallel lines in 2-space)”

Parallel planes are the same distance apart everywhere. Pick any point on one plane and use the point-to-plane formula with the other. If the two equations have the same normal, Ax+By+Cz+D1=0Ax + By + Cz + D_1 = 0 and Ax+By+Cz+D2=0Ax + By + Cz + D_2 = 0, this simplifies to

d=∣D1−D2∣A2+B2+C2d = \frac{|D_1 - D_2|}{\sqrt{A^2 + B^2 + C^2}}

The same idea works for two parallel lines in 2-space.

In 3-space a line has no single normal, so use the cross product instead. Let QQ be a point on the line with direction m⃗\vec{m}, and let θ\theta be the angle between QP→\overrightarrow{QP} and m⃗\vec{m}. From the right triangle in the figure, d=∣QP→∣sin⁡θd = |\overrightarrow{QP}| \sin\theta. Since ∣QP→×m⃗∣=∣QP→∣ ∣m⃗∣sin⁡θ|\overrightarrow{QP} \times \vec{m}| = |\overrightarrow{QP}|\,|\vec{m}| \sin\theta,

d=∣QP→×m⃗∣∣m⃗∣d = \frac{\left|\overrightarrow{QP} \times \vec{m}\right|}{|\vec{m}|}

Another way to see it: ∣QP→×m⃗∣\left|\overrightarrow{QP} \times \vec{m}\right| is the area of the parallelogram formed by the two vectors, and area ÷\div base == height.

The distance d from P to a line is the height of the parallelogram formed by QP and m θ Q P m QP d line
The distance dd is the height of the parallelogram formed by QP→\overrightarrow{QP} and m⃗\vec{m}.

Let the lines be r⃗=r⃗1+tm⃗1\vec{r} = \vec{r}_1 + t\vec{m}_1 and r⃗=r⃗2+sm⃗2\vec{r} = \vec{r}_2 + s\vec{m}_2, through points P1P_1 and P2P_2. The shortest segment between skew lines is perpendicular to both lines, so it runs in the direction

n⃗=m⃗1×m⃗2\vec{n} = \vec{m}_1 \times \vec{m}_2

Project the connecting vector P1P2→\overrightarrow{P_1P_2} onto n⃗\vec{n}:

d=∣P1P2→⋅(m⃗1×m⃗2)∣∣m⃗1×m⃗2∣d = \frac{\left|\overrightarrow{P_1P_2} \cdot (\vec{m}_1 \times \vec{m}_2)\right|}{|\vec{m}_1 \times \vec{m}_2|}

This is really the point-to-plane formula again: the two skew lines lie in parallel planes with normal n⃗\vec{n}, and dd is the gap between those planes. If the answer is 00, the lines actually intersect. (For parallel lines, m⃗1×m⃗2=0⃗\vec{m}_1 \times \vec{m}_2 = \vec{0}, so use the point-to-line formula instead.)

DistanceFormula
point to line in 2-space∣Ax1+By1+C∣A2+B2\dfrac{\lvert Ax_1 + By_1 + C \rvert}{\sqrt{A^2 + B^2}}
point to plane∣Ax1+By1+Cz1+D∣A2+B2+C2\dfrac{\lvert Ax_1 + By_1 + Cz_1 + D \rvert}{\sqrt{A^2 + B^2 + C^2}}
point to line in 3-space∣QP→×m⃗∣∣m⃗∣\dfrac{\lvert \overrightarrow{QP} \times \vec{m} \rvert}{\lvert \vec{m} \rvert}
skew lines∣P1P2→⋅(m⃗1×m⃗2)∣∣m⃗1×m⃗2∣\dfrac{\lvert \overrightarrow{P_1P_2} \cdot (\vec{m}_1 \times \vec{m}_2) \rvert}{\lvert \vec{m}_1 \times \vec{m}_2 \rvert}

Find the distance from P(5,3)P(5, 3) to the line 3x−4y+8=03x - 4y + 8 = 0.

Solution.

d=∣3(5)−4(3)+8∣32+(−4)2=∣11∣5=115=2.2d = \frac{|3(5) - 4(3) + 8|}{\sqrt{3^2 + (-4)^2}} = \frac{|11|}{5} = \frac{11}{5} = 2.2

Check with a projection. The point Q(0,2)Q(0, 2) is on the line (0−8+8=00 - 8 + 8 = 0). Then QP→=[5,1]\overrightarrow{QP} = [5, 1] and n⃗=[3,−4]\vec{n} = [3, -4]:

∣[5,1]⋅[3,−4]∣∣[3,−4]∣=∣15−4∣5=115\frac{|[5, 1] \cdot [3, -4]|}{|[3, -4]|} = \frac{|15 - 4|}{5} = \frac{11}{5}

Same answer ✓.

Example 2: Point to a plane, and parallel planes

Section titled “Example 2: Point to a plane, and parallel planes”
  • (a) Find the distance from P(2,−1,4)P(2, -1, 4) to the plane 2x−y+2z−3=02x - y + 2z - 3 = 0.
  • (b) Find the distance between the planes 2x−y+2z−3=02x - y + 2z - 3 = 0 and 4x−2y+4z+9=04x - 2y + 4z + 9 = 0.

Solution.

(a)

d=∣2(2)−(−1)+2(4)−3∣22+(−1)2+22=∣10∣9=103≈3.33d = \frac{|2(2) - (-1) + 2(4) - 3|}{\sqrt{2^2 + (-1)^2 + 2^2}} = \frac{|10|}{\sqrt{9}} = \frac{10}{3} \approx 3.33

(rounded to two decimal places).

(b) The normals [2,−1,2][2, -1, 2] and [4,−2,4][4, -2, 4] are parallel, so the planes are parallel. Pick a point on the first plane: with x=z=0x = z = 0, −y−3=0-y - 3 = 0, so Q(0,−3,0)Q(0, -3, 0). Its distance to the second plane:

d=∣4(0)−2(−3)+4(0)+9∣42+(−2)2+42=1536=156=2.5d = \frac{|4(0) - 2(-3) + 4(0) + 9|}{\sqrt{4^2 + (-2)^2 + 4^2}} = \frac{15}{\sqrt{36}} = \frac{15}{6} = 2.5

Check with the shortcut: divide the second equation by 22 to match normals: 2x−y+2z+4.5=02x - y + 2z + 4.5 = 0. Then d=∣−3−4.5∣3=7.53=2.5d = \dfrac{|-3 - 4.5|}{3} = \dfrac{7.5}{3} = 2.5 ✓.

Find the distance from P(3,1,−2)P(3, 1, -2) to the line r⃗=[1,0,1]+t[2,−1,2]\vec{r} = [1, 0, 1] + t[2, -1, 2].

Solution. Take Q(1,0,1)Q(1, 0, 1) on the line and m⃗=[2,−1,2]\vec{m} = [2, -1, 2]. Then QP→=[2,1,−3]\overrightarrow{QP} = [2, 1, -3], and

QP→×m⃗=[2,1,−3]×[2,−1,2]=[1(2)−(−3)(−1), (−3)(2)−2(2), 2(−1)−1(2)]=[−1,−10,−4]\begin{aligned} \overrightarrow{QP} \times \vec{m} &= [2, 1, -3] \times [2, -1, 2] \\ &= [1(2) - (-3)(-1),\ (-3)(2) - 2(2),\ 2(-1) - 1(2)] \\ &= [-1, -10, -4] \end{aligned} d=(−1)2+(−10)2+(−4)222+(−1)2+22=1173=3133=13≈3.61d = \frac{\sqrt{(-1)^2 + (-10)^2 + (-4)^2}}{\sqrt{2^2 + (-1)^2 + 2^2}} = \frac{\sqrt{117}}{3} = \frac{3\sqrt{13}}{3} = \sqrt{13} \approx 3.61

(rounded to two decimal places).

In intersections of lines and planes, Example 2 showed that these lines are skew. Find the distance between them.

L1:r⃗=[1,0,2]+t[2,1,−1]L2:r⃗=[0,4,1]+s[1,−1,2]L_1: \vec{r} = [1, 0, 2] + t[2, 1, -1] \qquad L_2: \vec{r} = [0, 4, 1] + s[1, -1, 2]

Solution. A vector perpendicular to both lines:

n⃗=[2,1,−1]×[1,−1,2]=[1(2)−(−1)(−1), (−1)(1)−2(2), 2(−1)−1(1)]=[1,−5,−3]\vec{n} = [2, 1, -1] \times [1, -1, 2] = [1(2) - (-1)(-1),\ (-1)(1) - 2(2),\ 2(-1) - 1(1)] = [1, -5, -3]

Connect a point on each line: P1(1,0,2)P_1(1, 0, 2) and P2(0,4,1)P_2(0, 4, 1) give P1P2→=[−1,4,−1]\overrightarrow{P_1P_2} = [-1, 4, -1].

d=∣[−1,4,−1]⋅[1,−5,−3]∣12+(−5)2+(−3)2=∣−1−20+3∣35=1835≈3.04d = \frac{|[-1, 4, -1] \cdot [1, -5, -3]|}{\sqrt{1^2 + (-5)^2 + (-3)^2}} = \frac{|-1 - 20 + 3|}{\sqrt{35}} = \frac{18}{\sqrt{35}} \approx 3.04

(rounded to two decimal places). The answer isn’t 00, which confirms the lines don’t meet.

Dropping the absolute value. The dot product can be negative, depending on which side of the plane the point is on. Distance is always positive (or zero), so take the absolute value.

Forgetting to divide by the length of the normal. ∣Ax1+By1+Cz1+D∣|Ax_1 + By_1 + Cz_1 + D| on its own is not the distance unless ∣n⃗∣=1|\vec{n}| = 1. Divide by A2+B2+C2\sqrt{A^2 + B^2 + C^2}.

Leaving the equation in the wrong form. The formula needs Ax+By+Cz+D=0Ax + By + Cz + D = 0. For a plane written as 2x+3y+6z=142x + 3y + 6z = 14, the constant is D=−14D = -14, not 1414.

Using the shortcut for planes whose normals don’t match. ∣D1−D2∣∣n⃗∣\dfrac{|D_1 - D_2|}{|\vec{n}|} only works when both equations use the same normal. Scale one equation first, or just pick a point on one plane.

Using a dot product for point-to-line distance in 3-space. A line in 3-space has no single normal, so the point-to-plane formula doesn’t apply. Use ∣QP→×m⃗∣∣m⃗∣\dfrac{|\overrightarrow{QP} \times \vec{m}|}{|\vec{m}|}.

Using the skew-line formula on parallel lines. If the lines are parallel, m⃗1×m⃗2=0⃗\vec{m}_1 \times \vec{m}_2 = \vec{0} and you’d divide by zero. Find the distance from a point on one line to the other line instead.

1. (Warm-up) Find the distance from (1,2)(1, 2) to the line 6x+8y−2=06x + 8y - 2 = 0.

Solutiond=∣6(1)+8(2)−2∣36+64=2010=2d = \frac{|6(1) + 8(2) - 2|}{\sqrt{36 + 64}} = \frac{20}{10} = 2

2. (Warm-up) Find the distance from the origin to the plane 2x+3y+6z=142x + 3y + 6z = 14.

Solution

Rewrite as 2x+3y+6z−14=02x + 3y + 6z - 14 = 0:

d=∣0+0+0−14∣4+9+36=147=2d = \frac{|0 + 0 + 0 - 14|}{\sqrt{4 + 9 + 36}} = \frac{14}{7} = 2

3. (Core) Find the distance from (4,−2,1)(4, -2, 1) to the plane x−2y+2z+5=0x - 2y + 2z + 5 = 0.

Solutiond=∣4−2(−2)+2(1)+5∣1+4+4=153=5d = \frac{|4 - 2(-2) + 2(1) + 5|}{\sqrt{1 + 4 + 4}} = \frac{15}{3} = 5

4. (Core) Find the distance between the parallel lines 3x+4y−10=03x + 4y - 10 = 0 and 3x+4y+15=03x + 4y + 15 = 0.

Solution

The point (2,1)(2, 1) is on the first line: 6+4−10=06 + 4 - 10 = 0. Its distance to the second line:

d=∣3(2)+4(1)+15∣9+16=255=5d = \frac{|3(2) + 4(1) + 15|}{\sqrt{9 + 16}} = \frac{25}{5} = 5

(Shortcut: same normal, so d=∣−10−15∣5=5d = \dfrac{|-10 - 15|}{5} = 5.)

5. (Core) Find the distance between the planes x+2y−2z=4x + 2y - 2z = 4 and −2x−4y+4z=10-2x - 4y + 4z = 10.

Solution

Divide the second equation by −2-2: x+2y−2z=−5x + 2y - 2z = -5. Now both planes have normal [1,2,−2][1, 2, -2], and in the form Ax+By+Cz+D=0Ax + By + Cz + D = 0 the constants are D1=−4D_1 = -4 and D2=5D_2 = 5:

d=∣−4−5∣1+4+4=93=3d = \frac{|-4 - 5|}{\sqrt{1 + 4 + 4}} = \frac{9}{3} = 3

6. (Core) Find the distance from P(2,3,−1)P(2, 3, -1) to the line r⃗=[0,1,1]+t[1,2,2]\vec{r} = [0, 1, 1] + t[1, 2, 2].

Solution

Q(0,1,1)Q(0, 1, 1) is on the line, so QP→=[2,2,−2]\overrightarrow{QP} = [2, 2, -2], and m⃗=[1,2,2]\vec{m} = [1, 2, 2].

[2,2,−2]×[1,2,2]=[2(2)−(−2)(2), (−2)(1)−2(2), 2(2)−2(1)]=[8,−6,2][2, 2, -2] \times [1, 2, 2] = [2(2) - (-2)(2),\ (-2)(1) - 2(2),\ 2(2) - 2(1)] = [8, -6, 2]d=64+36+41+4+4=1043=2263≈3.40d = \frac{\sqrt{64 + 36 + 4}}{\sqrt{1 + 4 + 4}} = \frac{\sqrt{104}}{3} = \frac{2\sqrt{26}}{3} \approx 3.40

(rounded to two decimal places).

7. (Core) Find the distance from P(6,−1)P(6, -1) to the line r⃗=[1,2]+t[3,4]\vec{r} = [1, 2] + t[3, 4].

Solution

Convert to scalar form. The direction [3,4][3, 4] gives normal [4,−3][4, -3], so 4x−3y+C=04x - 3y + C = 0. With (1,2)(1, 2): 4−6+C=04 - 6 + C = 0, so C=2C = 2.

d=∣4(6)−3(−1)+2∣16+9=295=5.8d = \frac{|4(6) - 3(-1) + 2|}{\sqrt{16 + 9}} = \frac{29}{5} = 5.8

8. (Challenge) Show that the lines L1:r⃗=[0,0,1]+t[1,1,0]L_1: \vec{r} = [0, 0, 1] + t[1, 1, 0] and L2:r⃗=[2,0,3]+s[0,1,1]L_2: \vec{r} = [2, 0, 3] + s[0, 1, 1] are skew by finding the distance between them.

Solution

The directions aren’t parallel. A common perpendicular:

n⃗=[1,1,0]×[0,1,1]=[1(1)−0(1), 0(0)−1(1), 1(1)−1(0)]=[1,−1,1]\vec{n} = [1, 1, 0] \times [0, 1, 1] = [1(1) - 0(1),\ 0(0) - 1(1),\ 1(1) - 1(0)] = [1, -1, 1]

P1P2→=[2,0,2]\overrightarrow{P_1P_2} = [2, 0, 2], so

d=∣[2,0,2]⋅[1,−1,1]∣3=43≈2.31d = \frac{|[2, 0, 2] \cdot [1, -1, 1]|}{\sqrt{3}} = \frac{4}{\sqrt{3}} \approx 2.31

(rounded to two decimal places). The lines aren’t parallel and the distance isn’t 00, so they never meet: they’re skew.

9. (Challenge) An engineer models a sloped solar panel as part of the plane 2x+2y+z=122x + 2y + z = 12, with distances in metres. A sensor is mounted at S(5,4,9)S(5, 4, 9).

  • (a) How far is the sensor from the plane of the panel?
  • (b) Find the point on the plane closest to the sensor.
Solution

(a)

d=∣2(5)+2(4)+9−12∣4+4+1=153=5 md = \frac{|2(5) + 2(4) + 9 - 12|}{\sqrt{4 + 4 + 1}} = \frac{15}{3} = 5 \text{ m}

(b) Follow the normal from SS: r⃗=[5,4,9]+t[2,2,1]\vec{r} = [5, 4, 9] + t[2, 2, 1]. Substitute into the plane:

2(5+2t)+2(4+2t)+(9+t)=12⇒27+9t=12⇒t=−532(5 + 2t) + 2(4 + 2t) + (9 + t) = 12 \quad\Rightarrow\quad 27 + 9t = 12 \quad\Rightarrow\quad t = -\frac{5}{3}

The closest point is

(5−103, 4−103, 9−53)=(53, 23, 223)\left(5 - \frac{10}{3},\ 4 - \frac{10}{3},\ 9 - \frac{5}{3}\right) = \left(\frac{5}{3},\ \frac{2}{3},\ \frac{22}{3}\right)

Check: 103+43+223=363=12\dfrac{10}{3} + \dfrac{4}{3} + \dfrac{22}{3} = \dfrac{36}{3} = 12 ✓. Also, the distance from SS is ∣t∣ ∣n⃗∣=53(3)=5|t|\,|\vec{n}| = \dfrac{5}{3}(3) = 5 m ✓, matching part (a).