Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Matrices and Transforms  ›  Lesson

Points, Vectors and Affine Space

Affine Space 12 minIn an affine space a point minus a point is a vector, a point plus a vector is a point, and points may only be blended with weights that add up to one.

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 D=(2,11)D = (2, 11), a boat at B=(14,2)B = (14, 2). Their numbers depend on where the origin is.
  • Vectors are arrows between places: B−D=(12,−9)B - D = (12, -9). 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 D=(12,11)D = (12, 11) and B=(24,2)B = (24, 2). The arrow B−DB - D is still (12,−9)(12, -9), but D+BD + B jumps from (16,13)(16, 13) to (36,13)(36, 13). 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. 0.5D+0.5B0.5D + 0.5B is the midpoint (8,6.5)(8, 6.5), and lerp (linear interpolation), D+t(B−D)=(1−t)D+tBD + t(B - D) = (1 - t)D + tB, slides from DD at t=0t = 0 to BB at t=1t = 1.

Games keep the two kinds apart with one extra number, ww: points get w=1w = 1 and vectors get w=0w = 0. So the drone is (2,11,1)(2, 11, 1) and the arrow to the boat is (12,−9,0)(12, -9, 0). The ww 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 ww of every term, times its weight. A total of 1 means a point, 0 means a vector, and anything else is a bug.

Which expressions are legal?Step 1 of 4
  1. 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.

quick drill

With points at w = 1 and vectors at w = 0, what is the w of (boat − drone)?

quick drill

Which expression gives a valid point?

quick drill

The level designer moves the world origin. Which value stays exactly the same?

Lerp the drone's x = 2 toward the boat's x = 14 with t = 0.25. What x do you get?
2+0.25×(14−2)= ?2 + 0.25 \times (14 - 2) = \,?
quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainA gull between two things

A teammate writes spawn = drone_position + boat_position to place a gull between the drone at (2, 11) and a boat at (14, 2). Explain why this is wrong in affine terms, what goes wrong when the level's origin moves, and write a correct version.