计算几何 《模板》

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
# include<cmath>
using namespace std;
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.x*p);
}

Vector operator /(Vector A,double p)
{
    return Vector(A.x/p, A.x/p);
}

const int esp=1e-10;

bool operator <(const point& a,const point& b)
{
    return a.x<b.x||(a.x==b.x && a.y<b.y);
}

int dcmp(double x)
{
    if(fabs(x)<esp) return 0;
    else
        return x<0?

-1:1; } bool operator ==(const point& a,const point& b) { return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0; } 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); } Vector Rotate (Vector A,double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad)); } 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); } int main() { return 0; }


原文地址:https://www.cnblogs.com/wgwyanfs/p/6767355.html