The distance between the center of the spherescircles can be understood as the distance between two points.
You can calculate it as:
dx = p1.x - p2.x
dy = p1.y - p2.y
distance = sqrt(dx*dx + dy*dy)
// where p1 and p2 are two points (x,y) and sqrt is the square root
In your little example, using only the x coordinate:
distance_x = sqrt((p1.x-p2.x)*(p1.x-p2.x))