LerpworksAcademy
On this page

Math and physics › Vectors

Dot product: how much two arrows point the same way

Know first: Vectors: arrows you can add

The dot product turns two arrows into one number: how far one runs along the other. Light on a surface, moss on top of rocks, a guard noticing a player, the bright rim around a silhouette and a character sliding along a wall all rest on it. This lesson shows what the number means in a picture, where the “multiply and add” formula comes from, and why it agrees with the formula that uses a cosine.

Why this matters

Plenty of people remember the formula a.x × b.x + a.y × b.y + a.z × b.z. Far fewer know why it works. Without that, you cannot tell why surface lighting is computed this way, why a moss mask multiplies the normal by “up,” or what to do when the result comes out negative.

The only prerequisite is the lesson on vectors: addition, length and normalizing. You do not even need trigonometry, because the cosine will show up here on its own.

Further in the article

  1. The shadow of one arrow on another
  2. Why “multiply and add” gives a shadow
  3. Cosine: the share that runs along
  4. The sign: in front or behind
  5. Light, moss and rim lighting
  6. Along and across: splitting a movement
  7. Where it breaks
  8. Connections: the same idea in other fields
  9. Key points
  10. Test yourself