def getPathBetween(self, betweenFirst, betweenSecond, isLeavingPerimeter, loopFirst): "Add a path between the perimeter and the fill." loopFirst = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loopFirst, self.combInset) nearestFirstDistanceIndex = euclidean.getNearestDistanceIndex( betweenFirst, loopFirst) nearestSecondDistanceIndex = euclidean.getNearestDistanceIndex( betweenSecond, loopFirst) firstBeginIndex = (nearestFirstDistanceIndex.index + 1) % len(loopFirst) secondBeginIndex = (nearestSecondDistanceIndex.index + 1) % len(loopFirst) nearestFirst = euclidean.getNearestPointOnSegment( loopFirst[nearestFirstDistanceIndex.index], loopFirst[firstBeginIndex], betweenFirst) nearestSecond = euclidean.getNearestPointOnSegment( loopFirst[nearestSecondDistanceIndex.index], loopFirst[secondBeginIndex], betweenSecond) clockwisePath = [nearestFirst] widdershinsPath = [nearestFirst] loopBeforeLeaving = euclidean.getAroundLoop(firstBeginIndex, firstBeginIndex, loopFirst) if nearestFirstDistanceIndex.index == nearestSecondDistanceIndex.index: if euclidean.getPathLength( widdershinsPath) < self.minimumDepartureDistance: widdershinsPath = [nearestFirst] + loopBeforeLeaving reversedLoop = loopBeforeLeaving[:] reversedLoop.reverse() clockwisePath = [nearestFirst] + reversedLoop else: widdershinsLoop = euclidean.getAroundLoop(firstBeginIndex, secondBeginIndex, loopFirst) widdershinsPath += widdershinsLoop clockwiseLoop = euclidean.getAroundLoop(secondBeginIndex, firstBeginIndex, loopFirst) clockwiseLoop.reverse() clockwisePath += clockwiseLoop clockwisePath.append(nearestSecond) widdershinsPath.append(nearestSecond) if euclidean.getPathLength(widdershinsPath) > euclidean.getPathLength( clockwisePath): loopBeforeLeaving.reverse() widdershinsPath = clockwisePath if isLeavingPerimeter: totalDistance = euclidean.getPathLength(widdershinsPath) loopLength = euclidean.getPolygonLength(loopBeforeLeaving) while totalDistance < self.minimumDepartureDistance: widdershinsPath = [nearestFirst ] + loopBeforeLeaving + widdershinsPath[1:] totalDistance += loopLength return widdershinsPath
def getPathsByIntersectedLoop( begin, end, loop ): """Get both paths along the loop from the point nearest to the begin to the point nearest to the end.""" nearestBeginDistanceIndex = euclidean.getNearestDistanceIndex( begin, loop ) nearestEndDistanceIndex = euclidean.getNearestDistanceIndex( end, loop ) beginIndex = ( nearestBeginDistanceIndex.index + 1 ) % len(loop) endIndex = ( nearestEndDistanceIndex.index + 1 ) % len(loop) nearestBegin = euclidean.getNearestPointOnSegment( loop[ nearestBeginDistanceIndex.index ], loop[ beginIndex ], begin ) nearestEnd = euclidean.getNearestPointOnSegment( loop[ nearestEndDistanceIndex.index ], loop[ endIndex ], end ) clockwisePath = [ nearestBegin ] widdershinsPath = [ nearestBegin ] if nearestBeginDistanceIndex.index != nearestEndDistanceIndex.index: widdershinsPath += euclidean.getAroundLoop( beginIndex, endIndex, loop ) clockwisePath += euclidean.getAroundLoop( endIndex, beginIndex, loop )[: : -1] clockwisePath.append( nearestEnd ) widdershinsPath.append( nearestEnd ) return [ clockwisePath, widdershinsPath ]
def getPathsByIntersectedLoop( begin, end, loop ): "Get both paths along the loop from the point nearest to the begin to the point nearest to the end." nearestBeginDistanceIndex = euclidean.getNearestDistanceIndex( begin, loop ) nearestEndDistanceIndex = euclidean.getNearestDistanceIndex( end, loop ) beginIndex = ( nearestBeginDistanceIndex.index + 1 ) % len(loop) endIndex = ( nearestEndDistanceIndex.index + 1 ) % len(loop) nearestBegin = euclidean.getNearestPointOnSegment( loop[ nearestBeginDistanceIndex.index ], loop[ beginIndex ], begin ) nearestEnd = euclidean.getNearestPointOnSegment( loop[ nearestEndDistanceIndex.index ], loop[ endIndex ], end ) clockwisePath = [ nearestBegin ] widdershinsPath = [ nearestBegin ] if nearestBeginDistanceIndex.index != nearestEndDistanceIndex.index: widdershinsPath += euclidean.getAroundLoop( beginIndex, endIndex, loop ) clockwisePath += euclidean.getAroundLoop( endIndex, beginIndex, loop )[: : -1] clockwisePath.append( nearestEnd ) widdershinsPath.append( nearestEnd ) return [ clockwisePath, widdershinsPath ]
def getPathBetween(self, betweenFirst, betweenSecond, isLeavingPerimeter, loopFirst): "Add a path between the perimeter and the fill." loopFirst = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(loopFirst, self.combInset) nearestFirstDistanceIndex = euclidean.getNearestDistanceIndex(betweenFirst, loopFirst) nearestSecondDistanceIndex = euclidean.getNearestDistanceIndex(betweenSecond, loopFirst) firstBeginIndex = (nearestFirstDistanceIndex.index + 1) % len(loopFirst) secondBeginIndex = (nearestSecondDistanceIndex.index + 1) % len(loopFirst) nearestFirst = euclidean.getNearestPointOnSegment( loopFirst[nearestFirstDistanceIndex.index], loopFirst[firstBeginIndex], betweenFirst ) nearestSecond = euclidean.getNearestPointOnSegment( loopFirst[nearestSecondDistanceIndex.index], loopFirst[secondBeginIndex], betweenSecond ) clockwisePath = [nearestFirst] widdershinsPath = [nearestFirst] loopBeforeLeaving = euclidean.getAroundLoop(firstBeginIndex, firstBeginIndex, loopFirst) if nearestFirstDistanceIndex.index == nearestSecondDistanceIndex.index: if euclidean.getPathLength(widdershinsPath) < self.minimumDepartureDistance: widdershinsPath = [nearestFirst] + loopBeforeLeaving reversedLoop = loopBeforeLeaving[:] reversedLoop.reverse() clockwisePath = [nearestFirst] + reversedLoop else: widdershinsLoop = euclidean.getAroundLoop(firstBeginIndex, secondBeginIndex, loopFirst) widdershinsPath += widdershinsLoop clockwiseLoop = euclidean.getAroundLoop(secondBeginIndex, firstBeginIndex, loopFirst) clockwiseLoop.reverse() clockwisePath += clockwiseLoop clockwisePath.append(nearestSecond) widdershinsPath.append(nearestSecond) if euclidean.getPathLength(widdershinsPath) > euclidean.getPathLength(clockwisePath): loopBeforeLeaving.reverse() widdershinsPath = clockwisePath if isLeavingPerimeter: totalDistance = euclidean.getPathLength(widdershinsPath) loopLength = euclidean.getPolygonLength(loopBeforeLeaving) while totalDistance < self.minimumDepartureDistance: widdershinsPath = [nearestFirst] + loopBeforeLeaving + widdershinsPath[1:] totalDistance += loopLength return widdershinsPath
def addRunningJumpPath(self, end, loop, pathAround): "Get the running jump path from the perimeter to the intersection or running jump space." if self.combRepository.runningJumpSpaceOverPerimeterWidth.value < 1.0: return if len(pathAround) < 2: return loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat( loop, self.combInset) penultimatePoint = pathAround[-2] lastPoint = pathAround[-1] nearestEndDistanceIndex = euclidean.getNearestDistanceIndex(end, loop) nearestEndIndex = (nearestEndDistanceIndex.index + 1) % len(loop) nearestEnd = euclidean.getNearestPointOnSegment( loop[nearestEndDistanceIndex.index], loop[nearestEndIndex], end) nearestEndMinusLast = nearestEnd - lastPoint nearestEndMinusLastLength = abs(nearestEndMinusLast) if nearestEndMinusLastLength <= 0.0: return nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength betweens = self.getBetweens() if self.getIsRunningJumpPathAdded(betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, self.runningJumpSpace): return doubleCombInset = 2.0 * self.combInset shortJumpSpace = 0.5 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return if self.getIsRunningJumpPathAdded(betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace): return shortJumpSpace = 0.25 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return self.getIsRunningJumpPathAdded(betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace)
def addRunningJumpPath(self, end, loop, pathAround): "Get the running jump path from the perimeter to the intersection or running jump space." if self.combRepository.runningJumpSpaceOverPerimeterWidth.value < 1.0: return if len(pathAround) < 2: return loop = intercircle.getLargestInsetLoopFromLoopNoMatterWhat(loop, self.combInset) penultimatePoint = pathAround[-2] lastPoint = pathAround[-1] nearestEndDistanceIndex = euclidean.getNearestDistanceIndex(end, loop) nearestEndIndex = (nearestEndDistanceIndex.index + 1) % len(loop) nearestEnd = euclidean.getNearestPointOnSegment(loop[nearestEndDistanceIndex.index], loop[nearestEndIndex], end) nearestEndMinusLast = nearestEnd - lastPoint nearestEndMinusLastLength = abs(nearestEndMinusLast) if nearestEndMinusLastLength <= 0.0: return nearestEndMinusLastSegment = nearestEndMinusLast / nearestEndMinusLastLength betweens = self.getBetweens() if self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, self.runningJumpSpace ): return doubleCombInset = 2.0 * self.combInset shortJumpSpace = 0.5 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return if self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace ): return shortJumpSpace = 0.25 * self.runningJumpSpace if shortJumpSpace < doubleCombInset: return self.getIsRunningJumpPathAdded( betweens, end, lastPoint, nearestEndMinusLastSegment, pathAround, penultimatePoint, shortJumpSpace )