Uses for Dot Product and Cross Product in Video Games

TIME : 2016-01-07
Uses for Dot Product and Cross Product in Video Games

The dot product is handy for a "half-space test," which tells you whether an object — say, a zombie — is in front of or behind the player/camera. If the player's forward vector is P and the vector from the player to the zombie (zombie position − player position) is Z, then the dot product P · Z gives you the angle between them. A positive result means the player is facing the zombie; otherwise, it's behind you — and you should never turn your back on a zombie!