Circle-Rectangle collision detection (intersection)

Here is how I would do it: bool intersects(CircleType circle, RectType rect) { circleDistance.x = abs(circle.x – rect.x); circleDistance.y = abs(circle.y – rect.y); if (circleDistance.x > (rect.width/2 + circle.r)) { return false; } if (circleDistance.y > (rect.height/2 + circle.r)) { return false; } if (circleDistance.x <= (rect.width/2)) { return true; } if (circleDistance.y <= (rect.height/2)) … Read more