Given three circles as
(x - x1)**2 + (y - y1)**2 = r1**2
(x - x2)**2 + (y - y2)**2 = r2**2
(x - x3)**2 + (y - y3)**2 = r3**2
How do I find in python the (x,y) point of intersection of the three circles? More precisely, how can this be robust even when the three circles do not intersect exactly in one point but none?
I have tried by using least_squares from scipy but I am not sure it's working properly since even when the circles actually intercept in one point, it gives another result.
def intersectionPoint(p1,p2,p3):
x1, y1, dist_1 = (p1[0], p1[1], p1[2])
x2, y2, dist_2 = (p2[0], p2[1], p2[2])
x3, y3, dist_3 = (p3[0], p3[1], p3[2])
def eq(g):
x, y, r = g
return (
(x - x1)**2 + (y - y1)**2 - (dist_1 - r )**2,
(x - x2)**2 + (y - y2)**2 - (dist_2 - r )**2,
(x - x3)**2 + (y - y3)**2 - (dist_3 - r )**2)
guess = (100, 100, 0)
ans = scipy.optimize.least_squares(eq, guess)
return ans
ans = intersectionPoint((0,0,9962),(7228,0,9784),(4463,3109,6251))