cplib-cpp

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

View the Project on GitHub hitonanode/cplib-cpp

:warning: geometry/sort_by_argument.hpp

Code

#pragma once
#include <cmath>

// CUT begin
// Point on grid, sortable by its argument
struct Point {
    constexpr static double eps = 1e-2;
    long long X, Y;
    double theta;
    Point() = default;
    Point(long long x, long long y) : X(x), Y(y), theta(std::atan2(y, x)) {}
    bool operator<(const Point &r) const {
        double b = theta - r.theta;
        return std::abs(b) > eps ? (b < 0) : (X * r.Y > r.X * Y);
    }
    bool operator==(const Point &r) const {
        return std::abs(theta - r.theta) < eps and X * r.Y == r.X * Y;
    }
    void rotate_pi() {
        theta += M_PI;
        X *= -1;
        Y *= -1;
    }
};
#line 2 "geometry/sort_by_argument.hpp"
#include <cmath>

// CUT begin
// Point on grid, sortable by its argument
struct Point {
    constexpr static double eps = 1e-2;
    long long X, Y;
    double theta;
    Point() = default;
    Point(long long x, long long y) : X(x), Y(y), theta(std::atan2(y, x)) {}
    bool operator<(const Point &r) const {
        double b = theta - r.theta;
        return std::abs(b) > eps ? (b < 0) : (X * r.Y > r.X * Y);
    }
    bool operator==(const Point &r) const {
        return std::abs(theta - r.theta) < eps and X * r.Y == r.X * Y;
    }
    void rotate_pi() {
        theta += M_PI;
        X *= -1;
        Y *= -1;
    }
};
Back to top page