Exemple #1
0
 def helicalMove(self, isCounterclockwise, splitLine):
     "Get statistics for a helical move."
     if self.oldLocation == None:
         return
     location = self.getLocationSetFeedRateToSplitLine(splitLine)
     location += self.oldLocation
     center = self.oldLocation.copy()
     indexOfR = gcodec.getIndexOfStartingWithSecond("R", splitLine)
     if indexOfR > 0:
         radius = gcodec.getDoubleAfterFirstLetter(splitLine[indexOfR])
         halfLocationMinusOld = location - self.oldLocation
         halfLocationMinusOld *= 0.5
         halfLocationMinusOldLength = halfLocationMinusOld.magnitude()
         centerMidpointDistanceSquared = radius * radius - halfLocationMinusOldLength * halfLocationMinusOldLength
         centerMidpointDistance = math.sqrt(
             max(centerMidpointDistanceSquared, 0.0))
         centerMinusMidpoint = euclidean.getRotatedWiddershinsQuarterAroundZAxis(
             halfLocationMinusOld)
         centerMinusMidpoint.normalize()
         centerMinusMidpoint *= centerMidpointDistance
         if isCounterclockwise:
             center.setToVector3(halfLocationMinusOld + centerMinusMidpoint)
         else:
             center.setToVector3(halfLocationMinusOld - centerMinusMidpoint)
     else:
         center.x = gcodec.getDoubleForLetter("I", splitLine)
         center.y = gcodec.getDoubleForLetter("J", splitLine)
     curveSection = 0.5
     center += self.oldLocation
     afterCenterSegment = location - center
     beforeCenterSegment = self.oldLocation - center
     afterCenterDifferenceAngle = euclidean.getAngleAroundZAxisDifference(
         afterCenterSegment, beforeCenterSegment)
     absoluteDifferenceAngle = abs(afterCenterDifferenceAngle)
     steps = int(
         round(0.5 + max(
             absoluteDifferenceAngle * 2.4,
             absoluteDifferenceAngle * beforeCenterSegment.magnitude() /
             curveSection)))
     stepPlaneAngle = euclidean.getWiddershinsUnitPolar(
         afterCenterDifferenceAngle / steps)
     zIncrement = (afterCenterSegment.z -
                   beforeCenterSegment.z) / float(steps)
     for step in xrange(1, steps):
         beforeCenterSegment = euclidean.getRoundZAxisByPlaneAngle(
             stepPlaneAngle, beforeCenterSegment)
         beforeCenterSegment.z += zIncrement
         arcPoint = center + beforeCenterSegment
         self.addToPath(arcPoint)
     self.addToPath(location)
Exemple #2
0
 def helicalMove(self, isCounterclockwise, splitLine):
     "Get statistics for a helical move."
     if self.oldLocation == None:
         return
     location = self.getLocationSetFeedRateToSplitLine(splitLine)
     location += self.oldLocation
     center = self.oldLocation.copy()
     indexOfR = gcodec.indexOfStartingWithSecond("R", splitLine)
     if indexOfR > 0:
         radius = gcodec.getDoubleAfterFirstLetter(splitLine[indexOfR])
         halfLocationMinusOld = location - self.oldLocation
         halfLocationMinusOld *= 0.5
         halfLocationMinusOldLength = halfLocationMinusOld.magnitude()
         centerMidpointDistanceSquared = radius * radius - halfLocationMinusOldLength * halfLocationMinusOldLength
         centerMidpointDistance = math.sqrt(max(centerMidpointDistanceSquared, 0.0))
         centerMinusMidpoint = euclidean.getRotatedWiddershinsQuarterAroundZAxis(halfLocationMinusOld)
         centerMinusMidpoint.normalize()
         centerMinusMidpoint *= centerMidpointDistance
         if isCounterclockwise:
             center.setToVector3(halfLocationMinusOld + centerMinusMidpoint)
         else:
             center.setToVector3(halfLocationMinusOld - centerMinusMidpoint)
     else:
         center.x = gcodec.getDoubleForLetter("I", splitLine)
         center.y = gcodec.getDoubleForLetter("J", splitLine)
     curveSection = 0.5
     center += self.oldLocation
     afterCenterSegment = location - center
     beforeCenterSegment = self.oldLocation - center
     afterCenterDifferenceAngle = euclidean.getAngleAroundZAxisDifference(afterCenterSegment, beforeCenterSegment)
     absoluteDifferenceAngle = abs(afterCenterDifferenceAngle)
     steps = int(
         round(
             0.5
             + max(
                 absoluteDifferenceAngle * 2.4,
                 absoluteDifferenceAngle * beforeCenterSegment.magnitude() / curveSection,
             )
         )
     )
     stepPlaneAngle = euclidean.getWiddershinsUnitPolar(afterCenterDifferenceAngle / steps)
     zIncrement = (afterCenterSegment.z - beforeCenterSegment.z) / float(steps)
     for step in xrange(1, steps):
         beforeCenterSegment = euclidean.getRoundZAxisByPlaneAngle(stepPlaneAngle, beforeCenterSegment)
         beforeCenterSegment.z += zIncrement
         arcPoint = center + beforeCenterSegment
         self.addToPath(arcPoint)
     self.addToPath(location)