Derived Vector Operations
Once you have the dot product and subtraction, a surprising amount of geometry falls out for free. Angle, distance, reflection and smooth interpolation aren't new machinery — they're those two operations wearing different hats.
Step through each on the grid below, using a = (3, 1) and b = (1, 2).
Angle — the dot product, normalized
The dot product already measures "how much two vectors point the same way." Divide it by both lengths and you get exactly the cosine of the angle between them:
cos θ = (a · b) / (|a| · |b|)
Here that's 5 / (√10·√5) ≈ 0.707, so θ ≈ 45°. If the dot product is zero the vectors
are perpendicular; if it's negative they point more than 90° apart.
Distance — the length of a difference
The distance between the two points is just the magnitude of a − b:
dist(a, b) = |a − b| = √((3−1)² + (1−2)²) = √5 ≈ 2.24
Subtraction gives the vector from one point to the other; its length is the distance.
Reflection — project, then go twice as far
To mirror b across the line through a, first project b onto a (the shadow
it casts), then continue the same distance past it:
b′ = 2·proj_a(b) − b = (2, −1)
The two dashed drops in the animation are mirror images across a's line — that's what
makes it a reflection. (Projection itself comes from the
core operations article.)
Lerp — blending one vector into another
Linear interpolation walks in a straight line from a to b:
lerp(a, b, t) = a + t·(b − a)
At t = 0 you're at a, at t = 1 you're at b, and t = 0.5 is the midpoint
(2, 1.5). Sweep t from 0 to 1 and you get smooth motion between the two — the move
behind almost every animation and transition.
Sources
- Lengyel, E. (2011). Mathematics for 3D Game Programming and Computer Graphics (3rd ed.). Cengage. — Dot product, projection, reflection and interpolation.
- Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge. — Angles, lengths and the geometry of the dot product.