struct Vec {
double x, y;
Vec(double x = 0, double y = 0) : x(x), y(y) {}
Vec operator - (const Vec & a) const { return Vec(x - a.x, y - a.y); }
double operator * (const Vec & a) const { return x * a.y - y * a.x; }
};
typedef Vec Pt;
struct Line {
Pt p; Vec v;
};
bool online(Pt a, Line b) {
return fabs((a.p - b.p) * b.v) < eps ? true : false;
}
int check(Line a, Line b) {
return fabs(a.v * b.v) < eps ? fabs(a.v * (b.p - a.p)) < eps ? 0 : 1 : 2;
}
原文:https://www.cnblogs.com/fly-in-milkyway/p/10569895.html