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)
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)
def getReturnValue(self, point): "Get return value." if self.function == None: return point self.function.localDictionary['azimuth'] = math.degrees( math.atan2( point.y, point.x ) ) self.function.localDictionary['radius'] = abs( point.dropAxis() ) if self.revolutions != None: if len( self.points ) > 0: self.revolutions += 0.5 / math.pi * euclidean.getAngleAroundZAxisDifference( point, self.points[-1] ) self.function.localDictionary['revolutions'] = self.revolutions self.function.localDictionary['vertex'] = point self.function.localDictionary['vertexes'] = self.points self.function.localDictionary['vertexindex'] = len( self.points ) self.function.localDictionary['x'] = point.x self.function.localDictionary['y'] = point.y self.function.localDictionary['z'] = point.z self.points.append(point) return self.function.getReturnValueWithoutDeletion()
def getReturnValue(self, point): "Get return value." if self.function == None: return point self.function.localDictionary["azimuth"] = math.degrees(math.atan2(point.y, point.x)) self.function.localDictionary["radius"] = abs(point.dropAxis()) if self.revolutions != None: if len(self.points) > 0: self.revolutions += 0.5 / math.pi * euclidean.getAngleAroundZAxisDifference(point, self.points[-1]) self.function.localDictionary["revolutions"] = self.revolutions self.function.localDictionary["vertex"] = point self.function.localDictionary["vertexes"] = self.points self.function.localDictionary["vertexindex"] = len(self.points) self.function.localDictionary["x"] = point.x self.function.localDictionary["y"] = point.y self.function.localDictionary["z"] = point.z self.points.append(point) return self.function.getReturnValueWithoutDeletion()
def getReturnValue(self, point, revolutions): "Get return value." if self.function == None: return point self.function.localDictionary['azimuth'] = math.degrees(math.atan2(point.y, point.x)) if len(self.points) > 0: self.distance += abs(point - self.points[-1]) self.function.localDictionary['distance'] = self.distance self.function.localDictionary['radius'] = abs(point.dropAxis()) if revolutions != None: if len( self.points ) > 0: revolutions += 0.5 / math.pi * euclidean.getAngleAroundZAxisDifference(point, self.points[-1]) self.function.localDictionary['revolutions'] = revolutions self.function.localDictionary['vertex'] = point self.function.localDictionary['vertexes'] = self.points self.function.localDictionary['vertexindex'] = len(self.points) self.function.localDictionary['x'] = point.x self.function.localDictionary['y'] = point.y self.function.localDictionary['z'] = point.z self.points.append(point) return self.function.getReturnValueWithoutDeletion()