check whether the distinct line segments intersect
function doIntersect ( p1 , q1 , p2 , q2 ) { let o1 = orientation ( p1 , q1 , p2 ) ; let o2 = orientation ( p1 , q1 , q2 ) ; let o3 = orientation ( p2 , q2 , p1 ) ; let o4 = orientation ( p2 , q2 , q1 ) ; if ( o1 != o2 && o3 != o4 ) return true ; return false ; }