Circle to circle

Determining if two circles intersect is extremely simple. If the length of a line going from the center of circle A to the center of circle B is less than the sum of the two circles, radii, they intersect. Of course, we want to avoid the expensive square root operation performed when finding the length of a line. To avoid this, we can compare the square length of the line against the square sum of the two circles, radii:

Circle to circle

Getting ready

We are going to implement a function to detect the collision between two circles. To avoid the expensive square root operation involved in finding the distance between two circles, we're going to find ...

Get Game Physics Cookbook 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.