码迷,mamicode.com
首页 > 其他好文 > 详细

计算几何-hdoj-1221-Rectangle and Circle

时间:2014-07-02 07:29:06      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   java   color   

Rectangle and Circle

 

Problem Description
Given 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 centre and radius, and the rectangle is located by one of its diagonal.

bubuko.com,布布扣

 

Input
The 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 centre 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).
Output
For each test case, if the rectangle and the circle intersects, just output "YES" in a single line, or you should output "NO" in a single line.
Sample Input
2 1 1 1 1 2 4 3 1 1 1 1 3 4 4.5

Sample Output
YES NO
 
Source
 

bubuko.com,布布扣分析:圆与矩形有交点的充分必要条件是:点到四个线段的最短距离dmin<=radius && 点到四个线段的最长距离dmax>=radius。


 

计算几何-hdoj-1221-Rectangle and Circle,布布扣,bubuko.com

计算几何-hdoj-1221-Rectangle and Circle

标签:des   style   blog   http   java   color   

原文地址:http://blog.csdn.net/chuchus/article/details/36220153

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!