def getPathsByIntersectedLoop(begin, end, loop):
 closestBeginDistanceIndex = euclidean.getClosestDistanceIndexToLine(begin, loop)
 closestEndDistanceIndex = euclidean.getClosestDistanceIndexToLine(end, loop)
 beginIndex = ((closestBeginDistanceIndex.index + 1) % len(loop))
 endIndex = ((closestEndDistanceIndex.index + 1) % len(loop))
 closestBegin = euclidean.getClosestPointOnSegment(loop[closestBeginDistanceIndex.index], loop[beginIndex], begin)
 closestEnd = euclidean.getClosestPointOnSegment(loop[closestEndDistanceIndex.index], loop[endIndex], end)
 clockwisePath = [closestBegin]
 widdershinsPath = [closestBegin]
 if (closestBeginDistanceIndex.index != closestEndDistanceIndex.index):
  widdershinsPath += euclidean.getAroundLoop(beginIndex, endIndex, loop)
  clockwisePath += euclidean.getAroundLoop(endIndex, beginIndex, loop)[::(-1)]
 clockwisePath.append(closestEnd)
 widdershinsPath.append(closestEnd)
 return [clockwisePath, widdershinsPath]

def getPathsByIntersectedLoop ( begin , end , loop ) : closestBeginDistanceIndex = euclidean . getClosestDistanceIndexToLine ( begin , loop ) closestEndDistanceIndex = euclidean . getClosestDistanceIndexToLine ( end , loop ) beginIndex = ( ( closestBeginDistanceIndex . index + 1 ) % len ( loop ) ) endIndex = ( ( closestEndDistanceIndex . index + 1 ) % len ( loop ) ) closestBegin = euclidean . getClosestPointOnSegment ( loop [ closestBeginDistanceIndex . index ] , loop [ beginIndex ] , begin ) closestEnd = euclidean . getClosestPointOnSegment ( loop [ closestEndDistanceIndex . index ] , loop [ endIndex ] , end ) clockwisePath = [ closestBegin ] widdershinsPath = [ closestBegin ] if ( closestBeginDistanceIndex . index != closestEndDistanceIndex . index ) : widdershinsPath += euclidean . getAroundLoop ( beginIndex , endIndex , loop ) clockwisePath += euclidean . getAroundLoop ( endIndex , beginIndex , loop ) [ : : ( - 1 ) ] clockwisePath . append ( closestEnd ) widdershinsPath . append ( closestEnd ) return [ clockwisePath , widdershinsPath ]
get both paths along the loop from the point nearest to the begin to the point nearest to the end .