3.6.23D Geometry

Distance formula in 3D

1,473 words7 min readdifficulty · medium4 backlinks

WHAT is it?


WHY is it true? (Derivation from scratch)

We build it ourselves — never just trust the formula.

Step 1 — Drop into a box. Place PP and QQ as opposite corners of an axis-aligned rectangular box (cuboid). The three edges of this box have lengths: a=x2x1,b=y2y1,c=z2z1a = |x_2-x_1|, \quad b = |y_2-y_1|, \quad c=|z_2-z_1|

Why this step? Because the differences in each coordinate are exactly the box edges parallel to the axes — that converts "distance" into a geometry of right angles we already understand.

Step 2 — Pythagoras on the floor. Look only at the bottom face of the box. The diagonal dd of this rectangle (in the xyxy-plane) satisfies: d2=a2+b2d^2 = a^2 + b^2

Why this step? The two edges aa and bb meet at 9090^\circ (x-axis ⟂ y-axis), so the floor diagonal is a plain 2D Pythagoras.

Step 3 — Pythagoras going up. Now the body diagonal PQPQ is the hypotenuse of a new right triangle whose legs are the floor diagonal dd and the vertical edge cc. The vertical edge is perpendicular to the entire floor, so: PQ2=d2+c2=(a2+b2)+c2PQ^2 = d^2 + c^2 = (a^2+b^2) + c^2

Why this step? The z-direction is perpendicular to the whole xyxy-plane, hence perpendicular to dd which lies in that plane — so again Pythagoras applies cleanly.

Step 4 — Substitute back. PQ=a2+b2+c2=(x2x1)2+(y2y1)2+(z2z1)2PQ = \sqrt{a^2+b^2+c^2} = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}

Note: squaring kills the absolute-value signs, so we don't need |\cdot| in the final form.

Figure — Distance formula in 3D

HOW to use it — worked examples


Common mistakes


Recall Feynman: explain to a 12-year-old

Imagine a shoebox. A tiny ant sits in one bottom corner and a crumb is in the opposite top corner. The ant can't walk straight through the box — but we can measure that straight diagonal. First measure across the floor (one Pythagoras using the box's length and width). Then tilt up to the top corner (another Pythagoras using that floor-diagonal and the box's height). Stack those two and you get one neat rule: square the differences in length, width, and height, add them, take the square root. That number is the real straight-line gap.


Active Recall

What is the 3D distance formula between P(x1,y1,z1)P(x_1,y_1,z_1) and Q(x2,y2,z2)Q(x_2,y_2,z_2)?
(x2x1)2+(y2y1)2+(z2z1)2\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}
Distance of point (x,y,z)(x,y,z) from the origin?
x2+y2+z2\sqrt{x^2+y^2+z^2}
Why does order of subtraction not matter in the distance formula?
Because each difference is squared, and squaring removes the sign.
How many times is Pythagoras applied to derive the 3D distance?
Twice — once for the floor diagonal, once going up to the body diagonal.
How do you test if three points A, B, C are collinear using distances?
Check whether the largest distance equals the sum of the other two (e.g. AB+BC=ACAB+BC=AC).
Distance between (1,2,3)(1,-2,3) and (4,2,15)(4,2,15)?
1313
The distance PQPQ equals the magnitude of which vector?
PQ=(x2x1,y2y1,z2z1)\vec{PQ}=(x_2-x_1,\,y_2-y_1,\,z_2-z_1)
If (x,2,1)(x,2,-1) is at distance 3 from (2,4,2)(2,4,-2), find xx.
x=0x=0 or x=4x=4

Connections

  • Coordinate axes and octants in 3D — coordinates that feed this formula.
  • Section formula in 3D — uses these same coordinate differences.
  • Vectors and magnitude — distance = PQ|\vec{PQ}|.
  • Distance formula in 2D — the special case with zz dropped.
  • Direction cosines and direction ratios — built from the same differences.
  • Equation of a sphere — all points at fixed distance from a centre.

Concept Map

add z leg

apply Pythagoras twice

Step 1

edges a b c

Step 2 floor diagonal

Step 3 vertical leg c

substitute back

origin case

equals

AB+BC = AC

2D distance = hypotenuse

3D distance idea

Derivation

Points as box corners

Coord differences

d^2 = a^2 + b^2

PQ^2 = d^2 + c^2

Distance formula PQ

OP = sqrt of x^2+y^2+z^2

Magnitude of vector PQ

Prove collinearity

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, 3D distance formula bilkul Pythagoras ka hi bada bhai hai. 2D mein hum do points ke beech distance nikalte the right triangle ki hypotenuse banaake. 3D mein bas ek extra direction aa gaya — z-axis. Toh hum Pythagoras do baar lagate hain: pehle box ke floor ka diagonal nikalo (d2=a2+b2d^2 = a^2 + b^2), phir us diagonal ke saath height cc ko jodo (PQ2=d2+c2PQ^2 = d^2 + c^2). Final answer: PQ=(x2x1)2+(y2y1)2+(z2z1)2PQ=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}.

Sabse important baat — har coordinate ka difference alag se lo: x ke saath x, y ke saath y, z ke saath z. Phir square karo, add karo, aur end mein square root lena mat bhoolna. Squaring ki wajah se subtract karne ka order matter nahi karta — (x2x1)2(x_2-x_1)^2 aur (x1x2)2(x_1-x_2)^2 same hote hain.

Yeh formula kaafi jagah kaam aata hai: collinearity check karne mein (jab badi distance = baaki do ka sum ho), unknown coordinate dhoondhne mein, aur sphere ka equation banane mein (sphere matlab centre se fixed distance par saare points). Vector language mein, PQPQ bas vector PQ\vec{PQ} ka magnitude PQ|\vec{PQ}| hai — same cheez, doosra naam.

Practice tip: ek shoebox ki picture mind mein rakho. Ant ek corner par, crumb opposite corner par — straight line gap hi distance hai. Yeh dual coding tumhe formula yaad rakhne mein bahut help karega.

Go deeper — visual, from zero

Test yourself — 3D Geometry

Connections