If any point of the circle lies on the rectangle or inside the rectangle we say the circle is overlapping the rectangle.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run. The first line of each test case contains seven space-separated integers ‘xC’, ‘yC’, ‘RAD’, ‘X1’, ‘Y1’, ‘X2’, ‘Y2’ where ‘xC’ and ‘yC’ represents the center coordinates of a circle and ‘RAD’ represents the radius of the circle and ‘X1’, ‘Y1’ represents the coordinates of the bottom left corner and ‘X2’, ‘Y2’ represents the coordinates of the top right corner of the rectangle respectively.
For each test case, print a single line containing ‘True’ if the meteor overlaps with the garden else, print ‘False’. The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5 1 <= RAD <= 2000 -10^4 <= xC, yC, X1, Y1, X2, Y2 <= 10^4 X1 < X2, Y1 < Y2 Where ‘T’ is the number of test cases, ‘xC’ and ‘yC’ represents the center coordinates of a circle and ‘RAD’ represents the radius of the circle and ‘X1’, ‘Y1’ represents the coordinates of the bottom left corner and ‘X2’, ‘Y2’ represents the coordinates of the top right corner of the rectangle. Time Limit: 1 sec
The idea here is to find the nearest point on a rectangle from the circle for this we can use suppose circle lies to the left side of the rectangle so in this case ‘xC < X1’ and if suppose circle lies on the right side ‘xC < X2’ and if it lies inside the rectangle ‘xC > X1’ and ‘xC < x2’ and same goes for ‘Y’ coordinate so we can say the point of intersecting only depends on (X1, Y1) and (X2, Y2) then after finding the nearest point we can simply compare the distance between nearest point and center coordinate and then we can compare it with radius. If radius distance is greater or equal to the distance we can say it is overlapping else we can say they are not.