计算几何模板

using namespace std;
typedef  long double ld;
const ld eps = 1e-8;
const int N = 50009;
struct Point {
    ld x, y;
    Point(ld X = 0, ld Y = 0) { x = X, y = Y; }
    Point operator-(Point a) { return Point(x - a.x, y - a.y); }
    Point operator+(Point a) { return Point(x + a.x, y + a.y); }
    ld operator*(Point a) { return x * a.y - y * a.x; }
    Point operator*(ld a) {return Point(x * a,y * a);}
    ld dis() {
        return sqrt(x * x + y * y);
    }
    void out() {
        printf("%.2Lf %.2Lf\n", x,y);
    }
} p[N];
int dcmp(ld a, ld b) {
    if (fabs(a-b)< eps)return 0;
    else if (a > b)return 1;
    else return -1;
}
typedef Point Vector;
struct Line {
    Point p1, p2;
    Vector v;
    //Line(Point P1= {}, Point P2 = {}, Vector V = {}) {p1 = P1, p2=P2, v = V;}
    void out() {
        printf("%.2Lf %.2Lf -> %.2Lf %.2Lf\n", p1.x,p1.y, p2.x, p2.y);
    }
}L[N];
void out(ld x) {
    printf("%.2Lf\n", x);
}
Point GetCross(Line a, Line b) {
    Vector v = b.p1 - a.p1;
    return b.p1 + (b.v * ((v * a.v) / (a.v * b.v)));
}
上一篇:Flutter 打包iOS包出现 ld: bitcode bundle could not be generated because


下一篇:【编译原理笔记20】代码生成:代码生成器的主要任务,一个简单的目标机模型,指令选择,寄存器的选择,寄存器选择函数getReg的设计,窥孔优化