def isAddedPointOnPathIntersectingPath(begin, path, point, pointIndex):
 segment = (point - begin)
 segmentLength = abs(segment)
 if (segmentLength <= 0.0):
  return False
 normalizedSegment = (segment / segmentLength)
 segmentYMirror = complex(normalizedSegment.real, (- normalizedSegment.imag))
 pointRotated = (segmentYMirror * point)
 beginRotated = (segmentYMirror * begin)
 if euclidean.isXSegmentIntersectingPath(path[max(0, (pointIndex - 20)):pointIndex], pointRotated.real, beginRotated.real, segmentYMirror, pointRotated.imag):
  return True
 return euclidean.isXSegmentIntersectingPath(path[(pointIndex + 1):(pointIndex + 21)], pointRotated.real, beginRotated.real, segmentYMirror, pointRotated.imag)

def isAddedPointOnPathIntersectingPath ( begin , path , point , pointIndex ) : segment = ( point - begin ) segmentLength = abs ( segment ) if ( segmentLength <= 0.0 ) : return False normalizedSegment = ( segment / segmentLength ) segmentYMirror = complex ( normalizedSegment . real , ( - normalizedSegment . imag ) ) pointRotated = ( segmentYMirror * point ) beginRotated = ( segmentYMirror * begin ) if euclidean . isXSegmentIntersectingPath ( path [ max ( 0 , ( pointIndex - 20 ) ) : pointIndex ] , pointRotated . real , beginRotated . real , segmentYMirror , pointRotated . imag ) : return True return euclidean . isXSegmentIntersectingPath ( path [ ( pointIndex + 1 ) : ( pointIndex + 21 ) ] , pointRotated . real , beginRotated . real , segmentYMirror , pointRotated . imag )
determine if the point added to a path is intersecting the path by checking line intersection .