POJ 1375
2014-07-28 22:27
204 查看
可以通过顶角角度来计算切线与坐标轴的坐标
开始还以为有公式可以算,谁知道原来是解二元一次方程,靠。。
开始还以为有公式可以算,谁知道原来是解二元一次方程,靠。。
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; const int MAX=1050; struct point{ double x; int flag; point(){ flag=0;} }p[MAX]; double dist(double x1,double y1,double x2,double y2){ return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } bool cmp(point A, point B){ if(A.x<B.x)return true; else if(A.x==B.x){ if(A.flag<B.flag) return true; } return false; } int main(){ double lx,ly; int n; double x,y,r; while(scanf("%d",&n)!=EOF){ if(n==0) break; scanf("%lf%lf",&lx,&ly); for(int i=0;i<n;i++){ scanf("%lf%lf%lf",&x,&y,&r); double dis=dist(lx,ly,x,y); double Agle=asin(r/dis); double Bgle=asin((lx-x)/dis); double bx=lx-ly*tan(Agle+Bgle); double ex=lx-ly*tan(Bgle-Agle); p[2*i].x=bx; p[2*i].flag=-1; p[2*i+1].x=ex; p[2*i+1].flag=1; } sort(p,p+2*n,cmp); int now=0; double L; for(int i=0;i<2*n;i++){ if(now==0){ L=p[i].x; } now+=p[i].flag; if(now==0) printf("%0.2f %0.2f\n",L,p[i].x); } printf("\n"); } return 0; }
相关文章推荐
- poj 1375
- POJ 1375 数学几何题
- POJ 1375 Intervals
- zoj 1309 || poj 1375 Intervals
- poj 1375 Intervals 圆的切线
- poj 1375
- POJ 1375 圆的切线
- POJ 1375 圆切线
- poj1375 圆的切线
- POJ 1375 Intervals
- poj 1375 Intervals(计算圆的切线)
- POJ 1375 过一点求圆切线极角
- poj 1375(解析几何)
- POJ1375-Intervals
- POJ 1375 Intervals(解析几何)
- zoj 1375||poj 1230(贪心)
- POJ 1375 Intervals 笔记
- [计算几何]POJ 1375 点对圆的切线+线段重叠
- poj 1375 Intervals(圆外一点到圆的切点)
- [poj] 1375 Interval || 圆的切线&和直线的交点