POJ 1279 Art Gallery 半平面交+求多边形核的面积


裸的:半平面交+求多边形核的面积


Art Gallery
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 5735   Accepted: 2419

Description

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. 
POJ 1279 Art Gallery 半平面交+求多边形核的面积_第1张图片

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

Source

Southeastern Europe 2002

[Submit]   [Go Back]   [Status]   [Discuss]



/* ***********************************************
Author        :CKboss
Created Time  :2015年04月09日 星期四 19时43分00秒
File Name     :POJ1279.cpp
************************************************ */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

#define mp make_pair
#define pb push_back

const double eps = 1e-8;
const double pi = acos(-1.0);
const double inf = 1e20;
const int maxp = 2111;

int dcmp(double d) { if(fabs(d)b left
	halfplane(point _a,point _b){ a=_a; b=_b;}
	halfplane(line v) { a=v.a; b=v.b; }
	void calcangle() { angle=atan2(b.y-a.y,b.x-a.x); }
	bool operator<(const halfplane &b) const { return angle0))
				hp[m-1]=hp[i];
		}
		n=m;
	}
	bool halfplaneinsert()
	{
		int i;
		for(int i=0;i=ed) return false;
		return true;
	}

	void getconvex(polygon &con)
	{
		p[st]=hp[que[st]].crosspoint(hp[que[ed]]);
		con.n=ed-st+1;
		int j=st,i=0;
		for(;j<=ed;i++,j++) con.p[i]=p[j];
	}
};

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

	int T_T;
	scanf("%d",&T_T);
	while(T_T--)
	{
		int n;
		scanf("%d",&n);
		vector vp;
		for(int i=0;i




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