I implement (in C ++) a detection method when the overlap occurs between two static, axis-oriented shapes in the 2d plane. Shapes are squares or circles, and so there are three cases that I need to consider for overlapping: square square, circle circle, and circle square.
The square square and circle circle were simple enough, but I'm struggling to find any reliable information on the Internet about what the correct algorithm is for calculating the overlap of a square circle.
I know that I could embed the square inside the circle (or vice versa) as a crude method, but I am wondering what would be the cleanest way to do this more accurately?
Researching it on the Internet suggests that there is a βcorrectβ answer to this question, but it is not clear what exactly this answer is.
source share