Circular collision detection

One way to detect collision is to see how far each of the objects are from each other's center. This is known as circular collision detection because it treats each object as if it is bound by a circle, and uses the radius of that circle to determine whether the objects are close enough to collide.

Take a look at the following diagram:

Circular collision detection

The circles on the left are not colliding, while the circles on the right are colliding. For the non-colliding circles, the distance (d) between the center points of the two circles is greater than the sum of the two radii (r1 + r2). For the colliding circles, the distance (d) between the ...

Get OpenGL Game Development By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.