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 — placed under the root. Because every term is squared, it does not matter which point you call "first": $(x_2 - x_1)^2 = (x_1 - x_2)^2$, so $PQ = QP$. Compare the two settings 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 — here $\sqrt{x^2 + y^2 + z^2}$ is also the length of the space diagonal of the box with edges $|x|, |y|, |z|$.

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

Testing collinearity. Because distance is unambiguous, three points $A$, $B$, $C$ are collinear exactly when the largest of the three pairwise distances equals the sum of the other two — for instance $AB + BC = AC$. If instead $AB + BC > AC$ for every arrangement, the three points form a genuine triangle.

Classifying a triangle by its sides. Once you have the three side-lengths, the type of triangle reads straight off them: isosceles if two sides are equal, equilateral if all three are equal, scalene if all differ, and right-angled when the three lengths satisfy $a^2 + b^2 = c^2$ (the longest side being the hypotenuse $c$).

Result from side-lengthsCondition
Collinear (no triangle)$AB + BC = AC$
Isosceles triangletwo sides equal
Equilateral triangleall three sides equal
Right-angled triangle$a^2 + b^2 = c^2$

A common application is finding a point with a stated distance property — for example a point on an axis equidistant from two given points. Put the unknown point in its general axis form (such as $(0, y, 0)$ on the $y$-axis), set the two squared distances equal, and the square terms cancel to leave a simple linear equation.

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. Imagine the box 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 contributes its own squared difference, and it generalises to any number of dimensions. The practical payoff is large: shape questions that are 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)$.

7
Worked Example
Show that the points $A(1, 2, 3)$, $B(2, 3, 4)$ and $C(0, 1, 2)$ are collinear, and state which point lies between the other two.
Solution
  1. $AB = \sqrt{1^2 + 1^2 + 1^2} = \sqrt{3}$.
  2. $BC = \sqrt{(-2)^2 + (-2)^2 + (-2)^2} = \sqrt{12} = 2\sqrt{3}$.
  3. $AC = \sqrt{(-1)^2 + (-1)^2 + (-1)^2} = \sqrt{3}$.
  4. $AC + AB = \sqrt{3} + \sqrt{3} = 2\sqrt{3} = BC$, so the points are collinear and $A$ lies between $B$ and $C$.

Answer: Collinear, since $BC = AB + AC = 2\sqrt{3}$; the point $A$ lies between $B$ and $C$.

8
Worked Example
Find the point on the $z$-axis equidistant from $A(1, 5, 7)$ and $B(5, 1, -4)$.
Solution
  1. A point on the $z$-axis has the form $P(0, 0, z)$.
  2. $PA^2 = 1 + 25 + (z-7)^2 = (z-7)^2 + 26$.
  3. $PB^2 = 25 + 1 + (z+4)^2 = (z+4)^2 + 26$.
  4. Set equal: $(z-7)^2 = (z+4)^2 \Rightarrow -14z + 49 = 8z + 16$.
  5. $22z = 33 \Rightarrow z = \dfrac{3}{2}$.

Answer: The required point is $\left(0, 0, \dfrac{3}{2}\right)$.

9
Worked Example
Show that the points $A(3, 3, 3)$, $B(0, 6, 3)$, $C(1, 7, 7)$ and $D(4, 4, 7)$ are the vertices of a parallelogram.
Solution
  1. $AB = \sqrt{(-3)^2 + 3^2 + 0^2} = \sqrt{18}$ and $CD = \sqrt{3^2 + (-3)^2 + 0^2} = \sqrt{18}$.
  2. $BC = \sqrt{1^2 + 1^2 + 4^2} = \sqrt{18}$ and $DA = \sqrt{(-1)^2 + (-1)^2 + (-4)^2} = \sqrt{18}$.
  3. Opposite sides are equal: $AB = CD$ and $BC = DA$.
  4. Diagonals: $AC = \sqrt{(-2)^2 + 4^2 + 4^2} = \sqrt{36} = 6$ and $BD = \sqrt{4^2 + (-2)^2 + 4^2} = \sqrt{36} = 6$. Equal diagonals show it is in fact a rectangle (all four sides are also equal here, so a square).

Answer: Opposite sides are equal ($AB = CD$, $BC = DA = \sqrt{18}$), so $ABCD$ is a parallelogram (here even a square, since all sides equal and diagonals equal).

10
Worked Example
Find the locus (equation) of a point $P(x, y, z)$ that is equidistant from $A(1, 2, 3)$ and $B(3, 2, -1)$.
Solution
  1. Equidistant means $PA^2 = PB^2$.
  2. $(x-1)^2 + (y-2)^2 + (z-3)^2 = (x-3)^2 + (y-2)^2 + (z+1)^2$.
  3. Expand and cancel $x^2, y^2, z^2$ and the $(y-2)^2$ terms: $-2x + 1 - 6z + 9 = -6x + 9 + 2z + 1$.
  4. $-2x - 6z + 10 = -6x + 2z + 10 \Rightarrow 4x - 8z = 0 \Rightarrow x = 2z$.

Answer: The locus is the plane $x - 2z = 0$ (the perpendicular bisector plane of $AB$).

11
Worked Example
Find the distance between $A(a, b, c)$ and $B(-a, -b, -c)$, and hence the distance of $(2, -3, 6)$ from its reflection in the origin.
Solution
  1. $AB = \sqrt{(2a)^2 + (2b)^2 + (2c)^2} = 2\sqrt{a^2 + b^2 + c^2}$.
  2. For $(2, -3, 6)$: $a^2 + b^2 + c^2 = 4 + 9 + 36 = 49$.
  3. So the distance $= 2\sqrt{49} = 2 \times 7 = 14$.

Answer: $AB = 2\sqrt{a^2 + b^2 + c^2}$; for $(2, -3, 6)$ the distance is $14$ units.

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; $PQ = QP$.
  • 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.
  • Classify triangles by side-lengths: isosceles (two equal), equilateral (all equal), right-angled ($a^2+b^2=c^2$).
  • For an equidistant point, set the two squared distances equal — the squared terms cancel, leaving a linear equation.
  • 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$.