79827351

Date: 2025-11-22 13:50:37
Score: 2.5
Natty:
Report link
boolean checkCollision(rect, circle)
{
    closest.x = circle.x;
    closest.y = circle.y;
 
    if (circle.x < rect.x)
        closest.x = rect.x;
    else if (circle.x > rect.x + rect.width)
        closest.x = rect.x + rect.width;
 
    if (circle.y < rect.y)
         closest.y = rect.y;
    else if (circle.y > rect.y + rect.height)
        closest.y = rect.y + rect.height;

    delta.x = circle.x - closest.x;
    delta.x = circle.y - closest.y;

    distanceSquared = delta.x * delta.x + delta.y * delta.y;
    radiusSquared = circle.radius * circle.radius;
    

    return distanceSquared <= radiusSquared;
}

For me this is much more clearer. Can anyone explain the other method, posted here? Sadly it did unformat my pseudo-code in the comment.

Reasons:
  • RegEx Blacklisted phrase (2.5): Can anyone explain
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Stuepfnick