vector2 클래스
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
const double PI = 2.0 * acos(0.0);
struct vector2 {
double x, y;
vector2(double x_ = 0, double y_ = 0) : x(x_), y(y_) {}
bool operator == (const vector2& rhs) const { return x == rhs.x && y == rhs.y; }
vector2 operator + (const vector2& rhs) const { return vector2(x + rhs.x, y + rhs.y); }
vector2 operator - (const vector2& rhs) const { return vector2(x - rhs.x, y - rhs.y); }
vector2 operator - () const { return vector2(-x, -y); }
bool operator < (const vector2& rhs) const
{
return x != rhs.x? x < rhs.x: y < rhs.y;
}
vector2 operator * (double rhs) const { return vector2(x * rhs, y * rhs); }
double norm() const { return hypot(x, y); }
vector2 normalize() const { double n = norm(); return vector2(x / n, y / n); }
double dot(const vector2& rhs) const { return x * rhs.x + y * rhs.y; }
double cross(const vector2& rhs) const { return x * rhs.y - rhs.x * y; }
vector2 project(const vector2& rhs) const {
vector2 r = rhs.normalize();
return r * r.dot(*this);
}
};
double ccw(vector2 a, vector2 b)
{
return a.cross(b);
}
double ccw(vector2 p, vector2 a, vector2 b)
{
return ccw(a-p, b-p);
}