Function intersectLineSegments