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

简介: 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 t

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.


 

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
 

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


 

目录
相关文章
|
3月前
利用ellipse and rectangle 画图
【6月更文挑战第30天】利用ellipse and rectangle 画图。
33 1
|
4月前
利用ellipse and rectangle画图
利用ellipse and rectangle画图。
38 7
LeetCode 85. Maximal Rectangle
题意是给定一个二维的零一矩阵,1可以用来围成一些矩阵,题意要求是返回围城矩阵的面积最大值.
75 0
LeetCode 85. Maximal Rectangle
|
机器学习/深度学习
HDOJ/HDU 1556 Color the ball(树状数组)
HDOJ/HDU 1556 Color the ball(树状数组)
97 0