Collision of Spheres in Javascript