ZOJ Radar Overlay (computational geometry vector)

Source: Internet
Author: User
Tags radar
Test Instructions:

The half-circle radar coverage with the center of the radar core can be rotated by multiple point radars, and the idea of the maximum coverage number (including the boundary) is obtained :

Calculates the difference between the geometry of the test center and the distance to point. In order to solve this problem, we only use the highlight distance formula to remove the must not hit, and then use the difference product
(P1,P2) m>0 P1 in the clockwise direction of the P2
(P1,P2) m<0 P1 in the counterclockwise direction of the P2
(P1,P2) m=0 P1 and P2 the same line
Relative point formula: m= (x1-x0) * (y2-y0)-(x2-x0) * (Y1-Y0) There is no need to subtract the program from the origin.

 const maxn=3000; var x,y:array[0..maxn] of Real;
  Max,p,q,s,sum,i,j:longint;
R,m,xi,yi:real;
Procedure main;
var i,j:longint;
      Begin for I:=1 to sum do begin p:=0;q:=0;s:=0;
          For j:=1 to sum do begin m:= (X[I]-XI) * (Y[j]-yi)-(X[J]-XI) * (Y[i]-yi);
          If M=0 then Inc (s);
          If M>0 then Inc (P);
        If M<0 then Inc (Q);
      End
      If S+p>max then max:=s+p;
    If S+q>max then max:=s+q;
End
End
  Begin READLN (XI,YI,R);
      While not (EOF (input)) does begin max:=0;
      sum:=0;
      Readln (j);
        For I:=1 to J do begin READLN (P,Q);
          If sqrt (Sqr (p-xi) +SQR (q-yi)) <=r THEN BEGIN Inc (SUM);
          X[sum]:=p;
        y[sum]:=q;
      End
      End
      Main
      Writeln (max);
    READLN (XI,YI,R);
End End. 

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.