The main topic: Give a light source, give some circle, to find the projection interval.
, you can find the angle a, through the radius and the PQ distance, and angle B can also be calculated. Then we can find the angle between the two tangent lines and the y-axis, respectively, A+b,b-a.
Then use the angle to find out the left and right vertices of each projection line, and sort and judge.
#include <iostream> #include <algorithm> #include <cmath> #include <cstdio>using namespace std; struct point{double x, y;} P,q;struct node{double L,r;} LINE[505];d ouble Dist (Point p1,point p2) {return sqrt ((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P1.Y-P2.Y));} BOOL CMP (Node N1,node n2) {return n1.l<n2.l;} int main () {int n; Double R; while (scanf ("%d", &n)!=eof&&n) {scanf ("%lf%lf", &p.x,&p.y); for (int i=0;i<n;i++) {scanf ("%lf%lf%lf", &q.x,&q.y,&r); Double D=dist (P,Q); Double A=asin (r/d), B=asin ((p.x-q.x)/d); Double ang1=a+b,ang2=b-a; Line[i].l=p.x-p.y*tan (ANG1); Line[i].r=p.x-p.y*tan (ANG2); } sort (line,line+n,cmp); Double L=LINE[0].L,R=LINE[0].R; for (int i=1;i<n;i++) {if (line[i].l>r) {printf ("%.2f%.2f\n", l,r); L=LINE[I].L; R=LINE[I].R; } else R=max (LINE[I].R,R); } printf ("%.2f%.2f\n\n", l,r); } return 0;}
POJ 1375 intervals (analytic geometry a little outside the circle to find the tangent of the circle)