11.2 Distance between Two Points
Two uses of Pythagoras' theorem give the straight-line distance between $P(x_1,y_1,z_1)$ and $Q(x_2,y_2,z_2)$: $PQ=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}$ โ the diagonal of a box. With it we test collinearity, classify triangles and describe planes and spheres by equations.
During a big cricket match a camera glides over the field hanging from four long cables, each running from a motor on top of a floodlight tower. To move the camera to a new point, a computer works out how long each cable must be and reels it in or lets it out. Every one of those lengths is the straight-line distance between two points in space โ the top of a tower and the camera โ and the computer finds it from their coordinates in a fraction of a second. The same calculation tells a drone pilot how far away the drone is, a chemist how far apart two atoms are in a molecule, and a removal company whether a long pipe will fit diagonally into a van.
In the plane, the distance between $(x_1,y_1)$ and $(x_2,y_2)$ is $\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$: Pythagoras' theorem on the right triangle with horizontal and vertical legs. In space the two points are opposite corners of a rectangular box, and we use Pythagoras twice โ once across the floor of the box and once up its height. The result looks exactly like the plane formula with one more square under the root. In this section we prove it, use it for distances from the origin and from the axes, test whether three points lie on a line, recognise special triangles, and turn distance conditions into equations of planes and spheres.
The Distance Formula in Space
Take $P(x_1,y_1,z_1)$ and $Q(x_2,y_2,z_2)$. Through each point draw the three planes parallel to the coordinate planes. The six planes form a rectangular box with $P$ and $Q$ at opposite corners and edges parallel to the axes, of lengths $|x_2-x_1|$, $|y_2-y_1|$ and $|z_2-z_1|$. The segment $PQ$ is a diagonal running through the inside of this box.
The distance between $P(x_1,y_1,z_1)$ and $Q(x_2,y_2,z_2)$ is $$PQ=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}.$$
Proof. Let $A=(x_2,y_1,z_1)$ and $N=(x_2,y_2,z_1)$, two more corners of the box. The points $P$, $A$, $N$ all have $z$-coordinate $z_1$, so they lie in the horizontal plane $z=z_1$. In that plane $PA$ is parallel to the $x$-axis with length $|x_2-x_1|$, $AN$ is parallel to the $y$-axis with length $|y_2-y_1|$, and the angle $PAN$ is a right angle. By Pythagoras' theorem in triangle $PAN$, $$PN^2=(x_2-x_1)^2+(y_2-y_1)^2.$$ Next, $N$ and $Q$ differ only in their $z$-coordinates, so $NQ$ is parallel to the $z$-axis, with length $|z_2-z_1|$. A vertical line is perpendicular to every line in the horizontal plane $z=z_1$, in particular to $PN$; so angle $PNQ$ is a right angle. Pythagoras' theorem in triangle $PNQ$ gives $$PQ^2=PN^2+NQ^2=(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2.$$ Taking the positive square root proves the formula. $\blacksquare$
The order of the points does not matter, because $(x_1-x_2)^2=(x_2-x_1)^2$; and nor do the signs of the coordinates โ just subtract carefully. When $z_1=z_2$ the formula reduces to the plane distance formula, as it should.
For a point $P(x,y,z)$:
- its distance from the origin is $OP=\sqrt{x^2+y^2+z^2}$;
- its distance from the $z$-axis is $\sqrt{x^2+y^2}$, from the $x$-axis $\sqrt{y^2+z^2}$, and from the $y$-axis $\sqrt{z^2+x^2}$.
Proof. The first is Theorem 11.2 with $Q=O(0,0,0)$. For the second, the foot of the perpendicular from $P$ to the $z$-axis is $C(0,0,z)$ (Section 11.1), so the distance from the axis is $PC=\sqrt{x^2+y^2+0^2}$; the other two axes are the same with the letters moved round. $\blacksquare$
Notice the pattern: the distance from an axis uses the two coordinates other than that axis's own, while the distance from a coordinate plane (Section 11.1) uses only the one coordinate measured from it.
(a) $P(1,-3,4)$ and $Q(-4,1,2)$; (b) the origin and $R(2,-6,3)$; (c) $A(2,-1,3)$ and $B(-2,1,3)$.
1. Sign slips in the differences. For $(1,-3,4)$ and $(-4,1,2)$, $\Delta y=1-(-3)=4$, not $-2$. Write each difference in brackets before squaring.
2. Adding coordinates instead of subtracting. The formula uses $x_2-x_1$, never $x_2+x_1$.
3. Forgetting the third square. $\sqrt{(\Delta x)^2+(\Delta y)^2}$ is only the floor diagonal $PN$; the distance in space needs $(\Delta z)^2$ as well.
4. Taking the root term by term. $\sqrt{9+16+144}=13$, but $\sqrt9+\sqrt{16}+\sqrt{144}=19$ is the length of the path along three edges of the box, not the straight line.
5. Mixing up "from an axis" and "from a plane". $P(3,-4,12)$ is $5$ from the $z$-axis but $12$ from the $XY$-plane.
Collinear Points and Special Triangles
For any three points $A$, $B$, $C$, the straight route from $A$ to $C$ is never longer than the detour through $B$: $AC\le AB+BC$. Equality holds exactly when $B$ lies on the segment $AC$. So three points are collinear exactly when the longest of the three distances between them equals the sum of the other two โ and then the point not at an end of the longest distance is the one in the middle. If the longest distance is less than the sum of the other two, the points are the corners of a genuine triangle, and its side lengths tell us its type.
- Find $AB$, $BC$ and $CA$ with Theorem 11.2. Keep surds exact and simplify them (e.g. $\sqrt{56}=2\sqrt{14}$) so that sums are easy to compare.
- Collinear? If the largest distance equals the sum of the other two, the points are collinear; the middle point is the one shared by the two shorter distances.
- Otherwise a triangle. Two sides equal โ isosceles; all three equal โ equilateral; the squares satisfy $a^2+b^2=c^2$ for the longest side $c$ โ right-angled, with the right angle opposite $c$ (converse of Pythagoras' theorem).
- Answer in words: "collinear, with $B$ between $A$ and $C$", or "a right-angled isosceles triangle with the right angle at $B$".
(b) Show that $P(1,0,0)$, $Q(0,1,0)$, $R(0,0,1)$ form an equilateral triangle, and find its perimeter.
(b) The distance between $A(2,-1,3)$ and $B(a,3,-1)$ is $9$. Find $a$.
Sets of Points Defined by Distances
A condition on distances picks out a set of points, and the distance formula turns the condition into an equation in $x$, $y$, $z$. Two cases are especially important.
The sphere with centre $C(a,b,c)$ and radius $r\gt0$ is the set of all points of space at distance $r$ from $C$. By Theorem 11.2, $P(x,y,z)$ lies on it exactly when $$(x-a)^2+(y-b)^2+(z-c)^2=r^2.$$ Points with $(x-a)^2+(y-b)^2+(z-c)^2\lt r^2$ lie inside the sphere and points with a larger value lie outside.
Points equidistant from two points. If $A$ and $B$ are fixed, the condition $PA=PB$ is equivalent to $PA^2=PB^2$ (both sides are non-negative). When both squares are expanded, the terms $x^2$, $y^2$, $z^2$ appear on both sides and cancel, leaving a linear equation $px+qy+rz+d=0$. In the plane the points equidistant from $A$ and $B$ formed the perpendicular bisector โ a line; in space they form a plane, the plane that cuts $AB$ at right angles through its middle.
(b) Write the equation of the sphere with centre $(1,-2,3)$ and radius $4$ in expanded form, and show that $(1,2,3)$ lies on it.
Other distance conditions give other surfaces. For instance, the points whose distances from two fixed points add up to a constant form an egg-shaped surface (an ellipsoid) โ the three-dimensional cousin of the ellipse of Chapter 10. Exercise III.5 asks you to find one.
Taught and tested in school, but not in the year-end board exam; JEE Main and JEE Advanced both list the section formula in three dimensions, and JEE problems use the centroid that comes with it. Both work exactly as in the plane, with a third coordinate.
Section formula. The point $R$ dividing the join of $P(x_1,y_1,z_1)$ and $Q(x_2,y_2,z_2)$ internally in the ratio $m:n$ is $$R\left(\frac{mx_2+nx_1}{m+n},\ \frac{my_2+ny_1}{m+n},\ \frac{mz_2+nz_1}{m+n}\right).$$ (Project onto each axis: each coordinate is divided in the same ratio $m:n$.) With $m=n$ this is the mid-point $\left(\tfrac{x_1+x_2}{2},\tfrac{y_1+y_2}{2},\tfrac{z_1+z_2}{2}\right)$. The centroid of the triangle with vertices $(x_i,y_i,z_i)$, $i=1,2,3$, is $\left(\tfrac{x_1+x_2+x_3}{3},\tfrac{y_1+y_2+y_3}{3},\tfrac{z_1+z_2+z_3}{3}\right)$.
Worked example. Find the point dividing the join of $A(1,-2,3)$ and $B(3,4,-5)$ internally in the ratio $2:3$.
Solution. $m=2$, $n=3$: $\left(\tfrac{2\cdot3+3\cdot1}{5},\tfrac{2\cdot4+3(-2)}{5},\tfrac{2(-5)+3\cdot3}{5}\right)=\left(\tfrac95,\tfrac25,-\tfrac15\right)$. Check: its distances from $A$ and $B$ are $\tfrac{2}{5}AB$ and $\tfrac35AB$, with $AB=\sqrt{4+36+64}=2\sqrt{26}$ โ.
Exercises
- 1 Find the distance between $(2,3,5)$ and $(4,3,1)$.
- 2 Find the distance between $(-3,7,2)$ and $(2,4,-1)$.
- 3 Find the distance between $(-1,3,-4)$ and $(1,-3,4)$.
- 4 Find the distance between $(5,-2,-3)$ and $(-1,1,3)$.
- 5 Find the distance of $(-6,2,-3)$ from the origin.
- 6 Find the distance of $P(-8,4,1)$ from the origin and from each of the three axes.
- 7 Find $a$ if the distance between $(a,0,1)$ and $(0,1,2)$ is $\sqrt{27}$.
- 8 Find the points on the $x$-axis at distance $13$ from $(2,3,4)$.
- 1 Show that $P(1,-2,3)$, $Q(2,1,1)$ and $R(4,7,-3)$ are collinear, and say which point is between the other two.
- 2 Are $A(0,1,2)$, $B(1,3,4)$ and $C(2,4,5)$ collinear?
- 3 Show that $A(0,7,10)$, $B(-1,6,6)$ and $C(-4,9,6)$ are the vertices of a right-angled isosceles triangle.
- 4 Show that $(1,2,3)$, $(3,2,1)$ and $(1,4,1)$ are the vertices of an equilateral triangle.
- 5 Find the perimeter of the triangle with vertices $O(0,0,0)$, $A(3,4,0)$ and $B(3,4,12)$, and show that it is right-angled.
- 6 Find the point on the $z$-axis equidistant from $(1,5,7)$ and $(5,1,-4)$.
- 7 Find the point in the $XY$-plane that is equidistant from $(2,0,3)$, $(0,3,2)$ and $(0,0,1)$.
- 8 Find the point equidistant from the four points $O(0,0,0)$, $A(a,0,0)$, $B(0,b,0)$ and $C(0,0,c)$.
- 1 Find the equation of the set of points equidistant from $(1,2,3)$ and $(3,2,-1)$.
- 2 Write the equation of the sphere with centre $(2,-3,1)$ and radius $5$ in expanded form.
- 3 Decide whether $(5,1,1)$ and $(4,0,4)$ lie on, inside or outside the sphere of part 2.
- 4 Find the centre and radius of the sphere $x^2+y^2+z^2-6x+4y-2z-11=0$.
- 5 $A=(0,3,0)$ and $B=(0,-3,0)$. Find the equation of the set of points $P$ with $PA+PB=10$.
- 6 $A=(1,2,0)$ and $B=(-1,0,4)$. Find the equation of the set of points $P$ with $PA^2+PB^2=30$, and show that it is a sphere; find its centre and radius.
- 1 In a stadium the origin is the centre of the ground, the $z$-axis is vertical and the unit is $1\ \text{m}$. A cable camera is at $C(10,-20,15)$ and one of its cables runs to a pulley at $T(60,40,45)$ on a tower. Find the length of that cable, to the nearest $0.1\ \text{m}$.
- 2 A room is $5\ \text{m}$ long, $4\ \text{m}$ wide and $3\ \text{m}$ high. What is the longest straight rod that fits in it?
- 3 A drone flies in a straight line from $A(0,0,20)$ to $B(30,40,20)$ and then straight up to $C(30,40,60)$ (metres). Find the length of its path and the length of the direct flight from $A$ to $C$.
- 4 A radar station (in km, $z$ up) shows two aircraft at $(-12,5,3)$ and $(4,-7,3.5)$. How far apart are they, to three significant figures?
- 5 In a model of a methane molecule the carbon atom is at the origin and the hydrogen atoms at $(1,1,1)$, $(1,-1,-1)$, $(-1,1,-1)$ and $(-1,-1,1)$. Show that all four CโH distances are equal, and that all six HโH distances are equal.
How this is examined: Board papers ask for a distance or a distance from an axis (1 mark), a proof that three points are collinear or form a right-angled or isosceles triangle (2โ3 marks), an equation from a distance condition (3 marks), and case studies on cables, drones or rooms. JEE Main mixes the distance formula with the 3-D section formula and centroid (see the ๐ box).
E1. Board ยท 1 mark The distance of $(3,-4,5)$ from the origin is (A) $5\sqrt2$ (B) $50$ (C) $5$ (D) $12$
E2. Board ยท 1 mark The distance of the point $(-2,6,3)$ from the $x$-axis is (A) $2$ (B) $3\sqrt5$ (C) $7$ (D) $\sqrt{13}$
E3. Board ยท 3 marks Using the distance formula, show that $A(3,-5,1)$, $B(2,-3,3)$ and $C(0,1,7)$ are collinear.
E4. Board ยท Case study A cable camera hangs over a football ground. Take the origin at the centre of the ground, the $z$-axis vertical and the unit $1\ \text{m}$. Two cable pulleys are at $T_1(50,40,30)$ and $T_2(-50,40,30)$ on top of two towers, and the camera is at $C(10,20,10)$. (i) Find the length $CT_1$ in simplest surd form. (1 mark) (ii) Find $CT_2$. (1 mark) (iii) The camera is moved along the vertical line through $(10,20,0)$ until $CT_1=45\ \text{m}$. Find the possible heights of the camera. (2 marks)
E5. JEE Main The point on the $x$-axis equidistant from $(1,2,3)$ and $(3,5,-2)$ is (A) $(6,0,0)$ (B) $(-6,0,0)$ (C) $\left(\tfrac32,0,0\right)$ (D) $(2,0,0)$
E6. JEE Main Numerical answer. The vertices of a triangle are $A(3,-1,2)$, $B(1,2,-4)$ and $C(-1,5,8)$. Find the distance of its centroid from the origin.
Research question. How long must the cables of a model cable camera be to put the camera at a chosen point โ and does the distance formula predict the lengths you actually measure?
Why it matters. Cable cameras in stadiums, cable-driven robots in warehouses and the tension cables of suspension structures are all controlled by distances in space. An error in one coordinate changes every cable length, so engineers check their models against measurements.
What to do.
- In a room (or a large cardboard box), choose a floor corner as $O$ with right-handed axes. Fix four "pulleys" (hooks or drawing pins) high up near the four corners and measure their coordinates.
- Hang a small weight (the "camera") from four strings tied to the hooks. Measure the coordinates of the weight with a tape measure: distances from two walls and the height above the floor.
- Predict the four string lengths with the distance formula, then measure them. Record the percentage error for each.
- Move the camera to two more positions and repeat. Which coordinate is hardest to measure accurately, and how much does a $1\ \text{cm}$ error in it change the predicted lengths?
Tools: String, a small weight, four hooks or pins, a measuring tape, a spreadsheet for the calculations
Hand in: A labelled sketch with coordinates, a table of predicted and measured lengths with percentage errors, and a short paragraph explaining the main sources of error.
Going further. Write a spreadsheet that takes the camera's target $(x,y,z)$ and outputs all four cable lengths. Then plan a straight-line move of the camera in $10$ equal steps and tabulate how each cable must change. Do the cables change at a constant rate?
๐งช Self-check quiz
Q1. The distance between $(1,2,3)$ and $(4,6,3)$ is
Q2. The distance of $(2,-3,6)$ from the origin is
Q3. The distance of $P(x,y,z)$ from the $z$-axis is
Q4. For three points, $AB=\sqrt{14}$, $BC=2\sqrt{14}$ and $AC=3\sqrt{14}$. Then
Q5. The set of all points equidistant from $(0,0,1)$ and $(0,0,-1)$ is