import numpy as np
def decode_circle(p1, p2, p3):
x1,y1 = p1
x2,y2 = p2
x3,y3 = p3
D = 2 * np.linalg.det([
[x1, y1, 1],
[x2, y2, 1],
[x3, y3, 1]
])
h = ((x1**2+y1**2)*(y2-y3) +
(x2**2+y2**2)*(y3-y1) +
(x3**2+y3**2)*(y1-y2)) / D
k = ((x1**2+y1**2)*(x3-x2) +
(x2**2+y2**2)*(x1-x3) +
(x3**2+y3**2)*(x2-x1)) / D
r = np.sqrt((x1-h)**2 + (y1-k)**2)
return h, k, r
import numpy as np
def decode_point(x, y, h, k, R):
d = np.sqrt((x - h)**2 + (y - k)**2)
if np.isclose(d, R):
return "on", d
elif d < R:
return "inside", d
else:
return "outside", d
def reconstruct_circle(p1, p2, p3):
x1,y1 = p1
x2,y2 = p2
x3,y3 = p3
D = 2 * np.linalg.det([
[x1, y1, 1],
[x2, y2, 1],
[x3, y3, 1]
])
h = ((x1**2+y1**2)*(y2-y3) +
(x2**2+y2**2)*(y3-y1) +
(x3**2+y3**2)*(y1-y2)) / D
k = ((x1**2+y1**2)*(x3-x2) +
(x2**2+y2**2)*(x1-x3) +
(x3**2+y3**2)*(x2-x1)) / D
R = np.sqrt((x1-h)**2 + (y1-k)**2)
return h, k, R












No comments:
Post a Comment