This link is very helpful!
Collisions of round circles
It is very detailed and didactic.
There are still links at the bottom of this page, even more detailed information!
I used the Distance Between Centers --- Circles method
By measuring the distance between each center, you can tell if they collide. The distance must never be greater than the sum of radius 2.
Here is what I did:
private boolean checkDrawContains(ShapeDrawable newHole) { long newCenterX = newHole.getBounds().left + (newHole.getBounds().width()/2); //Get the center of my shapes long newCenterY = newHole.getBounds().top + (newHole.getBounds().height()/2); for(ShapeDrawable hole: mHoles) // I was storing the circles in an ArrayList { long centerX = hole.getBounds().left + (hole.getBounds().width()/2); //Get the center of my shapes long centerY = hole.getBounds().top + (hole.getBounds().height()/2); long x = centerX - newCenterX; long y = centerY - newCenterY; long aux = (long) ((Math.pow(Math.abs(x),2)) + (Math.pow(Math.abs(y),2))); //Pythagoras the hard way :P long distance = (long) Math.sqrt(aux); long sRads = (newHole.getBounds().width()/2) + (hole.getBounds().width()/2); if(distance <= sRads ) { return true; //Is Colliding! } } return false; // Is not Colliding! }
source share