UVALive 3890 Most Distant Point from the Sea (半平面交)

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define FRER() freopen("in.txt","r",stdin)
#define FREW() freopen("out.txt","w",stdout)
#define go int T;cin>>T;for(int kase=0;kase pii;
const int maxn = 300;
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
};
typedef Point Vector;
Vector operator + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Vector A,Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator * (Vector A,double p){return Vector(A.x*p,A.y*p);    }
Vector operator / (Vector A,double p){return Vector(A.x/p,A.y/p);    }
double Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}
double Length(Vector A){return sqrt(Dot(A,A));}
double Angle(Vector A,Vector B){return acos(Dot(A,B) / Length(A) / Length(B));}
double Cross(Vector A,Vector B){return A.x*B.y - A.y*B.x;}
double Area2(Point A,Point B,Point C){return Cross(B-A,C-A);}
Vector Rotate(Vector A,double rad){
	return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
Vector Normal(Vector A){
	double L = Length(A);
	return Vector(-A.y/L,A.x/L);
}
Point GetLineIntersection(Point P,Vector v,Point Q,Vector w){
	Vector u=P-Q;
	double t=Cross(w,u)/Cross(v,w);
	return P+v*t;
} 
struct Line{
	Point P;
	Vector v;
	double ang;
	Line(){}
	Line(Point _p,Vector _v):P(_p),v(_v){ang = atan2(v.y,v.x);}
	bool operator < (const Line& rhs) const{
		return ang < rhs.ang;
	}
};
Point GetLineIntersection(Line a,Line b){
	Vector u = a.P - b.P;
	double t = Cross(b.v,u)/Cross(a.v,b.v);
	return a.P + a.v*t;
} 
bool OnLeft(Line L,Point P){
	return Cross(L.v,P-L.P) > 0;
}
int HalfplaneIntersection(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 eps){
			double mid = left + (right - left) / 2;
			for(int i=0;i

 

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