ZOJ 1199 Point of Intersection(平面几何)
来源:互联网 发布:容祖儿 借过知乎 编辑:程序博客网 时间:2024/05/21 17:49
Given two circles on the same plane which are centered at (x1,y1) and (x2,y2) ,with radiuses r1 and r2, respectively.We can see that they have two common tangent lines in most of the cases.Now you are asked to write a programme to calculate the point of intersection of the two tangents if there exists one. ( See Figure 1 )
Figure. 1 Point of intersection
Input
The input data consists of the information of several figures.The first line of the input contains the number of figures.
Each figure is described by two lines of data.Each line contains 3 integers constituting the coordinates of the center (x, y) and the radius r (>0) of a circle.
Output
For each figure, you are supposed to output the coordinates (x, y) of the point of intersection if it exists.The x and y must be rounded to two decimal places and be separated by one space.If there is no such point exists simply output "Impossible."
Sample Input
20 0 100 0 50 0 1010 0 1
Output for the Sample Input
Impossible.11.11 0.00
Notice
The common tangent lines like the following figure don't take into account;
Source: Zhejiang University Local Contest 2002, Preliminary
此题给出两个圆的圆心和半径,如果两圆内含或者两个圆大小相同,则输出impossible.
其余情况根据两个圆心来求出交点坐标
#include<iostream>#include<cstdio>#include<math.h>#include<vector>#include<algorithm>using namespace std;int flag;int b,c;#define eps 1e-6double dis(double x1,double y1,double x2,double y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}int main(){int t;scanf("%d",&t);while(t--){double x1,y1,r1,x2,y2,r2;scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&r1,&x2,&y2,&r2);if(r2>r1){swap(r2,r1);swap(x1,x2);swap(y1,y2);}double d1=dis(x1,y1,x2,y2);if(r2+d1-r1<=eps||r1==r2){printf("Impossible.\n");continue;}double d2=d1/(r1/r2-1);if(x1==x2){if(y1<y2)printf("%.2lf %.2lf\n",x2,y2+d2);else printf("%.2lf %.2lf\n",x2,y2-d2);continue;}else{double k=fabs((y1-y2)/(x1-x2));//double b=(x1*y2-x2*y1)/(x1-x2);double by=d2/sqrt(k*k+1)*k;double bx=d2/sqrt(k*k+1);if(y2>=y1&&x2>=x1){printf("%.2lf %.2lf\n",x2+bx,y2+by);}else if(y2<=y1&&x2>=x1){printf("%.2lf %.2lf\n",x2+bx,y2-by);}else if(y2>=y1&&x2<=x1){printf("%.2lf %.2lf\n",x2-bx,y2+by);}else if(y2<=y1&&x2<=x1){printf("%.2lf %.2lf\n",x2-bx,y2-by);}}}return 0;}
- ZOJ 1199 Point of Intersection(平面几何)
- ZOJ 1199 Point of Intersection
- zoj 1199 Point of Intersection
- ZOJ 1199Point of Intersection
- hdu5476Explore Track of Point+平面几何
- zoj 1199 Point of Intersection 求两个圆公切线的交点
- Point of Intersection
- zoj1199-Point of Intersection
- ZOJ1199-Point of Intersection
- HDU 5476 Explore Track of Point(平面几何)
- HDU 5476 Explore Track of Point(平面几何)
- ZOJ 3198 Intersection of Two Sets
- zoj 3198 Intersection of Two Sets
- ZOJ 3198 Intersection of Two Sets
- hdu5120 Intersection(平面几何+圆相交面积)
- Find the first intersection of two lists (if the two list are merged at some point)
- ZOJ 3862 Intersection
- ZOJ 3862 Intersection (dijkstra)
- [Google Guava] 缓存
- netty5简介
- Android RxJava详解(四)
- J2EE系列之Struts2学习笔记(十)--动态方法调用以及Action的生命周期
- Shell——传递参数
- ZOJ 1199 Point of Intersection(平面几何)
- 68.二叉树的后序遍历
- 数据结构Java实现04----循环链表、仿真链表
- Linux入门(4)——Ubuntu16.04安装MATLAB2016b
- Java异常的深入研究与分析
- javascript中的json对象应用
- C++笔记 --入门
- linux查看服务器设备信息命令dmidecode
- 批处理 打开指定的文件夹