Computational Ry-hdoj-1221-Rectangle and circle

Source: Internet
Author: User
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.


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.