I am implementing (in C++) a method to detect when an overlap is occurring between two static, axis-aligned shapes on a 2d plane. The shapes are either squares or circles, and therefore there are three cases I need to consider for overlap: square-square, circle-circle, and circle-square.
Square-square and circle-circle were simple enough, but I am struggling to find any solid information online about what the correct algorithm is for calculating square-circle overlap.
I am aware that I could embed the square inside a circle (or vice versa) as a rough method, but I'm interested in what would be considered the cleanest way to do this more precisely?
Researching it online suggests there is a 'correct' answer to this question, but it isn't made clear what exactly that answer is.