Introduction to Three Dimensional Geometry • Topic 2 of 3

Distance Formula in Three Dimensions

The distance between two points in space follows directly from Pythagoras’ theorem applied twice. If $P(x_1, y_1, z_1)$ and $Q(x_2, y_2, z_2)$ are any two points, the distance $PQ$ is the length of the straight segment joining them.

$$PQ = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$$

This is exactly the 2D distance formula with one extra squared term — the $z$-difference — added under the root. Compare the two side by side.

SettingDistance formula
In a plane (2D)$\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$
In space (3D)$\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}$

Distance from the origin: Putting $P = O(0, 0, 0)$ gives a handy special case.

$$OQ = \sqrt{x_2^{\,2} + y_2^{\,2} + z_2^{\,2}}$$

What the formula lets you prove: Because distance is unambiguous, you can settle a great many geometric questions purely by computing lengths. Three points are collinear when the sum of two of the three pairwise distances equals the third. A triangle is isosceles if two sides are equal, equilateral if all three are equal, and right-angled when the three side-lengths satisfy $a^2 + b^2 = c^2$.

Deeper Insight — why one extra term is all you need: The 3D distance formula is not a new idea so much as Pythagoras’ theorem used twice. First imagine the box (rectangular parallelepiped) whose opposite corners are $P$ and $Q$ and whose edges are parallel to the axes; the diagonal of its base has length $\sqrt{(\Delta x)^2 + (\Delta y)^2}$ by the ordinary plane theorem. That base diagonal and the vertical edge of length $|\Delta z|$ are themselves perpendicular, so a second application of Pythagoras gives the space diagonal $\sqrt{(\Delta x)^2 + (\Delta y)^2 + (\Delta z)^2}$. This "Pythagoras twice" argument is why every coordinate dimension contributes its own squared difference, and it generalises cleanly to any number of dimensions. The practical payoff is huge: shape problems that would be hard to picture in space — is this triangle right-angled? are these four points the vertices of a square? — collapse into routine arithmetic the moment you compute a few distances.

Distance between two points P and Q in space Distance PQ in Space x y z O P Q d = PQ The distance formula is Pythagoras applied twice Pythagoras, applied twice base diagonal√((Δx)²+(Δy)²) space diagonal√((Δx)²+(Δy)²+(Δz)²)
1
Worked Example
Find the distance between $P(1, -3, 4)$ and $Q(4, 1, 6)$.
Solution
  1. Differences: $x_2 - x_1 = 3$, $y_2 - y_1 = 4$, $z_2 - z_1 = 2$.
  2. Square and add: $3^2 + 4^2 + 2^2 = 9 + 16 + 4 = 29$.
  3. $PQ = \sqrt{29}$.

Answer: $PQ = \sqrt{29}$ units.

2
Worked Example
Find the distance of the point $A(2, -1, 2)$ from the origin.
Solution
  1. Use $OA = \sqrt{x^2 + y^2 + z^2}$.
  2. $OA = \sqrt{2^2 + (-1)^2 + 2^2} = \sqrt{4 + 1 + 4}$.
  3. $= \sqrt{9} = 3$.

Answer: $OA = 3$ units.

3
Worked Example
Show that the points $A(0, 7, 10)$, $B(-1, 6, 6)$ and $C(-4, 9, 6)$ form a right-angled isosceles triangle.
Solution
  1. $AB^2 = (-1-0)^2 + (6-7)^2 + (6-10)^2 = 1 + 1 + 16 = 18$.
  2. $BC^2 = (-4+1)^2 + (9-6)^2 + (6-6)^2 = 9 + 9 + 0 = 18$.
  3. $CA^2 = (0+4)^2 + (7-9)^2 + (10-6)^2 = 16 + 4 + 16 = 36$.
  4. $AB = BC$ ($= \sqrt{18}$), so the triangle is isosceles. Also $AB^2 + BC^2 = 18 + 18 = 36 = CA^2$, so it is right-angled at $B$.

Answer: $AB = BC = \sqrt{18}$ and $AB^2 + BC^2 = CA^2$, so $\triangle ABC$ is right-angled isosceles.

4
Worked Example
Find the value of $x$ so that the point $P(x, 2, 3)$ is at a distance $5$ from $Q(1, -1, 3)$.
Solution
  1. $PQ^2 = (x-1)^2 + (2+1)^2 + (3-3)^2 = (x-1)^2 + 9$.
  2. Set $PQ = 5$, so $PQ^2 = 25$: $(x-1)^2 + 9 = 25$.
  3. $(x-1)^2 = 16 \Rightarrow x - 1 = \pm 4$.
  4. $x = 5$ or $x = -3$.

Answer: $x = 5$ or $x = -3$.

5
Worked Example
Show that the points $A(-2, 3, 5)$, $B(1, 2, 3)$ and $C(7, 0, -1)$ are collinear.
Solution
  1. $AB = \sqrt{3^2 + (-1)^2 + (-2)^2} = \sqrt{9 + 1 + 4} = \sqrt{14}$.
  2. $BC = \sqrt{6^2 + (-2)^2 + (-4)^2} = \sqrt{36 + 4 + 16} = \sqrt{56} = 2\sqrt{14}$.
  3. $AC = \sqrt{9^2 + (-3)^2 + (-6)^2} = \sqrt{81 + 9 + 36} = \sqrt{126} = 3\sqrt{14}$.
  4. Since $AB + BC = \sqrt{14} + 2\sqrt{14} = 3\sqrt{14} = AC$, the points are collinear.

Answer: $AB + BC = AC$, so $A$, $B$, $C$ are collinear.

6
Worked Example
Find the point on the $y$-axis which is equidistant from $A(3, 1, 2)$ and $B(5, 5, 2)$.
Solution
  1. A point on the $y$-axis has the form $P(0, y, 0)$.
  2. $PA^2 = 9 + (y-1)^2 + 4 = (y-1)^2 + 13$.
  3. $PB^2 = 25 + (y-5)^2 + 4 = (y-5)^2 + 29$.
  4. Set $PA^2 = PB^2$: $(y-1)^2 + 13 = (y-5)^2 + 29 \Rightarrow y^2 - 2y + 14 = y^2 - 10y + 54$.
  5. $8y = 40 \Rightarrow y = 5$.

Answer: The required point is $(0, 5, 0)$.

Key Points

  • Distance: $PQ = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}$ — the 2D formula plus a $z$-term.
  • Distance from origin: $OQ = \sqrt{x^2 + y^2 + z^2}$.
  • Three points are collinear when the largest pairwise distance equals the sum of the other two.
  • Use side-lengths to classify triangles: isosceles (two equal), equilateral (all equal), right-angled ($a^2+b^2=c^2$).
  • The formula is just Pythagoras applied twice — once across the base, once up to the point.
Tap an option to check your answer0 / 4
Q1.The distance of $(a,b,c)$ from the origin is:
Explanation: Distance from origin.
Q2.The distance of $(3,4,12)$ from the origin is:
Explanation: $\sqrt{9+16+144}=13$.
Q3.The distance between $(1,2,3)$ and $(1,2,5)$ is:
Explanation: Only $z$ differs by $2$.
Q4.The 3-D distance formula uses how many coordinate differences?
Explanation: Differences in $x$, $y$ and $z$.