示例#1
0
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]
示例#2
0
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
示例#3
0
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]
示例#4
0
文件: comb.py 项目: folksjos/RepG
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