src/main/java/de/blau/android/util/Geometry.java
/**
     * Check if the segments/lines between p1-q1 and p2-q2 intersect
     * 
     * Note assumes planar geometry
     * 
     * @param start1 start Node segment 1
     * @param end1 end Node segment 1
     * @param start2 start Node segment 2
     * @param end2 end Node segment 2
     * @return true if the lines intersect
     */
Check if the segments/lines between p1-q1 and p2-q2 intersect

Note assumes planar geometry


Check if the segments / lines between p1 - q1 and p2 - q2 intersect Note assumes planar geometry
private static boolean intersect(@NonNull Node start1, @NonNull Node end1, @NonNull Node start2, @NonNull Node end2) {
        int w1 = winding(start1, end1, start2);
        int w2 = winding(start1, end1, end2);
        int w3 = winding(start2, end2, start1);
        int w4 = winding(start2, end2, end1);
        if (w1 != w2 && w3 != w4) {
            return true;
        }
        if (w1 == COLINEAR && onSegment(start1, start2, end1)) {
            return true;
        }
        if (w2 == COLINEAR && onSegment(start1, end2, end1)) {
            return true;
        }
        if (w3 == COLINEAR && onSegment(start2, start1, end2)) {
            return true;
        }
        return w4 == COLINEAR && onSegment(start2, end1, end2);
    }
private static boolean intersect ( @ NonNull Node start1 , @ NonNull Node end1 , @ NonNull Node start2 , @ NonNull Node end2 ) { int w1 = winding ( start1 , end1 , start2 ) ; int w2 = winding ( start1 , end1 , end2 ) ; int w3 = winding ( start2 , end2 , start1 ) ; int w4 = winding ( start2 , end2 , end1 ) ; if ( w1 != w2 && w3 != w4 ) { return true ; } if ( w1 == COLINEAR && onSegment ( start1 , start2 , end1 ) ) { return true ; } if ( w2 == COLINEAR && onSegment ( start1 , end2 , end1 ) ) { return true ; } if ( w3 == COLINEAR && onSegment ( start2 , start1 , end2 ) ) { return true ; } return w4 == COLINEAR && onSegment ( start2 , end1 , end2 ) ; }
Check if the segments/lines between p1-q1 and p2-q2 intersect
Check if the segments / lines between p1 - q1 and p2 - q2 intersect
// General case // Handle cases in which the intersection is on one of the ways