## 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:

### 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 the square distance. Because we're comparing the square distance, we also have to square the sum of the circles, radii.

### How to do it…

Follow these steps to implement a collision detection function between two circles:

Declare the

`CircleCircle`

collision function in`Geometry2D.h`

:bool CircleCircle(const Circle& c1, const Circle& c2);

Implement...