I'm trying to write a method that will calculate if two circles are overlapping. I've come up with the following and I'm just curious to know if there is anyway it could be optimised further.
private static boolean isCollision(Point2D p1, float r1, Point2D p2, float r2)
{
float a,dx, dy;
a = (r1+r2) * (r1+r2);
dx = (float) (p1.getX() - p2.getX());
dy = (float) (p1.getY() - p2.getY());
if (a > (dx*dx) + (dy*dy))
{
return true;
}
return false;
}