Geometry concepts for Game Development

Distance and angles


The Euclidean distance, our bread and butter.

Representation of the Euclidean distance
The Euclidean distance is the length of the vector that goes from point A to point B.

Note that square roots might be expensive. Sometimes, we don't need the real value of the distance (for instance, when we're trying to compare them). In cases like that, we could just go with:



The Manhattan distance is very fast to compute (no need for a square root) and good for heuristics in path finding. algorithms, etc. Also needed in games where movement occurs in a grid and diagonals are forbidden.

Representation of the Manhattan distance
The Manhattan distance between point A and B is the sum of the deltas of x and y.


We can detect collisions between entities in our game if we surround them in simple geometrical shapes (called bounding boxes) and perform some simple calculus with them.

Circle vs circle

These bounding boxes are useful for game entities that can rotate, since a circle is invariant to rotation.

To check whether two circles are colliding we just need to check whether the distance between their centers is less than the sum of their radii.

Two circles of radii r1 and r2 and a line representing the distance between their centers (d)
Non-colliding circles.

Alternatively, if we want to skip the square root when calculating the distance, we can just do:


Added on: ; Updated on: