Python
numpy
programming-contest

Cross points of circles in Python

def arg(p):
  return np.arctan2(p[1], p[0])

def polar(a, r): 
  return [np.cos(r) * a, np.sin(r) * a]

def getCrossPoints(c1, c1r, c2, c2r):
  d = np.linalg.norm(c1-c2)
  a = np.arccos((c1r * c1r + d * d - c2r * c2r) / (2*c1r*d))
  t = arg(c2 - c1) 
  return [c1 + polar(c1r, t-a), c1 + polar(c1r, t+a)]

a = []
a.append(map(int, raw_input().split()))
for aa in a:
    cx = aa[0]
    cy = aa[1]
    r = aa[2]
    c1 = np.array([cx,cy])
    c1r = r 
a = []
a.append(map(int, raw_input().split()))
for aa in a:
    cx = aa[0]
    cy = aa[1]
    r = aa[2]
    c2 = np.array([cx,cy])
    c2r = r 

# print(c1,c1r,c2,c2r)
gcp = getCrossPoints(c1, c1r, c2, c2r)
# gcp = np.sort(gcp,axis=0)
out = ""
for x in gcp:
    for xx in x:
        if (out):
            out = out + " " 
        out = out + str(xx)
print(out)
0 0 2
2 0 2
1.0 -1.73205080757 1.0 1.73205080757

Refs.