POJ 1375 intervals (analytic geometry a little outside the circle to find the tangent of the circle)

Source: Internet
Author: User
Tags asin

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.