HayatoY's Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub HayatoYagi/library

:warning: Geometry/vector2.cpp

Code

double EPS = 1e-10;

double add(double a, double b){
    if(abs(a + b) < EPS * (abs(a) + abs(b)))return 0;
    return a + b;
}

struct P{
    double x, y;
    P(){}
    P(double x, double y) : x(x), y(y) {
    }
    P operator + (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator - (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator * (double d){
        return P(x * d, y * d);
    }
    double dot(P p){
        return add(x * p.x, y * p.y);
    }
    double det(P p){
        return add(x * p.y, -y * p.x);
    }
};
#line 1 "Geometry/vector2.cpp"
double EPS = 1e-10;

double add(double a, double b){
    if(abs(a + b) < EPS * (abs(a) + abs(b)))return 0;
    return a + b;
}

struct P{
    double x, y;
    P(){}
    P(double x, double y) : x(x), y(y) {
    }
    P operator + (P p){
        return P(add(x, p.x), add(y, p.y));
    }
    P operator - (P p){
        return P(add(x, -p.x), add(y, -p.y));
    }
    P operator * (double d){
        return P(x * d, y * d);
    }
    double dot(P p){
        return add(x * p.x, y * p.y);
    }
    double det(P p){
        return add(x * p.y, -y * p.x);
    }
};
Back to top page