Vectors, the Dot & Cross Products & Solid Coordinate Geometry

the distance formula in space

On a flat map you find the straight-line distance between two towns with the Pythagorean theorem. In three dimensions — adding height to east and north — the same idea works, you just include one more squared difference. The distance formula in space tells you the true straight-line gap between any two points P and Q given their coordinates.

Set up the 3D Cartesian system with three mutually perpendicular axes x, y, z meeting at the origin O, every point named by a triple (x, y, z). For P = (x_1, y_1, z_1) and Q = (x_2, y_2, z_2), the distance is |PQ| = sqrt((x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2). Where does it come from? The displacement PQ has components (x_2 - x_1, y_2 - y_1, z_2 - z_1), and the distance is just the magnitude of that vector. Geometrically you apply Pythagoras twice: once in the base plane to get the horizontal leg, once more to climb the vertical leg, and the two combine into a single square root of three squared differences.

This formula is the metric backbone of solid coordinate geometry — it is what 'distance' means once points are coordinates, and it powers the equation of a sphere (all points a fixed distance from a centre), the length of a segment, and tests for congruence. It is symmetric, |PQ| = |QP|, and always non-negative. One caution worth stating: it measures the straight-line (Euclidean) distance through space, not a path along a surface — the distance you would fly, not the distance you would drive over hills. Distances measured along curved surfaces are a different and harder notion handled by Riemannian geometry.

The distance between P(1, 2, 3) and Q(4, 6, 3) is |PQ| = sqrt((4 - 1)^2 + (6 - 2)^2 + (3 - 3)^2) = sqrt(9 + 16 + 0) = sqrt(25) = 5. The z-coordinates match, so this reduces to the familiar 3-4-5 right triangle in a horizontal plane.

Pythagoras with one extra squared difference for height.

Square the differences before adding, then take the square root at the very end — students often forget the final root, or take roots of each term separately, which is wrong because sqrt(a + b) is not sqrt(a) + sqrt(b).

Also called
3D distance formulaEuclidean distance in 3D三維距離公式