# Python3 implementation to check if any
# point overlaps the given Circle
# and Rectangle
# Function to check if any point
# overlaps the given Circle
# and Rectangle
def checkOverlap(R, Xc, Yc, X1, Y1, X2, Y2):
# Find the nearest point on the
# rectangle to the center of
# the circle
Xn = max(X1, min(Xc, X2))
Yn = max(Y1, min(Yc, Y2))
# Find the distance between the
# nearest point and the center
# of the circle
# Distance between 2 points,
# (x1, y1) & (x2, y2) in
# 2D Euclidean space is
# ((x1-x2)**2 + (y1-y2)**2)**0.5
Dx = Xn - Xc
Dy = Yn - Yc
return (Dx**2 + Dy**2) <= R**2
# Driver code
if(__name__ == "__main__"):
R = 1
Xc, Yc = 0, 0
X1, Y1 = 1, -1
X2, Y2 = 3, 1
print(checkOverlap(R, Xc, Yc, X1, Y1, X2, Y2))