import math
class Point:
def __init__(self, A, B):
self.x = A
self.y = B
class Line:
def __init__(self, A, B):
self.point_A = A
self.point_B = B
self.kA = B.y - A.y
self.kB = A.x - B.x
self.kC = B.x * A.y - A.x * B.y
class Circle:
def __init__(self, A, B):
self.O = A
self.r = B
def get_distance(P, l):
# TODO: 计算点P到直线l的距离
if l.point_A.x == l.point_B.x:
return abs(P.x - l.point_A.x)
else:
return abs(l.kA * P.x + l.kB * P.y + l.kC)/(math.sqrt(l.kA ** 2 + l.kB ** 2))
def getDistance(circle, l):
# 请在这里实现你的代码
if l.point_A.x == l.point_B.x and l.point_A.y == l.point_B.y:
return circle.r
else:
distance = get_distance(circle.O, l)
if distance >= circle.r:
return 0.0
else:
return math.sqrt(circle.r ** 2 - distance ** 2) * 2
pass
def main():
ox, oy, r = map(float, input().split())
x1, y1, x2, y2 = map(float, input().split())
center = Point(ox, oy)
circle = Circle(center, int(r))
p1 = Point(x1, y1)
p2 = Point(x2, y2)
l = Line(p1, p2)
result = getDistance(circle, l)
print("{:.6f}".format(result))
if __name__ == "__main__":
main()