def getPathsByIntersectedLoop(begin, end, loop): "Get both paths along the loop from the point closest to the begin to the point closest to the end." 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 getJumpPointIfInside(boundary, otherPoint, perimeterWidth, runningJumpSpace): 'Get the jump point if it is inside the boundary, otherwise return None.' insetBoundary = intercircle.getSimplifiedInsetFromClockwiseLoop(boundary, -perimeterWidth) closestJumpDistanceIndex = euclidean.getClosestDistanceIndexToLine(otherPoint, insetBoundary) jumpIndex = (closestJumpDistanceIndex.index + 1) % len(insetBoundary) jumpPoint = euclidean.getClosestPointOnSegment(insetBoundary[closestJumpDistanceIndex.index], insetBoundary[jumpIndex], otherPoint) jumpPoint = getJumpPoint(jumpPoint, otherPoint, boundary, runningJumpSpace) if euclidean.isPointInsideLoop(boundary, jumpPoint): return jumpPoint return None
def getPathsByIntersectedLoop(begin, end, loop): 'Get both paths along the loop from the point closest to the begin to the point closest to the end.' 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 getJumpPointIfInside(boundary, otherPoint, edgeWidth, runningJumpSpace): 'Get the jump point if it is inside the boundary, otherwise return None.' insetBoundary = intercircle.getSimplifiedInsetFromClockwiseLoop( boundary, -edgeWidth) closestJumpDistanceIndex = euclidean.getClosestDistanceIndexToLine( otherPoint, insetBoundary) jumpIndex = (closestJumpDistanceIndex.index + 1) % len(insetBoundary) jumpPoint = euclidean.getClosestPointOnSegment( insetBoundary[closestJumpDistanceIndex.index], insetBoundary[jumpIndex], otherPoint) jumpPoint = getJumpPoint(jumpPoint, otherPoint, boundary, runningJumpSpace) if euclidean.isPointInsideLoop(boundary, jumpPoint): return jumpPoint return None