Rectangle and circle
Problem descriptionGiven a rectangle and a circle in the coordinate system (two edges of the rectangle are parallel with the x-axis, and the other two are parallel with the y-axis ), you have to tell if their borders intersect.
Note: We call them intersect even if they are just tangent. The circle is located by its center and radius, and the rectangle is located by one of its diagonal.
InputThe first line of input is a positive integer p which indicates the number of test cases. then P test cases follow. each test cases consists of seven real numbers, they are X, Y, R, X1, Y1, X2, y2. that means the center of a circle is (x, y) and the radius of the circle is R, and one of the rectangle's diagonal is (x1, Y1)-(X2, Y2 ).
Outputfor each test case, if the rectangle and the circle intersects, just output "yes" in a single line, or you shoshould output "no" in a single line.
Sample Input
21 1 1 1 2 4 31 1 1 1 3 4 4.5
Sample output
YESNO
Source Hangzhou University of Electronic Science and Technology's third Program Design Competition
Analysis: a sufficient condition for the intersection of a circle and a rectangle is the shortest distance dmin <= radius & the shortest distance dmax> = radius from a point to four line segments.