Points, Vectors and Affine Space
A level designer drags the harbour's origin from the end of the quay to the foot of the lighthouse. Every position in the level changes its numbers, yet the crate is still 6 m to the right of the drone. Some quantities depend on where you put zero and some don't, and mixing the two up causes real bugs.
The rule
Point − point is a vector. Point + vector is a point.
An affine space has two different kinds of thing in it:
- Points are places: the drone at , a boat at . Their numbers depend on where the origin is.
- Vectors are arrows between places: . They don't care where the origin is.
The legal moves are: point − point = vector; point + vector = point; vector ± vector = vector. Point + point has no meaning. Move the origin 10 m to the left and every x grows by 10, so and . The arrow is still , but jumps from to . A "result" that changes when you move an arbitrary marker isn't a real place.
Points can be blended, as long as the weights add up to 1. is the midpoint , and lerp (linear interpolation), , slides from at to at .
Games keep the two kinds apart with one extra number, : points get and vectors get . So the drone is and the arrow to the boat is . The values follow the same arithmetic as everything else, and in the next lesson they decide what a slide can move.
The shortcut
Tally the w's. Add up the of every term, times its weight. A total of 1 means a point, 0 means a vector, and anything else is a bug.
boat − drone
w: 1 − 1 = 0. A vector: (12, −9), the arrow from the drone to the boat.
The trap is that most engines use a single vector type for both points and arrows, so the compiler won't warn you. The maths still cares. A classic bug: code that moves the drone also shifts its velocity, because the velocity got treated as if it were a place.
Drills
Answer fast — trust the rule.
With points at w = 1 and vectors at w = 0, what is the w of (boat − drone)?
Which expression gives a valid point?
The level designer moves the world origin. Which value stays exactly the same?
What is 0.5 × (2, 11) + 0.5 × (14, 2)?
Remember
- Point − point = vector; point + vector = point; point + point means nothing.
- Blend points only with weights that sum to 1: midpoints and lerp.
- Tally the w's: 1 is a point, 0 is a vector, anything else is a bug.
