Game dev
Saved & recent

Dot product

Takes two vectors and returns one number. For unit vectors that number says how much they point the same way: 1 for the same direction, 0 for a right angle, -1 for opposite.

It answers questions like "is the enemy in front of me?" and "how directly does light hit this surface?". See diffuse lighting.

a · b = ax*bx + ay*by + az*bz

Further reading
LearnOpenGL: Transformations: dot product
+0.5 0 −0.5 signed projection
Project the gold unit vector onto the violet one. At 60°, 90° and 120°, the signed projections are 0.5, 0 and −0.5.

View in the full Game dev collection