Three-Dimensional Coordinate Systems
Multivariable calculus lives in space, so it starts with a way to name every point of space by three numbers. This lesson sets up precisely: the axes and their orientation, coordinate planes and octants, the distance formula, and the equation of a sphere. It is the ground floor for vectors, lines, planes and surfaces.
Axes, planes and octants
Pick an origin and three mutually perpendicular number lines through it, the -, - and -axes. A point is then the ordered triple of its signed distances along them. The set of all triples is
The axes are arranged by the right-hand rule: curl the fingers of your right hand from the positive -axis toward the positive -axis; your thumb points along the positive -axis. A left-handed system ( flipped) is just as valid as geometry, but every formula that involves orientation, above all the cross product, changes sign.
Each pair of axes spans a coordinate plane:
| Plane | Equation | Contains |
|---|---|---|
| -plane | - and -axes | |
| -plane | - and -axes | |
| -plane | - and -axes |
The three planes cut space into eight octants. The first octant is where ; the others have no standard numbering.
Note: An equation describes different sets in different dimensions. In , is a line. In , is the whole plane parallel to the -plane, because and are free. Always ask "which space am I in?"
Projections
The projection of onto the -plane is , onto the -plane , and onto the -plane . Projection drops one coordinate. It is how 3D data becomes a 2D shadow, and how a top-down minimap is drawn from a 3D level.
The distance formula
Theorem. The distance between and is
Proof sketch. Build a box with and at opposite corners and edges parallel to the axes. Let be the corner that shares with but has the and of . In the horizontal face, the Pythagorean theorem gives . The segment is vertical with length , and triangle has a right angle at . Apply Pythagoras once more: . ∎
The midpoint of is , the coordinate-wise average.
import math
def dist(p, q):
return math.sqrt(sum((b - a) ** 2 for a, b in zip(p, q)))
P1, P2 = (1, -2, 4), (7, 1, 2)
A = (P2[0], P2[1], P1[2]) # box corner used in the proof
print("|P1A| =", dist(P1, A), " |AP2| =", dist(A, P2))
print("Pythagoras:", math.hypot(dist(P1, A), dist(A, P2)))
print("direct :", dist(P1, P2))
print("math.dist :", math.dist(P1, P2))
print("midpoint :", tuple((a + b) / 2 for a, b in zip(P1, P2)))|P1A| = 6.708203932499369 |AP2| = 2.0
Pythagoras: 7.0
direct : 7.0
math.dist : 7.0
midpoint : (4.0, -0.5, 3.0)
The differences satisfy , so the distance is exactly 7.
Spheres
A sphere is the set of points at fixed distance from a centre . Squaring the distance formula gives its equation:
Given an expanded equation such as , complete the square in each variable. The result is a sphere when the right-hand side is positive, a single point when it is zero, and the empty set when it is negative.
import sympy as sp
x, y, z = sp.symbols("x y z", real=True)
expr = x**2 + y**2 + z**2 - 6*x + 2*y - 10*z + 19
# complete the square: x² + Dx = (x + D/2)² − D²/4
D, E, F = -6, 2, -10
h, k, l = sp.Rational(-D, 2), sp.Rational(-E, 2), sp.Rational(-F, 2)
r2 = h**2 + k**2 + l**2 - 19
print("centre:", (h, k, l), " r^2 =", r2, " r =", sp.sqrt(r2))
check = (x - h)**2 + (y - k)**2 + (z - l)**2 - r2
print("same polynomial:", sp.expand(check - expr) == 0)centre: (3, -1, 5) r^2 = 16 r = 4
same polynomial: True
Inequalities describe solids: is the solid ball, and is a spherical shell between radii 1 and 2.
In software
- Handedness. OpenGL, Three.js and most maths texts use right-handed coordinates; Unity and DirectX's traditional conventions are left-handed, and Unreal and Blender put up. Importing a model between tools often needs one axis negated. See Handedness and engine conventions.
- Distance checks. Games compare squared distances (no square root) for "is the enemy within 10 m?": . Bounding spheres, a centre plus a radius, are the cheapest broad-phase collision test (Circles and Spheres).
- Spatial data. Point clouds from LIDAR, molecular coordinates and k-nearest-neighbour search all start from the 3D (or n-D) distance formula.
For a gentler first look at coordinates and vectors, see Vectors.
Exercises
Exercise 1: Which set is it?
Describe in words the set of points in satisfying (a) , (b) and , (c) .
Answer
(a) A plane parallel to the -plane, 2 units behind it. (b) The -axis. (c) A circular cylinder of radius 3 around the -axis.
Solution
(a) Only is fixed; and are free, so it is a plane perpendicular to the -axis through . (b) Two conditions fix and ; only varies, which gives the -axis. (c) In every plane , the points satisfy , a circle of radius 3 centred on the -axis. Stacking these circles for all gives a cylinder.
Exercise 2: Is the triangle right-angled?
Show that , , form a right triangle, and find the vertex with the right angle.
Answer
, , , so the right angle is at .
Solution
By the converse of Pythagoras, the triangle is right-angled exactly when the largest squared side equals the sum of the other two.
A, B, C = (2, 0, 1), (4, 3, 1), (5, -2, 5)
d2 = lambda p, q: sum((b - a) ** 2 for a, b in zip(p, q))
ab, bc, ac = d2(A, B), d2(B, C), d2(A, C)
print("AB^2 =", ab, " BC^2 =", bc, " AC^2 =", ac)
print("right angle at A:", ab + ac == bc)
print("right angle at B:", ab + bc == ac)
print("right angle at C:", bc + ac == ab)AB^2 = 13 BC^2 = 42 AC^2 = 29
right angle at A: True
right angle at B: False
right angle at C: False
Exercise 3: Sphere from a diameter
Find the equation of the sphere that has the segment from to as a diameter.
Answer
Solution
Exercise 4: Point, sphere or nothing? (code)
Write a function that takes from and reports "sphere", "point" or "empty" along with the centre. Test it on , and .
Answer
: point at . : empty. : sphere centre , radius 5.
Solution
Completing the square gives .
from fractions import Fraction as Fr
def classify(D, E, F, G):
c = (Fr(-D, 2), Fr(-E, 2), Fr(-F, 2))
r2 = Fr(D * D + E * E + F * F, 4) - G
kind = "sphere" if r2 > 0 else "point" if r2 == 0 else "empty"
return kind, tuple(str(v) for v in c), str(r2)
for coeffs in [(2, -4, 6, 14), (2, -4, 6, 20), (0, 0, 8, -9)]:
print(coeffs, "->", classify(*coeffs))(2, -4, 6, 14) -> ('point', ('-1', '2', '-3'), '0')
(2, -4, 6, 20) -> ('empty', ('-1', '2', '-3'), '-6')
(0, 0, 8, -9) -> ('sphere', ('0', '0', '-4'), '25')
Test yourself
In , what is the set ?
- A line parallel to the -axis
- A point
- A plane parallel to the -plane
- A sphere of radius 4
What is the distance from to ?
- 7
- 11
- 49
describes…
- the empty set
- a sphere centred at the origin
- a single point
- a sphere of radius 2 centred at