Academy
Formulas/maths/3d Geometry/Distance Between Two Points

Distance Between Two Points

Distance between P(x₁, y₁, z₁) and Q(x₂, y₂, z₂) in space. Direct extension of the 2D formula using Pythagoras twice.
Derivation

Let P(x1,y1,z1)P(x_1, y_1, z_1) and Q(x2,y2,z2)Q(x_2, y_2, z_2) be two points in space.

Step 1: Drop a perpendicular from PP to the xy-plane, meeting it at A(x1,y1,0)A(x_1, y_1, 0). Similarly B(x2,y2,0)B(x_2, y_2, 0) for QQ.

Step 2: In the xy-plane, AB=(x2x1)2+(y2y1)2AB = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}.

Step 3: PQPQ is the hypotenuse of a right triangle with legs ABAB (horizontal) and z2z1z_2-z_1 (vertical):

PQ=AB2+(z2z1)2=(x2x1)2+(y2y1)2+(z2z1)2PQ = \sqrt{AB^2 + (z_2-z_1)^2} = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}

Distance from origin: For P(x,y,z)P(x, y, z):

OP=x2+y2+z2OP = \sqrt{x^2+y^2+z^2}

Collinearity test: Three points AA, BB, CC are collinear iff AB+BC=ACAB + BC = AC (one distance equals the sum of the other two).