Simple Collision Detection

Sphere-Sphere Collision

Compute distance between the centers of the two spheres. If it's less than the sum of the radii, then there exist points that lie within both spheres -> the spheres overlap.

def SphereCollidesWithSphere(s1, s2):
    d = s1.center.distanceSquared(s2.center)
    rsum = s1.radius + s2.radius
    return (d <= rsum*rsum)