text: a); } void Line::getequation(double A, double B, double C) const { A = a.y - b.y, B = b.x - a.x, C = det(a, b); } template <class T1, class T2> inline double dist(const T1 &x, const T2 &y) { return sqrt(dist_sqr(x, y)); } template <class T1, class T2> inline int dett(const T1 &x, const T2 &y) { return sgn(det(x, y)); } template <class T1, class T2> inline int dott(const T1 &x, const T2 &y) { return sgn(dot(x, y)); } template <class T1, class T2, class T3> inline int dett(const T1 &x, const T2 &y, const T3 &z) { return sgn(det(x, y, z)); } template <class T1, class T2, class T3> inline int dott(const T1 &x, const T2 &y, const T3 &z) { return sgn(dot(x, y, z)); } template <class T1, class T2, class T3, class T4> inline int dett(const T1 &x, const T2 &y, const T3 &z, const T4 &w) { return sgn(det(x, y, z, w)); } template <class T1, class T2, class T3, class T4> inline int dott(const T1 &x, const T2 &y, const T3 &z, const T4 &w) { return sgn(dot(x, y, z, w)); } inline double dist_sqr(const Po &a, const Po &b) { return sqr(a.x - b.x) + sqr(a.y - b.y); } inline double dist_sqr(const Po &p, const Line &l) { Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr(); } inline double dist_sqr(const Po &p, const Seg &l) { Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b; if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l)); else return min(v1.length_sqr(), v2.length_sqr()); } inline double dist_sqr(Line l, Po p) { return dist_sqr(p, l); } inline double dist_sqr(Seg l, Po p) { return dist_sqr(p, l); } inline double dist_sqr(Line l1, Line l2) { if (sgn(det(l1, l2)) != 0) return 0; return dist_sqr(l1.a, l2); } inline double dist_sqr(Line l1, Seg l2) { Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; double c1 = det(v0, v1), c2 = det(v0, v2); return sgn(c1) != sgn(c2) ?0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr(); } bool isIntersect(Seg l1, Seg l2) { if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.