static boolean _isIntersectingHelper ( Line line1 , Line line2 ) { int s11 = line1 . _side ( line2 . m_xStart , line2 . m_yStart ) ; int s12 = line1 . _side ( line2 . m_xEnd , line2 . m_yEnd ) ; if ( s11 < 0 && s12 < 0 || s11 > 0 && s12 > 0 ) return false ; // no intersection. The line2 lies to one side of an // infinite line passing through line1 int s21 = line2 . _side ( line1 . m_xStart , line1 . m_yStart ) ; int s22 = line2 . _side ( line1 . m_xEnd , line1 . m_yEnd ) ; if ( s21 < 0 && s22 < 0 || s21 > 0 && s22 > 0 ) return false ; // no intersection.The line1 lies to one side of an // infinite line passing through line2 double len1 = line1 . calculateLength2D ( ) ; double len2 = line2 . calculateLength2D ( ) ; if ( len1 > len2 ) { return line1 . _projectionIntersect ( line2 ) ; } else { return line2 . _projectionIntersect ( line1 ) ; } }
Tests if two lines intersect using projection of one line to another .