推导细节请参考:https://blog.csdn.net/qq_17550379/article/details/78146201
import numpy as np
def circle(x1, y1, x2, y2, x3, y3):
"""
:return: x0 and y0 is center of a circle, r is radius of a circle
"""
a = x1 - x2
b = y1 - y2
c = x1 - x3
d = y1 - y3
a1 = ((x1 * x1 - x2 * x2) + (y1 * y1 - y2 * y2)) / 2.0
a2 = ((x1 * x1 - x3 * x3) + (y1 * y1 - y3 * y3)) / 2.0
theta = b * c - a * d
if abs(theta) < 1e-7:
raise RuntimeError('There should be three different x & y !')
x0 = (b * a2 - d * a1) / theta
y0 = (c * a1 - a * a2) / theta
r = np.sqrt(pow((x1 - x0), 2) + pow((y1 - y0), 2))
return x0, y0, r
x0, y0, r = circle(48.955587, -122.745016, 0, 1, 4, 0)
print("圆心: " + str(x0) + " " + str(y0))
print("圆的半径: " + str(r))