zoj 1199 Point of Intersection 求两个圆公切线的交点
来源:互联网 发布:7u分享网络注册 编辑:程序博客网 时间:2024/05/21 22:35
题目来源:
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=199
分析:
两个圆,不存在交点的情况。
1)在 半径相同的情况下, 两条公切线 是平行的, 不存在交点。
2)当一个圆在另一个圆内时, 不存在交点。
当存在交点时, 计算 交点的坐标。 我们用三角形的相似,计算出x,y 值。
x = (p2.x * r1 - p1.x * r2 ) / (r1 - r2) ,
y = (p2.y * r1 - p1.y * r2) / (r1 - r2))
代码如下:
double add(double a, double b){ return (fabs(a+b) < EPS * (fabs(a) + fabs(b))) ? 0 : (a + b) ;}struct Point{ double x, y ; Point(){} Point(double x, double y):x(x),y(y){}} ;double dist(Point a, Point b){ return sqrt(add( (a.x - b.x)*(a.x - b.x) ,(a.y - b.y)*(a.y - b.y) )) ;}double r1 ,r2 ;Point p1, p2;bool is_insection(){ if(r1 == r2) return 0 ; if(dist(p1, p2) <= fabs(r1 - r2)) return 0 ; return 1;}Point tangle_p(){ return Point((p2.x * r1 - p1.x * r2 ) / (r1 - r2) , (p2.y * r1 - p1.y * r2) / (r1 - r2)) ;}int main(){ int t; cin>>t; while(t--){ scanf("%lf%lf%lf%lf%lf%lf", &p1.x , &p1.y, &r1 ,&p2.x , &p2.y , &r2) ; if(is_insection()){ Point p = tangle_p(); printf("%.2lf %.2lf\n" , p.x , p.y) ; } else printf("Impossible.\n"); }}
0 0
- zoj 1199 Point of Intersection 求两个圆公切线的交点
- ZOJ 1199 Point of Intersection
- zoj 1199 Point of Intersection
- ZOJ 1199Point of Intersection
- ZOJ 1199 Point of Intersection(平面几何)
- 160 Intersection of Two Linked Lists 求两个链表的交点
- 如何找到两个圆的公切线?
- LeetCode OJ 之 Intersection of Two Linked Lists (两个链表的交点)
- LeetCode--Intersection of Two Linked Lists (两个链表的交点)Python
- How Many Points of Intersection? ——求交点问题
- Intersection of Two Arrays--求两个向量的交集
- 求两个单链表的交点
- 求两个单链表的交点
- Point of Intersection
- zoj1199-Point of Intersection
- ZOJ1199-Point of Intersection
- 求两个相交圆的交点的公式
- 求过圆心直线与圆的两个交点
- zoj 1041 Transmitters 判断一个可以移动的半圆最多可容纳的点的个数
- zoj 1081 Points Within 判断点是否在任意多边形内(模板)
- Objective-C 线性表
- foj 2148 Moon Game 判断n个点有几个凸四边形 + 枚举4个点 + 判断点在三角形外
- poj 1584 A Round Peg in a Ground Hole 判断多边形是否为凸多边形 + 圆心是否在凸多边形内 + 圆是否在凸多边形内部
- zoj 1199 Point of Intersection 求两个圆公切线的交点
- zoj 1439 Area Ratio 计算三角形内接圆面积和外接圆面积之比
- zoj 1608 Two Circles and a Rectangle 判断两个圆是否能放入一个矩形中
- zoj 1806 This Takes the Cake 计算凸四边形和三角形的面积
- zoj 1904 Beavergnaw 计算圆柱和圆台的体积
- 大数相加
- hdu 2516 FIB博弈模型
- hdu 2897 巴什博弈变形
- hdu 3032 SG(打表找规律) 石子可以 任意取 或分割成非空的两堆