计算几何基础类模板
// todo 常量定义
const double esp = 1e-9;
const double pi = acos(-1);
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll maxn = 1e5 + 7;
// todo 三态函数
int dcmp(double x) {
if (fabs(x) < esp) return 0;
return x > 0 ? 1 : -1;
}
// todo 点(向量)类
class Point {
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
// todo 点操作
bool operator<(const Point &a) const {
return (!dcmp(x - a.x)) ? dcmp(y - a.y) < 0 : x < a.x;
}
bool operator==(const Point &a) const {
return (!dcmp(x - a.x)) && (!dcmp(y - a.y));
}
double dis2(const Point a) {//两点间距离的平方
return (x - a.x) * (x - a.x) + (y - a.y) * (y - a.y);
}
double dis(const Point a) {//两点间距离
return sqrt(dis2(a));
}
// todo 向量操作
double dis2() {//向量的模的平方
return x * x + y * y;
}
};
我看见 你

浙公网安备 33010602011771号