LA-2512:Art Gallery(半平面交)

The art galleries of the new and very futuristic building of the Center for Balkan Cooperation have the form of polygons (not necessarily convex). When a big exhibition is organized, watching over all of the pictures is a big security concern. Your task is that for a given gallery to write a program which finds the surface of the area of the floor, from which each point on the walls of the gallery is visible. On the figure 1. a map of a gallery is given in some co-ordinate system. The area wanted is shaded on the figure 2. 
Input
The number of tasks T that your program have to solve will be on the first row of the input file. Input data for each task start with an integer N, 5 <= N <= 1500. Each of the next N rows of the input will contain the co-ordinates of a vertex of the polygon ? two integers that fit in 16-bit integer type, separated by a single space. Following the row with the co-ordinates of the last vertex for the task comes the line with the number of vertices for the next test and so on.
Output
For each test you must write on one line the required surface - a number with exactly two digits after the decimal point (the number should be rounded to the second digit after the decimal point).
Sample Input
1
7
0 0
4 4
4 7
9 7
13 -1
8 -6
4 -4
Sample Output
80.00

题意:给你一个多边形的画廊,找出一片区域,使得无论你站在这个区域的哪个地方,都能监视到画廊的各个地方。

思路:半平面交的模版题。求出半平面交的面积即可。(题目中给的点是按顺时针方向给出的,不过题目没有说明给出的顺序)

#include
#include
#include
#include
#include
using namespace std;
struct Point
{
    double x,y;
}p[2000],ch[2000];
struct Line
{
    Point p;
    Point v;
    double angle;
    Line(){}
    Line(Point p,Point v):p(p),v(v){angle=atan2(v.y,v.x);}
    bool operator<(const Line& L)const{return angle0;}
Point Getinter(Line a,Line b)
{
    Point u=Vector(a.p,b.p);
    double t=cross(b.v,u)/cross(a.v,b.v);
    return (Point){a.p.x+a.v.x*t,a.p.y+a.v.y*t};
}
int Half(Line *L,int n,Point *poly)       //求半平面交上的点
{
    sort(L,L+n);
    int first,last;
    Point *p=new Point[n];
    Line *q=new Line[n];
    q[first=last=0]=L[0];
    for(int i=1;i>T;
    while(T--)
    {
        cin>>n;
        for(int i=0;i>p[i].x>>p[i].y;
        for(int i=0;i



你可能感兴趣的:(计算几何)