Link
It looks like this is called resolution ry.
How to obtain the X coordinate between the intersection of the tangent from the light source to the Circle and the floor can be calculated by angle and distance ,,
Angle A, B, and r can be obtained based on the distance and radius, and D1, d2.
As for the direction problem, we can make r = Asin (P. x-c.x)/d) P as the source point, C as the center of the circle, and D as the distance between two points.
If it is in the inverse direction, the natural R is a negative angle and does not affect the final result.
After sorting, the statistical interval is enough.
1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<vector> 7 #include<cmath> 8 #include<queue> 9 #include<set>10 using namespace std;11 #define N 50512 #define LL long long13 #define INF 0xfffffff14 const double eps = 1e-8;15 const double pi = acos(-1.0);16 const double inf = ~0u>>2;17 struct point18 {19 double x,y;20 double r;21 point(double x=0,double y=0):x(x),y(y){}22 }p[N];23 struct node24 {25 double l,r;26 }li[N],ans[N];27 typedef point pointt;28 pointt operator -(point a,point b)29 {30 return point(a.x-b.x,a.y-b.y);31 }32 double dis(point a)33 {34 return sqrt(a.x*a.x+a.y*a.y);35 }36 node cal(point a,point b)37 {38 double ang1,ang2,ang3,ang4;39 double d = dis(a-b);40 ang1 = asin(a.r/d);41 ang2 = asin((b.x-a.x)/d);42 ang3 = ang1+ang2;43 ang4 = ang2-ang1;44 //cout<<ang1<<" "<<ang2<<" "<<ang3<<" "<<ang4<<endl;45 node ll;46 double l = b.x-b.y*tan(ang3);47 double r = b.x-b.y*tan(ang4);48 ll.l = min(l,r);49 ll.r = max(l,r);50 return ll;51 }52 bool cmp(node a,node b)53 {54 return a.l<b.l;55 }56 int main()57 {58 int n,i;59 point pp;60 while(scanf("%d",&n)&&n)61 {62 scanf("%lf%lf",&pp.x,&pp.y);63 for(i = 1; i <= n; i++)64 scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r);65 for(i = 1; i <= n; i++)66 {67 li[i] = cal(p[i],pp);68 }69 sort(li+1,li+n+1,cmp);70 int g = 1;71 ans[g].l = li[1].l;72 double te = li[1].r;73 for(i = 2 ; i <= n; i++)74 {75 if(li[i].l>te)76 {77 ans[g].r = te;78 ans[++g].l = li[i].l;79 }80 te = max(te,li[i].r);81 }82 ans[g].r = te;83 for(i = 1; i <= g; i++)84 printf("%.2f %.2f\n",ans[i].l,ans[i].r);85 puts("");86 }87 return 0;88 }
View code