20 Rational o1 = P1P2[0] * P2Q1[1] - P1P2[1] * P2Q1[0];
21 Rational o2 = P1P2[0] * P2Q2[1] - P1P2[1] * P2Q2[0];
22 Rational o3 = Q1Q2[0] * Q2P1[1] - Q1Q2[1] * Q2P1[0];
23 Rational o4 = Q1Q2[0] * Q2P2[1] - Q1Q2[1] * Q2P2[0];
30 if (o1_sgn == 0 && o2_sgn == 0) {
32 if (Q1[0] >= std::min(P1[0], P2[0]) && Q1[0] <= std::max(P1[0], P2[0])) {
36 }
else if (Q2[0] >= std::min(P1[0], P2[0]) && Q2[0] <= std::max(P1[0], P2[0])) {
45 }
else if (o1_sgn * o2_sgn <= 0 && o3_sgn * o4_sgn <= 0) {
48 (P1Q1[0] * Q1Q2[1] - P1Q1[1] * Q1Q2[0]) / (P1P2[0] * Q1Q2[1] - P1P2[1] * Q1Q2[0]);
49 intersection = P1 + t * P1P2;
bool segment_intersection_rational(const Vector2r &P1, const Vector2r &P2, const Vector2r &Q1, const Vector2r &Q2, Vector2r &intersection)
Vector< Rational, 2 > Vector2r