Пример #1
0
def getRandomGrid(diameter, loopsComplex, maximumComplex, minimumComplex, xmlElement):
	"Get rectangular grid."
	packingDensity = evaluate.getEvaluatedFloatByKeys(0.2, ['packingDensity', 'density'], xmlElement)
	gridPath = []
	diameterReciprocal = complex(1.0 / diameter.real, 1.0 / diameter.imag)
	diameterSquared = diameter.real * diameter.real + diameter.imag * diameter.imag
	elements = int(math.ceil(packingDensity * euclidean.getAreaLoops(loopsComplex) / diameterSquared / math.sqrt(0.75)))
	elements = evaluate.getEvaluatedIntDefault(elements, 'elements', xmlElement)
	failedPlacementAttempts = 0
	pixelDictionary = {}
	seed = evaluate.getEvaluatedIntDefault(None, 'seed', xmlElement)
	if seed != None:
		random.seed(seed)
	successfulPlacementAttempts = 0
	while failedPlacementAttempts < 100:
		point = euclidean.getRandomComplex(minimumComplex, maximumComplex)
		if getIsPointInsideZoneAwayOthers(diameterReciprocal, loopsComplex, point, pixelDictionary):
			gridPath.append(point)
			euclidean.addElementToPixelListFromPoint(point, pixelDictionary, point)
			successfulPlacementAttempts += 1
		else:
			failedPlacementAttempts += 1
		if successfulPlacementAttempts >= elements:
			return gridPath
	return gridPath
Пример #2
0
	def __init__(self, modulo, prefix, xmlElement):
		"Initialize."
		self.start = evaluate.getEvaluatedIntDefault(0, prefix + 'start', xmlElement)
		self.extent = evaluate.getEvaluatedIntDefault(modulo - self.start, prefix + 'extent', xmlElement)
		self.end = evaluate.getEvaluatedIntDefault(self.start + self.extent, prefix + 'end', xmlElement)
		self.revolutions = evaluate.getEvaluatedIntDefault(1, prefix + 'revolutions', xmlElement)
		if self.revolutions > 1:
			self.end += modulo * (self.revolutions - 1)
Пример #3
0
	def __init__(self, xmlElement):
		'Set defaults.'
		self.sides = evaluate.getEvaluatedFloatDefault(4.0, 'sides', xmlElement)
		self.sideAngle = 2.0 * math.pi / self.sides
		cosSide = math.cos(0.5 * self.sideAngle)
		self.radius = lineation.getComplexByMultiplierPrefixes(cosSide, ['apothem', 'inradius'], complex(1.0, 1.0), xmlElement)
		self.radius = lineation.getComplexByPrefixes(['demisize', 'radius'], self.radius, xmlElement)
		self.radius = lineation.getComplexByMultiplierPrefixes(2.0, ['diameter', 'size'], self.radius, xmlElement)
		self.sidesCeiling = int(math.ceil(abs(self.sides)))
		self.start = evaluate.getEvaluatedIntDefault(0, 'start', xmlElement)
		end = evaluate.getEvaluatedIntDefault(self.sidesCeiling, 'end', xmlElement)
		self.revolutions = evaluate.getEvaluatedIntDefault(1, 'revolutions', xmlElement)
		self.extent = evaluate.getEvaluatedIntDefault(end - self.start, 'extent', xmlElement)
		self.extent += self.sidesCeiling * (self.revolutions - 1)
		self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
Пример #4
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.sides = evaluate.getEvaluatedFloatDefault(self.sides, 'sides', xmlElement)
		self.sideAngle = 2.0 * math.pi / self.sides
		self.radius = lineation.getComplexByMultiplierPrefixes(math.cos(0.5 * self.sideAngle), ['apothem', 'inradius'], self.radius, xmlElement)
		self.radius = lineation.getComplexByPrefixes(['demisize', 'radius'], self.radius, xmlElement)
		self.radius = lineation.getComplexByMultiplierPrefixes(2.0, ['diameter', 'size'], self.radius, xmlElement)
		self.sidesCeiling = int(math.ceil(abs(self.sides)))
		self.start = evaluate.getEvaluatedIntDefault(self.start, 'start', xmlElement)
		self.start = lineation.getWrappedInteger(self.start, 360.0)
		self.extent = evaluate.getEvaluatedIntDefault(self.sidesCeiling - self.start, 'extent', xmlElement)
		self.end = evaluate.getEvaluatedIntDefault(self.start + self.extent, 'end', xmlElement)
		self.end = lineation.getWrappedInteger(self.end, self.sidesCeiling)
		self.revolutions = evaluate.getEvaluatedIntDefault(self.revolutions, 'revolutions', xmlElement)
		if self.revolutions > 1:
			self.end += self.sidesCeiling * (self.revolutions - 1)
		self.spiral = evaluate.getVector3ByPrefix('spiral', self.spiral, xmlElement)
Пример #5
0
	def setToXMLElementOnly(self, xmlElement):
		"Set to the xmlElement."
		self.axisEnd = evaluate.getVector3ByPrefix(self.axisEnd, 'axisEnd', xmlElement)
		self.axisStart = evaluate.getVector3ByPrefix(self.axisStart, 'axisStart', xmlElement)
		self.end = evaluate.getEvaluatedFloatDefault(self.end, 'end', xmlElement)
		self.loop = evaluate.getTransformedPathByKey('loop', xmlElement)
		self.sides = evaluate.getEvaluatedIntDefault(self.sides, 'sides', xmlElement)
		self.start = evaluate.getEvaluatedFloatDefault(self.start, 'start', xmlElement)
		self.target = evaluate.getTransformedPathsByKey('target', xmlElement)
Пример #6
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], self.inradius, xmlElement)
		self.inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', self.inradius, xmlElement)
		self.demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', self.inradius.real, xmlElement)
		self.demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', self.inradius.imag, xmlElement)
		self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd('bottomdemiwidth', 'bottomwidth', self.demiwidth, xmlElement)
		self.topDemiwidth = lineation.getFloatByPrefixBeginEnd('topdemiwidth', 'topwidth', self.demiwidth, xmlElement)
		self.interiorAngle = evaluate.getEvaluatedFloatDefault(self.interiorAngle, 'interiorangle', xmlElement)
		self.revolutions = evaluate.getEvaluatedIntDefault(self.revolutions, 'revolutions', xmlElement)
		self.spiral = evaluate.getVector3ByPrefix(self.spiral, 'spiral', xmlElement)
Пример #7
0
	def __init__(self, xmlElement):
		'Set defaults.'
		self.inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(1.0, 1.0), xmlElement)
		self.inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', self.inradius, xmlElement)
		self.demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', self.inradius.real, xmlElement)
		self.demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', self.inradius.imag, xmlElement)
		self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd('bottomdemiwidth', 'bottomwidth', self.demiwidth, xmlElement)
		self.topDemiwidth = lineation.getFloatByPrefixBeginEnd('topdemiwidth', 'topwidth', self.demiwidth, xmlElement)
		self.interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, 'interiorangle', xmlElement)
		self.revolutions = evaluate.getEvaluatedIntDefault(1, 'revolutions', xmlElement)
		self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
Пример #8
0
	def __init__(self, xmlElement):
		'Set defaults.'
		self.depthBottomOverRadius = evaluate.getEvaluatedFloatDefault(0.0, 'depthBottomOverRadius', xmlElement)
		self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(0.0, 'depthOverRadius', xmlElement)
		self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.depthTopOverRadius, 'depthTopOverRadius', xmlElement)
		self.radius = evaluate.getEvaluatedFloatDefault(1.0, 'radius', xmlElement)
		self.sides = evaluate.getEvaluatedIntDefault(4, 'sides', xmlElement)
		self.depthBottom = self.radius * self.depthBottomOverRadius
		self.depthBottom = evaluate.getEvaluatedFloatDefault(self.depthBottom, 'depthBottom', xmlElement)
		self.depthTop = self.radius * self.depthTopOverRadius
		self.depthTop = evaluate.getEvaluatedFloatDefault(self.depthTop, 'depth', xmlElement)
		self.depthTop = evaluate.getEvaluatedFloatDefault(self.depthTop, 'depthTop', xmlElement)
Пример #9
0
	def __init__(self, xmlElement):
		'Set defaults.'
		self.axisEnd = evaluate.getVector3ByPrefix(None, 'axisEnd', xmlElement)
		self.axisStart = evaluate.getVector3ByPrefix(None, 'axisStart', xmlElement)
		self.end = evaluate.getEvaluatedFloatDefault(360.0, 'end', xmlElement)
		self.loop = evaluate.getTransformedPathByKey([], 'loop', xmlElement)
		self.sides = evaluate.getEvaluatedIntDefault(None, 'sides', xmlElement)
		self.start = evaluate.getEvaluatedFloatDefault(0.0, 'start', xmlElement)
		self.target = evaluate.getTransformedPathsByKey([], 'target', xmlElement)
		if len(self.target) < 1:
			print('Warning, no target in derive in lathe for:')
			print(xmlElement)
			return
		firstPath = self.target[0]
		if len(firstPath) < 3:
			print('Warning, firstPath length is less than three in derive in lathe for:')
			print(xmlElement)
			self.target = []
			return
		if self.axisStart == None:
			if self.axisEnd == None:
				self.axisStart = firstPath[0]
				self.axisEnd = firstPath[-1]
			else:
				self.axisStart = Vector3()
		self.axis = self.axisEnd - self.axisStart
		axisLength = abs(self.axis)
		if axisLength <= 0.0:
			print('Warning, axisLength is zero in derive in lathe for:')
			print(xmlElement)
			self.target = []
			return
		self.axis /= axisLength
		firstVector3 = firstPath[1] - self.axisStart
		firstVector3Length = abs(firstVector3)
		if firstVector3Length <= 0.0:
			print('Warning, firstVector3Length is zero in derive in lathe for:')
			print(xmlElement)
			self.target = []
			return
		firstVector3 /= firstVector3Length
		self.axisProjectiveSpace = euclidean.ProjectiveSpace().getByBasisZFirst(self.axis, firstVector3)
		if self.sides == None:
			distanceToLine = euclidean.getDistanceToLineByPaths(self.axisStart, self.axisEnd, self.target)
			self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(distanceToLine, xmlElement)
		endRadian = math.radians(self.end)
		startRadian = math.radians(self.start)
		self.isEndCloseToStart = euclidean.getIsRadianClose(endRadian, startRadian)
		if len(self.loop) < 1:
			self.loop = euclidean.getComplexPolygonByStartEnd(endRadian, 1.0, self.sides, startRadian)
		self.normal = euclidean.getNormalByPath(firstPath)
Пример #10
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], self.inradius, xmlElement)
		self.inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', self.inradius, xmlElement)
		self.demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', self.inradius.real, xmlElement)
		self.demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', self.inradius.imag, xmlElement)
		self.packingDensity = evaluate.getEvaluatedFloatByKeys(self.packingDensity, ['packingDensity', 'density'], xmlElement)
		self.radius = lineation.getComplexByPrefixBeginEnd('elementRadius', 'elementDiameter', self.radius, xmlElement)
		self.radius = lineation.getComplexByPrefixBeginEnd('radius', 'diameter', self.radius, xmlElement)
		self.seed = evaluate.getEvaluatedIntDefault(self.seed, 'seed', xmlElement)
		if len(self.target) < 1:
			self.target = evaluate.getTransformedPathsByKey('target', xmlElement)
		self.typeString = evaluate.getEvaluatedStringDefault(self.typeString, 'type', xmlElement)
		self.zigzag = evaluate.getEvaluatedBooleanDefault(self.zigzag, 'zigzag', xmlElement)
Пример #11
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], self.inradius, xmlElement)
		self.inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', self.inradius, xmlElement)
		self.demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', self.inradius.real, xmlElement)
		self.demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', self.inradius.imag, xmlElement)
		self.packingDensity = evaluate.getEvaluatedFloatByKeys(self.packingDensity, ['packingDensity', 'density'], xmlElement)
		self.radius = lineation.getComplexByPrefixBeginEnd('elementRadius', 'elementDiameter', self.radius, xmlElement)
		self.radius = lineation.getComplexByPrefixBeginEnd('radius', 'diameter', self.radius, xmlElement)
		self.seed = evaluate.getEvaluatedIntDefault(self.seed, 'seed', xmlElement)
		if len(self.target) < 1:
			self.target = evaluate.getTransformedPathsByKey('target', xmlElement)
		self.typeString = evaluate.getEvaluatedStringDefault(self.typeString, 'type', xmlElement)
		self.zigzag = evaluate.getEvaluatedBooleanDefault(self.zigzag, 'zigzag', xmlElement)
Пример #12
0
def getGeometryOutput( xmlElement ):
	"Get vector3 vertices from attribute dictionary."
	if '_arguments' in xmlElement.attributeDictionary:
		arguments = xmlElement.attributeDictionary[ '_arguments' ]
		if len( arguments ) > 0:
			xmlElement.attributeDictionary[ 'sides' ] = arguments[ 0 ]
	sides = evaluate.getEvaluatedFloatDefault( 4.0, 'sides', xmlElement )
	sideAngle = 2.0 * math.pi / float( sides )
	radiusXY = evaluate.RadiusXY().getByRadius( getRadiusFromXMLElement( sideAngle, xmlElement ), xmlElement )
	loop = []
	sidesCeiling = int( math.ceil( abs( sides ) ) )
	start = evaluate.getEvaluatedIntZero( 'start', xmlElement )
	start = getWrappedInteger( start, sidesCeiling )
	extent = evaluate.getEvaluatedIntDefault( sidesCeiling - start, 'extent', xmlElement )
	end = evaluate.getEvaluatedIntDefault( start + extent, 'end', xmlElement )
	end = getWrappedInteger( end, sidesCeiling )
	for side in xrange( start, min( end, sidesCeiling ) ):
		angle = float( side ) * sideAngle
		point = euclidean.getWiddershinsUnitPolar( angle )
		vertex = Vector3( point.real * radiusXY.radiusX, point.imag * radiusXY.radiusY )
		loop.append( vertex )
	sideLength = sideAngle * radiusXY.radius
	return lineation.getGeometryOutputByLoop( None, lineation.SideLoop( loop, sideAngle, sideLength ), xmlElement )
Пример #13
0
	def __init__(self, xmlElement):
		'Set defaults.'
		self.inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(10.0, 10.0), xmlElement)
		self.inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', self.inradius, xmlElement)
		self.demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', self.inradius.real, xmlElement)
		self.demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', self.inradius.imag, xmlElement)
		self.packingDensity = evaluate.getEvaluatedFloatByKeys(0.2, ['packingDensity', 'density'], xmlElement)
		self.radius = lineation.getComplexByPrefixBeginEnd('elementRadius', 'elementDiameter', complex(1.0, 1.0), xmlElement)
		self.radius = lineation.getComplexByPrefixBeginEnd('radius', 'diameter', self.radius, xmlElement)
		self.seed = evaluate.getEvaluatedIntDefault(None, 'seed', xmlElement)
		self.target = evaluate.getTransformedPathsByKey([], 'target', xmlElement)
		self.typeMenuRadioStrings = 'hexagonal random rectangular'.split()
		self.typeString = evaluate.getEvaluatedStringDefault('rectangular', 'type', xmlElement)
		self.zigzag = evaluate.getEvaluatedBooleanDefault(True, 'zigzag', xmlElement)
Пример #14
0
 def __init__(self, xmlElement):
     'Set defaults.'
     self.sides = evaluate.getEvaluatedFloatDefault(4.0, 'sides',
                                                    xmlElement)
     self.sideAngle = 2.0 * math.pi / self.sides
     cosSide = math.cos(0.5 * self.sideAngle)
     self.radius = lineation.getComplexByMultiplierPrefixes(
         cosSide, ['apothem', 'inradius'], complex(1.0, 1.0), xmlElement)
     self.radius = lineation.getComplexByPrefixes(['demisize', 'radius'],
                                                  self.radius, xmlElement)
     self.radius = lineation.getComplexByMultiplierPrefixes(
         2.0, ['diameter', 'size'], self.radius, xmlElement)
     self.sidesCeiling = int(math.ceil(abs(self.sides)))
     self.start = evaluate.getEvaluatedIntDefault(0, 'start', xmlElement)
     self.start = lineation.getWrappedInteger(self.start, 360.0)
     end = evaluate.getEvaluatedIntDefault(self.sidesCeiling, 'end',
                                           xmlElement)
     end = lineation.getWrappedInteger(end, self.sidesCeiling)
     self.revolutions = evaluate.getEvaluatedIntDefault(
         1, 'revolutions', xmlElement)
     self.extent = evaluate.getEvaluatedIntDefault(end - self.start,
                                                   'extent', xmlElement)
     self.extent += self.sidesCeiling * (self.revolutions - 1)
     self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
Пример #15
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.depthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
			self.depthBottomOverRadius, 'depthBottomOverRadius', xmlElement)
		self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.depthTopOverRadius, 'depthOverRadius', xmlElement)
		self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.depthTopOverRadius, 'depthTopOverRadius', xmlElement)
		self.radius = evaluate.getEvaluatedFloatDefault(self.radius, 'radius', xmlElement)
		self.sides = evaluate.getEvaluatedIntDefault(self.sides, 'sides', xmlElement)
		if self.depthBottom == None:
			self.depthBottom = self.radius * self.depthBottomOverRadius
		self.depthBottom = evaluate.getEvaluatedFloatDefault(self.depthBottom, 'depthBottom', xmlElement)
		if self.depthTop == None:
			self.depthTop = self.radius * self.depthTopOverRadius
		self.depthTop = evaluate.getEvaluatedFloatDefault(self.depthTop, 'depth', xmlElement)
		self.depthTop = evaluate.getEvaluatedFloatDefault(self.depthTop, 'depthTop', xmlElement)
Пример #16
0
 def __init__(self, xmlElement):
     'Set defaults.'
     self.depthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
         0.0, 'depthBottomOverRadius', xmlElement)
     self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         0.0, 'depthOverRadius', xmlElement)
     self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthTopOverRadius, 'depthTopOverRadius', xmlElement)
     self.radius = evaluate.getEvaluatedFloatDefault(
         1.0, 'radius', xmlElement)
     self.sides = evaluate.getEvaluatedIntDefault(4, 'sides', xmlElement)
     self.depthBottom = self.radius * self.depthBottomOverRadius
     self.depthBottom = evaluate.getEvaluatedFloatDefault(
         self.depthBottom, 'depthBottom', xmlElement)
     self.depthTop = self.radius * self.depthTopOverRadius
     self.depthTop = evaluate.getEvaluatedFloatDefault(
         self.depthTop, 'depth', xmlElement)
     self.depthTop = evaluate.getEvaluatedFloatDefault(
         self.depthTop, 'depthTop', xmlElement)
Пример #17
0
 def __init__(self, xmlElement):
     'Set defaults.'
     self.inradius = lineation.getComplexByPrefixes(
         ['demisize', 'inradius'], complex(1.0, 1.0), xmlElement)
     self.inradius = lineation.getComplexByMultiplierPrefix(
         2.0, 'size', self.inradius, xmlElement)
     self.demiwidth = lineation.getFloatByPrefixBeginEnd(
         'demiwidth', 'width', self.inradius.real, xmlElement)
     self.demiheight = lineation.getFloatByPrefixBeginEnd(
         'demiheight', 'height', self.inradius.imag, xmlElement)
     self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd(
         'bottomdemiwidth', 'bottomwidth', self.demiwidth, xmlElement)
     self.topDemiwidth = lineation.getFloatByPrefixBeginEnd(
         'topdemiwidth', 'topwidth', self.demiwidth, xmlElement)
     self.interiorAngle = evaluate.getEvaluatedFloatDefault(
         90.0, 'interiorangle', xmlElement)
     self.revolutions = evaluate.getEvaluatedIntDefault(
         1, 'revolutions', xmlElement)
     self.spiral = evaluate.getVector3ByPrefix(None, 'spiral', xmlElement)
Пример #18
0
 def setToXMLElement(self, xmlElement):
     "Set to the xmlElement."
     self.inradius = lineation.getComplexByPrefixes(
         ['demisize', 'inradius'], self.inradius, xmlElement)
     self.inradius = lineation.getComplexByMultiplierPrefix(
         2.0, 'size', self.inradius, xmlElement)
     self.demiwidth = lineation.getFloatByPrefixBeginEnd(
         'demiwidth', 'width', self.inradius.real, xmlElement)
     self.demiheight = lineation.getFloatByPrefixBeginEnd(
         'demiheight', 'height', self.inradius.imag, xmlElement)
     self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd(
         'bottomdemiwidth', 'bottomwidth', self.demiwidth, xmlElement)
     self.topDemiwidth = lineation.getFloatByPrefixBeginEnd(
         'topdemiwidth', 'topwidth', self.demiwidth, xmlElement)
     self.interiorAngle = evaluate.getEvaluatedFloatDefault(
         self.interiorAngle, 'interiorangle', xmlElement)
     self.revolutions = evaluate.getEvaluatedIntDefault(
         self.revolutions, 'revolutions', xmlElement)
     self.spiral = evaluate.getVector3ByPrefix('spiral', self.spiral,
                                               xmlElement)
Пример #19
0
 def setToXMLElement(self, xmlElement):
     "Set to the xmlElement."
     self.depthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthBottomOverRadius, "depthBottomOverRadius", xmlElement
     )
     self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthTopOverRadius, "depthOverRadius", xmlElement
     )
     self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthTopOverRadius, "depthTopOverRadius", xmlElement
     )
     self.radius = evaluate.getEvaluatedFloatDefault(self.radius, "radius", xmlElement)
     self.sides = evaluate.getEvaluatedIntDefault(self.sides, "sides", xmlElement)
     if self.depthBottom == None:
         self.depthBottom = self.radius * self.depthBottomOverRadius
     self.depthBottom = evaluate.getEvaluatedFloatDefault(self.depthBottom, "depthBottom", xmlElement)
     if self.depthTop == None:
         self.depthTop = self.radius * self.depthTopOverRadius
     self.depthTop = evaluate.getEvaluatedFloatDefault(self.depthTop, "depth", xmlElement)
     self.depthTop = evaluate.getEvaluatedFloatDefault(self.depthTop, "depthTop", xmlElement)
Пример #20
0
 def setToXMLElement(self, xmlElement):
     "Set to the xmlElement."
     self.depthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthBottomOverRadius, 'depthBottomOverRadius', xmlElement)
     self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthTopOverRadius, 'depthOverRadius', xmlElement)
     self.depthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.depthTopOverRadius, 'depthTopOverRadius', xmlElement)
     self.radius = evaluate.getEvaluatedFloatDefault(
         self.radius, 'radius', xmlElement)
     self.sides = evaluate.getEvaluatedIntDefault(self.sides, 'sides',
                                                  xmlElement)
     if self.depthBottom == None:
         self.depthBottom = self.radius * self.depthBottomOverRadius
     self.depthBottom = evaluate.getEvaluatedFloatDefault(
         self.depthBottom, 'depthBottom', xmlElement)
     if self.depthTop == None:
         self.depthTop = self.radius * self.depthTopOverRadius
     self.depthTop = evaluate.getEvaluatedFloatDefault(
         self.depthTop, 'depth', xmlElement)
     self.depthTop = evaluate.getEvaluatedFloatDefault(
         self.depthTop, 'depthTop', xmlElement)
Пример #21
0
def getRandomGrid(derivation, diameter, loopsComplex, maximumComplex, minimumComplex, xmlElement):
	"Get rectangular grid."
	gridPath = []
	diameterReciprocal = complex(1.0 / diameter.real, 1.0 / diameter.imag)
	diameterSquared = diameter.real * diameter.real + diameter.imag * diameter.imag
	elements = int(math.ceil(derivation.packingDensity * euclidean.getAreaLoops(loopsComplex) / diameterSquared / math.sqrt(0.75)))
	elements = evaluate.getEvaluatedIntDefault(elements, 'elements', xmlElement)
	failedPlacementAttempts = 0
	pixelDictionary = {}
	if derivation.seed != None:
		random.seed(derivation.seed)
	successfulPlacementAttempts = 0
	while failedPlacementAttempts < 100:
		point = euclidean.getRandomComplex(minimumComplex, maximumComplex)
		if getIsPointInsideZoneAwayOthers(diameterReciprocal, loopsComplex, point, pixelDictionary):
			gridPath.append(point)
			euclidean.addElementToPixelListFromPoint(point, pixelDictionary, point)
			successfulPlacementAttempts += 1
		else:
			failedPlacementAttempts += 1
		if successfulPlacementAttempts >= elements:
			return gridPath
	return gridPath
Пример #22
0
 def __init__(self, xmlElement):
     'Set defaults.'
     self.inradius = lineation.getComplexByPrefixes(
         ['demisize', 'inradius'], complex(10.0, 10.0), xmlElement)
     self.inradius = lineation.getComplexByMultiplierPrefix(
         2.0, 'size', self.inradius, xmlElement)
     self.demiwidth = lineation.getFloatByPrefixBeginEnd(
         'demiwidth', 'width', self.inradius.real, xmlElement)
     self.demiheight = lineation.getFloatByPrefixBeginEnd(
         'demiheight', 'height', self.inradius.imag, xmlElement)
     self.packingDensity = evaluate.getEvaluatedFloatByKeys(
         0.2, ['packingDensity', 'density'], xmlElement)
     self.radius = lineation.getComplexByPrefixBeginEnd(
         'elementRadius', 'elementDiameter', complex(1.0, 1.0), xmlElement)
     self.radius = lineation.getComplexByPrefixBeginEnd(
         'radius', 'diameter', self.radius, xmlElement)
     self.seed = evaluate.getEvaluatedIntDefault(None, 'seed', xmlElement)
     self.target = evaluate.getTransformedPathsByKey([], 'target',
                                                     xmlElement)
     self.typeMenuRadioStrings = 'hexagonal random rectangular'.split()
     self.typeString = evaluate.getEvaluatedStringDefault(
         'rectangular', 'type', xmlElement)
     self.zigzag = evaluate.getEvaluatedBooleanDefault(
         True, 'zigzag', xmlElement)
Пример #23
0
 def setToXMLElement(self, xmlElement):
     "Set to the xmlElement."
     self.bevelOverClearance = evaluate.getEvaluatedFloatDefault(
         self.bevelOverClearance, 'bevelOverClearance', xmlElement)
     self.clearanceOverWavelength = evaluate.getEvaluatedFloatDefault(
         self.clearanceOverWavelength, 'clearanceOverWavelength',
         xmlElement)
     self.collarWidthOverShaftRadius = evaluate.getEvaluatedFloatDefault(
         self.collarWidthOverShaftRadius, 'collarWidthOverShaftRadius',
         xmlElement)
     self.creationType = evaluate.getEvaluatedStringDefault(
         self.creationType, 'creationType', xmlElement)
     self.helixAngle = evaluate.getEvaluatedFloatDefault(
         self.helixAngle, 'helixAngle', xmlElement)
     self.helixType = evaluate.getEvaluatedStringDefault(
         self.helixType, 'helixType', xmlElement)
     self.lighteningHoleMarginOverRimWidth = evaluate.getEvaluatedFloatDefault(
         self.lighteningHoleMarginOverRimWidth,
         'lighteningHoleMarginOverRimWidth', xmlElement)
     self.lighteningHoleMinimumRadius = evaluate.getEvaluatedFloatDefault(
         self.lighteningHoleMinimumRadius, 'lighteningHoleMinimumRadius',
         xmlElement)
     self.moveType = evaluate.getEvaluatedStringDefault(
         self.moveType, 'moveType', xmlElement)
     self.pitchRadius = evaluate.getEvaluatedFloatDefault(
         self.pitchRadius, 'pitchRadius', xmlElement)
     self.pressureAngle = evaluate.getEvaluatedFloatDefault(
         self.pressureAngle, 'pressureAngle', xmlElement)
     self.profileDefinitionSurfaces = evaluate.getEvaluatedIntDefault(
         self.profileDefinitionSurfaces, 'profileDefinitionSurfaces',
         xmlElement)
     self.rackLengthOverRadius = evaluate.getEvaluatedFloatDefault(
         self.rackLengthOverRadius, 'rackLengthOverRadius', xmlElement)
     self.rackWidthOverThickness = evaluate.getEvaluatedFloatDefault(
         self.rackWidthOverThickness, 'rackWidthOverThickness', xmlElement)
     self.rimWidthOverRadius = evaluate.getEvaluatedFloatDefault(
         self.rimWidthOverRadius, 'rimWidthOverRadius', xmlElement)
     self.shaftDepthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
         self.shaftDepthBottomOverRadius, 'shaftDepthBottomOverRadius',
         xmlElement)
     self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.shaftDepthTopOverRadius, 'shaftDepthOverRadius', xmlElement)
     self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
         self.shaftDepthTopOverRadius, 'shaftDepthTopOverRadius',
         xmlElement)
     self.shaftRadiusOverPitchRadius = evaluate.getEvaluatedFloatDefault(
         self.shaftRadiusOverPitchRadius, 'shaftRadiusOverPitchRadius',
         xmlElement)
     self.shaftSides = evaluate.getEvaluatedIntDefault(
         self.shaftSides, 'shaftSides', xmlElement)
     self.teethPinion = evaluate.getEvaluatedIntDefault(
         self.teethPinion, 'teeth', xmlElement)
     self.teethPinion = evaluate.getEvaluatedIntDefault(
         self.teethPinion, 'teethPinion', xmlElement)
     self.teethSecond = evaluate.getEvaluatedIntDefault(
         self.teethSecond, 'teethSecond', xmlElement)
     self.thickness = evaluate.getEvaluatedFloatDefault(
         self.thickness, 'thickness', xmlElement)
     # Set absolute variables.
     self.wavelength = self.pitchRadius * 2.0 * math.pi / float(
         self.teethPinion)
     if self.clearance == None:
         self.clearance = self.wavelength * self.clearanceOverWavelength
     self.clearance = evaluate.getEvaluatedFloatDefault(
         self.clearance, 'clearance', xmlElement)
     if self.bevel == None:
         self.bevel = self.clearance * self.bevelOverClearance
     self.bevel = evaluate.getEvaluatedFloatDefault(self.bevel, 'bevel',
                                                    xmlElement)
     if self.rackLength == None:
         self.rackLength = self.pitchRadius * self.rackLengthOverRadius
     self.rackLength = evaluate.getEvaluatedFloatDefault(
         self.rackLength, 'rackLength', xmlElement)
     if self.rackWidth == None:
         self.rackWidth = self.thickness * self.rackWidthOverThickness
     self.rackWidth = evaluate.getEvaluatedFloatDefault(
         self.rackWidth, 'rackWidth', xmlElement)
     if self.rimWidth == None:
         self.rimWidth = self.pitchRadius * self.rimWidthOverRadius
     self.rimWidth = evaluate.getEvaluatedFloatDefault(
         self.rimWidth, 'rimWidth', xmlElement)
     if self.shaftRadius == None:
         self.shaftRadius = self.pitchRadius * self.shaftRadiusOverPitchRadius
     self.shaftRadius = evaluate.getEvaluatedFloatDefault(
         self.shaftRadius, 'shaftRadius', xmlElement)
     if self.collarWidth == None:
         self.collarWidth = self.shaftRadius * self.collarWidthOverShaftRadius
     self.collarWidth = evaluate.getEvaluatedFloatDefault(
         self.collarWidth, 'collarWidth', xmlElement)
     if self.lighteningHoleMargin == None:
         self.lighteningHoleMargin = self.rimWidth * self.lighteningHoleMarginOverRimWidth
     self.lighteningHoleMargin = evaluate.getEvaluatedFloatDefault(
         self.lighteningHoleMargin, 'lighteningHoleMargin', xmlElement)
     if self.shaftDepthBottom == None:
         self.shaftDepthBottom = self.shaftRadius * self.shaftDepthBottomOverRadius
     self.shaftDepthBottom = evaluate.getEvaluatedFloatDefault(
         self.shaftDepthBottom, 'shaftDepthBottom', xmlElement)
     if self.shaftDepthTop == None:
         self.shaftDepthTop = self.shaftRadius * self.shaftDepthTopOverRadius
     self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(
         self.shaftDepthTop, 'shaftDepth', xmlElement)
     self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(
         self.shaftDepthTop, 'shaftDepthTop', xmlElement)
     # Set derived values.
     self.helixRadian = math.radians(self.helixAngle)
     self.tanHelix = math.tan(self.helixRadian)
     self.helixThickness = self.tanHelix * self.thickness
     self.pressureRadian = math.radians(self.pressureAngle)
     self.cosPressure = math.cos(self.pressureRadian)
     self.sinPressure = math.sin(self.pressureRadian)
     self.tanPressure = math.tan(self.pressureRadian)
     # tooth multiplied by 0.99 is because at greater than 0.99 there is an intersection
     self.xToothMultiplier = 0.99 - 0.01 * self.tanHelix
     self.halfWavelength = 0.5 * self.wavelength
     self.quarterWavelength = 0.25 * self.wavelength
     self.pinionToothProfile = getToothProfileHalfCylinder(
         self, self.pitchRadius, self.teethPinion)
     self.addendum = self.pinionToothProfile[-1].imag - self.pitchRadius
     self.dedendum = abs(
         self.pinionToothProfile[-1]) - self.pitchRadius + self.clearance
     self.xmlElement = xmlElement
Пример #24
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.clearanceOverWavelength = evaluate.getEvaluatedFloatDefault(
			self.clearanceOverWavelength, 'clearanceOverWavelength', xmlElement)
		self.collarWidthOverShaftRadius = evaluate.getEvaluatedFloatDefault(
			self.collarWidthOverShaftRadius, 'collarWidthOverShaftRadius', xmlElement)
		self.copyShallow = xmlElement.getCopyShallow()
		self.creationType = evaluate.getEvaluatedStringDefault(self.creationType, 'creationType', xmlElement)
		self.gearCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault(
			self.gearCollarThicknessOverThickness, 'gearCollarThicknessOverThickness', xmlElement)
		self.helixAngle = evaluate.getEvaluatedFloatDefault(self.helixAngle, 'helixAngle', xmlElement)
		self.helixType = evaluate.getEvaluatedStringDefault(self.helixType, 'helixType', xmlElement)
		self.keywayRadiusOverRadius = evaluate.getEvaluatedFloatDefault(
			self.keywayRadiusOverRadius, 'keywayRadiusOverRadius', xmlElement)
		self.lighteningHoleMarginOverRimWidth = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMarginOverRimWidth, 'lighteningHoleMarginOverRimWidth', xmlElement)
		self.lighteningHoleMinimumRadius = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMinimumRadius, 'lighteningHoleMinimumRadius', xmlElement)
		self.moveType = evaluate.getEvaluatedStringDefault(self.moveType, 'moveType', xmlElement)
		self.operatingAngle = evaluate.getEvaluatedFloatDefault(self.operatingAngle, 'operatingAngle', xmlElement)
		self.pinionCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault(
			self.pinionCollarThicknessOverThickness, 'pinionCollarThicknessOverThickness', xmlElement)
		self.pinionThickness = evaluate.getEvaluatedFloatDefault(self.pinionThickness, 'pinionThickness', xmlElement)
		self.pinionThickness = evaluate.getEvaluatedFloatDefault(self.pinionThickness, 'thickness', xmlElement)
		self.pitchRadius = evaluate.getEvaluatedFloatDefault(self.pitchRadius, 'pitchRadius', xmlElement)
		self.plateClearanceOverThickness = evaluate.getEvaluatedFloatDefault(
			self.plateClearanceOverThickness, 'plateClearanceOverThickness', xmlElement)
		self.plateThicknessOverThickness = evaluate.getEvaluatedFloatDefault(
			self.plateThicknessOverThickness, 'plateThicknessOverThickness', xmlElement)
		self.pressureAngle = evaluate.getEvaluatedFloatDefault(self.pressureAngle, 'pressureAngle', xmlElement)
		self.profileSurfaces = evaluate.getEvaluatedIntDefault(self.profileSurfaces, 'profileSurfaces', xmlElement)
		self.rackHoleRadiusOverWidth = evaluate.getEvaluatedFloatDefault(
			self.rackHoleRadiusOverWidth, 'rackHoleRadiusOverWidth', xmlElement)
		self.rackHoleBelowOverWidth = evaluate.getEvaluatedFloatDefault(
			self.rackHoleBelowOverWidth, 'rackHoleBelowOverWidth', xmlElement)
		self.rackHoleStep = evaluate.getEvaluatedFloatDefault(
			self.rackHoleStep, 'rackHoleStep', xmlElement)
		self.rackLengthOverRadius = evaluate.getEvaluatedFloatDefault(self.rackLengthOverRadius, 'rackLengthOverRadius', xmlElement)
		self.rackWidthOverThickness = evaluate.getEvaluatedFloatDefault(
			self.rackWidthOverThickness, 'rackWidthOverThickness', xmlElement)
		self.rimWidthOverRadius = evaluate.getEvaluatedFloatDefault(self.rimWidthOverRadius, 'rimWidthOverRadius', xmlElement)
		self.rootBevelOverClearance = evaluate.getEvaluatedFloatDefault(
			self.rootBevelOverClearance, 'rootBevelOverClearance', xmlElement)
		self.shaftDepthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthBottomOverRadius, 'shaftDepthBottomOverRadius', xmlElement)
		self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthTopOverRadius, 'shaftDepthOverRadius', xmlElement)
		self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthTopOverRadius, 'shaftDepthTopOverRadius', xmlElement)
		self.shaftRadiusOverPitchRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftRadiusOverPitchRadius, 'shaftRadiusOverPitchRadius', xmlElement)
		self.shaftSides = evaluate.getEvaluatedIntDefault(self.shaftSides, 'shaftSides', xmlElement)
		self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teeth', xmlElement)
		self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teethPinion', xmlElement)
		self.teethGear = evaluate.getEvaluatedIntDefault(self.teethGear, 'teethGear', xmlElement)
		self.tipBevelOverClearance = evaluate.getEvaluatedFloatDefault(self.tipBevelOverClearance, 'tipBevelOverClearance', xmlElement)
		self.toothWidthMultiplier = evaluate.getEvaluatedFloatDefault(self.toothWidthMultiplier, 'toothWidthMultiplier', xmlElement)
		# Set absolute variables.
		self.wavelength = self.pitchRadius * 2.0 * math.pi / float(self.teethPinion)
		if self.clearance == None:
			self.clearance = self.wavelength * self.clearanceOverWavelength
		self.clearance = evaluate.getEvaluatedFloatDefault(self.clearance, 'clearance', xmlElement)
		if self.gearCollarThickness == None:
			self.gearCollarThickness = self.pinionThickness * self.gearCollarThicknessOverThickness
		self.gearCollarThickness = evaluate.getEvaluatedFloatDefault(self.gearCollarThickness, 'gearCollarThickness', xmlElement)
		if self.gearHolePaths == None:
			self.gearHolePaths = evaluate.getTransformedPathsByKey('gearHolePaths', xmlElement)
		if self.pinionCollarThickness == None:
			self.pinionCollarThickness = self.pinionThickness * self.pinionCollarThicknessOverThickness
		self.pinionCollarThickness = evaluate.getEvaluatedFloatDefault(self.pinionCollarThickness, 'pinionCollarThickness', xmlElement)
		if self.plateThickness == None:
			self.plateThickness = self.pinionThickness * self.plateThicknessOverThickness
		self.plateThickness = evaluate.getEvaluatedFloatDefault(self.plateThickness, 'plateThickness', xmlElement)
		if self.plateClearance == None:
			self.plateClearance = self.plateThickness * self.plateClearanceOverThickness
		self.plateClearance = evaluate.getEvaluatedFloatDefault(self.plateClearance, 'plateClearance', xmlElement)
		if self.rackLength == None:
			self.rackLength = self.pitchRadius * self.rackLengthOverRadius
		self.rackLength = evaluate.getEvaluatedFloatDefault(self.rackLength, 'rackLength', xmlElement)
		self.rackDemilength = 0.5 * self.rackLength
		if self.rackWidth == None:
			self.rackWidth = self.pinionThickness * self.rackWidthOverThickness
		self.rackWidth = evaluate.getEvaluatedFloatDefault(self.rackWidth, 'rackWidth', xmlElement)
		if self.rimWidth == None:
			self.rimWidth = self.pitchRadius * self.rimWidthOverRadius
		self.rimWidth = evaluate.getEvaluatedFloatDefault(self.rimWidth, 'rimWidth', xmlElement)
		if self.rootBevel == None:
			self.rootBevel = self.clearance * self.rootBevelOverClearance
		self.rootBevel = evaluate.getEvaluatedFloatDefault(self.rootBevel, 'rootBevel', xmlElement)
		if self.shaftRadius == None:
			self.shaftRadius = self.pitchRadius * self.shaftRadiusOverPitchRadius
		self.shaftRadius = evaluate.getEvaluatedFloatDefault(self.shaftRadius, 'shaftRadius', xmlElement)
		if self.collarWidth == None:
			self.collarWidth = self.shaftRadius * self.collarWidthOverShaftRadius
		self.collarWidth = evaluate.getEvaluatedFloatDefault(self.collarWidth, 'collarWidth', xmlElement)
		if self.keywayRadius == None:
			self.keywayRadius = self.shaftRadius * self.keywayRadiusOverRadius
		self.keywayRadius = lineation.getFloatByPrefixBeginEnd('keywayRadius', 'keywayDiameter', self.keywayRadius, xmlElement)
		if self.lighteningHoleMargin == None:
			self.lighteningHoleMargin = self.rimWidth * self.lighteningHoleMarginOverRimWidth
		self.lighteningHoleMargin = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMargin, 'lighteningHoleMargin', xmlElement)
		if self.rackHoleBelow == None:
			self.rackHoleBelow = self.rackWidth * self.rackHoleBelowOverWidth
		self.rackHoleBelow = evaluate.getEvaluatedFloatDefault(self.rackHoleBelow, 'rackHoleBelow', xmlElement)
		if self.rackHoleRadius == None:
			self.rackHoleRadius = self.rackWidth * self.rackHoleRadiusOverWidth
		self.rackHoleRadius = lineation.getFloatByPrefixBeginEnd('rackHoleRadius', 'rackHoleDiameter', self.rackHoleRadius, xmlElement)
		if self.rackHoleStep == None:
			self.rackHoleStep = self.rackWidth * self.rackHoleStepOverWidth
		self.rackHoleStep = evaluate.getEvaluatedFloatDefault(self.rackHoleStep, 'rackHoleStep', xmlElement)
		if self.shaftDepthBottom == None:
			self.shaftDepthBottom = self.shaftRadius * self.shaftDepthBottomOverRadius
		self.shaftDepthBottom = evaluate.getEvaluatedFloatDefault(self.shaftDepthBottom, 'shaftDepthBottom', xmlElement)
		if self.shaftDepthTop == None:
			self.shaftDepthTop = self.shaftRadius * self.shaftDepthTopOverRadius
		self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepth', xmlElement)
		self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepthTop', xmlElement)
		if self.shaftPath == None:
			self.shaftPath = evaluate.getTransformedPathByKey('shaftPath', xmlElement)
		if len(self.shaftPath) < 3:
			self.shaftPath = shaft.getShaftPath(self.shaftDepthBottom, self.shaftDepthTop, self.shaftRadius, -self.shaftSides)
		if self.tipBevel == None:
			self.tipBevel = self.clearance * self.tipBevelOverClearance
		self.tipBevel = evaluate.getEvaluatedFloatDefault(self.tipBevel, 'tipBevel', xmlElement)
		# Set derived values.
		self.helixRadian = math.radians(self.helixAngle)
		if self.teethGear <= 0.0 and self.operatingAngle != 180.0:
			print('Warning, an operatingAngle other than 180 degrees can only work with a positive number of gear teeth.')
			print('Therefore the operatingAngle will be reset to 180 degrees.')
			self.operatingAngle = 180.0
		self.tanHelix = math.tan(self.helixRadian)
		self.helixThickness = self.tanHelix * self.pinionThickness
		self.operatingRadian = math.radians(self.operatingAngle)
		self.pitchRadiusGear = self.pitchRadius * float(self.teethGear) / float(self.teethPinion)
		self.pressureRadian = math.radians(self.pressureAngle)
		self.cosPressure = math.cos(self.pressureRadian)
		self.sinPressure = math.sin(self.pressureRadian)
		self.tanPressure = math.tan(self.pressureRadian)
		self.halfWavelength = 0.5 * self.wavelength
		if self.helixPath == None:
			self.helixPath = euclidean.getComplexPath(evaluate.getTransformedPathByKey('helixPath', xmlElement))
		if len(self.helixPath) < 1:
			self.helixPath = getHelixComplexPath(self, xmlElement)
		self.quarterWavelength = 0.25 * self.wavelength
		self.shaftRimRadius = self.shaftRadius + self.collarWidth
		self.toothProfileHalf = getToothProfileHalfCylinder(self, self.pitchRadius)
		self.toothProfileHalf = getWidthMultipliedPath(self.toothProfileHalf, self.toothWidthMultiplier)
		self.addendum = self.toothProfileHalf[-1].imag - self.pitchRadius
		self.dedendum = abs(self.toothProfileHalf[-1]) - self.pitchRadius + self.clearance
		self.pinionToothProfile = getToothProfileCylinderByProfile(self, self.pitchRadius, self.teethPinion, self.toothProfileHalf)
		self.xmlElement = xmlElement
Пример #25
0
	def __init__(self, xmlElement):
		'Set defaults.'
		self.clearanceOverWavelength = evaluate.getEvaluatedFloatDefault(0.1, 'clearanceOverWavelength', xmlElement)
		self.collarWidthOverShaftRadius = evaluate.getEvaluatedFloatDefault(1.0, 'collarWidthOverShaftRadius', xmlElement)
		self.copyShallow = xmlElement.getCopyShallow()
		self.creationType = evaluate.getEvaluatedStringDefault('both', 'creationType', xmlElement)
		self.creationTypeMenuRadioStrings = 'both first second'.split()
		self.gearCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault(
			0.0, 'gearCollarThicknessOverThickness', xmlElement)
		self.helixAngle = evaluate.getEvaluatedFloatDefault(0.0, 'helixAngle', xmlElement)
		self.helixType = evaluate.getEvaluatedStringDefault('basic', 'helixType', xmlElement)
		self.helixTypeMenuRadioStrings = 'basic herringbone parabolic'.split()
		self.keywayRadiusOverRadius = evaluate.getEvaluatedFloatDefault(0.5, 'keywayRadiusOverRadius', xmlElement)
		self.lighteningHoleMarginOverRimWidth = evaluate.getEvaluatedFloatDefault(
			1.0, 'lighteningHoleMarginOverRimWidth', xmlElement)
		self.lighteningHoleMinimumRadius = evaluate.getEvaluatedFloatDefault(
			1.0, 'lighteningHoleMinimumRadius', xmlElement)
		self.moveType = evaluate.getEvaluatedStringDefault('separate', 'moveType', xmlElement)
		self.moveTypeMenuRadioStrings = 'mesh none separate vertical'.split()
		self.operatingAngle = evaluate.getEvaluatedFloatDefault(180.0, 'operatingAngle', xmlElement)
		self.pinionCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault(
			0.0, 'pinionCollarThicknessOverThickness', xmlElement)
		self.pinionThickness = evaluate.getEvaluatedFloatDefault(10.0, 'pinionThickness', xmlElement)
		self.pinionThickness = evaluate.getEvaluatedFloatDefault(self.pinionThickness, 'thickness', xmlElement)
		self.plateClearanceOverThickness = evaluate.getEvaluatedFloatDefault(0.2, 'plateClearanceOverThickness', xmlElement)
		self.plateThicknessOverThickness = evaluate.getEvaluatedFloatDefault(0.5, 'plateThicknessOverThickness', xmlElement)
		self.pressureAngle = evaluate.getEvaluatedFloatDefault(20.0, 'pressureAngle', xmlElement)
		self.profileSurfaces = evaluate.getEvaluatedIntDefault(11, 'profileSurfaces', xmlElement)
		self.rackHoleRadiusOverWidth = evaluate.getEvaluatedFloatDefault(0.0, 'rackHoleRadiusOverWidth', xmlElement)
		self.rackHoleBelowOverWidth = evaluate.getEvaluatedFloatDefault(0.6, 'rackHoleBelowOverWidth', xmlElement)
		self.rackHoleStepOverWidth = evaluate.getEvaluatedFloatDefault(1.0, 'rackHoleStepOverWidth', xmlElement)
		self.rackLengthOverRadius = evaluate.getEvaluatedFloatDefault(math.pi + math.pi, 'rackLengthOverRadius', xmlElement)
		self.rackWidthOverThickness = evaluate.getEvaluatedFloatDefault(1.0, 'rackWidthOverThickness', xmlElement)
		self.rimWidthOverRadius = evaluate.getEvaluatedFloatDefault(0.2, 'rimWidthOverRadius', xmlElement)
		self.rootBevelOverClearance = evaluate.getEvaluatedFloatDefault(0.5, 'rootBevelOverClearance', xmlElement)
		self.shaftDepthBottomOverRadius = evaluate.getEvaluatedFloatDefault(0.0, 'shaftDepthBottomOverRadius', xmlElement)
		self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(0.0, 'shaftDepthOverRadius', xmlElement)
		self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthTopOverRadius, 'shaftDepthTopOverRadius', xmlElement)
		self.shaftRadiusOverPitchRadius = evaluate.getEvaluatedFloatDefault(0.0, 'shaftRadiusOverPitchRadius', xmlElement)
		self.shaftSides = evaluate.getEvaluatedIntDefault(4, 'shaftSides', xmlElement)
		self.teethPinion = evaluate.getEvaluatedIntDefault(7, 'teeth', xmlElement)
		self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teethPinion', xmlElement)
		self.teethGear = evaluate.getEvaluatedIntDefault(17, 'teethGear', xmlElement)
		totalTeethOverPinionTeeth = float(self.teethGear + self.teethPinion) / float(self.teethPinion)
		self.centerDistance = evaluate.getEvaluatedFloatDefault(20.0 * totalTeethOverPinionTeeth, 'centerDistance', xmlElement)
		derivedPitchRadius = self.centerDistance / totalTeethOverPinionTeeth
		self.pitchRadius = evaluate.getEvaluatedFloatDefault(derivedPitchRadius, 'pitchRadius', xmlElement)
		self.tipBevelOverClearance = evaluate.getEvaluatedFloatDefault(0.1, 'tipBevelOverClearance', xmlElement)
		# tooth multiplied by 0.99999 to avoid an intersection
		self.toothWidthMultiplier = evaluate.getEvaluatedFloatDefault(0.99999, 'toothWidthMultiplier', xmlElement)
		# Set absolute variables.
		self.wavelength = self.pitchRadius * 2.0 * math.pi / float(self.teethPinion)
		self.clearance = self.wavelength * self.clearanceOverWavelength
		self.clearance = evaluate.getEvaluatedFloatDefault(self.clearance, 'clearance', xmlElement)
		self.gearCollarThickness = self.pinionThickness * self.gearCollarThicknessOverThickness
		self.gearCollarThickness = evaluate.getEvaluatedFloatDefault(self.gearCollarThickness, 'gearCollarThickness', xmlElement)
		self.gearHolePaths = evaluate.getTransformedPathsByKey([], 'gearHolePaths', xmlElement)
		self.pinionCollarThickness = self.pinionThickness * self.pinionCollarThicknessOverThickness
		self.pinionCollarThickness = evaluate.getEvaluatedFloatDefault(self.pinionCollarThickness, 'pinionCollarThickness', xmlElement)
		self.plateThickness = self.pinionThickness * self.plateThicknessOverThickness
		self.plateThickness = evaluate.getEvaluatedFloatDefault(self.plateThickness, 'plateThickness', xmlElement)
		self.plateClearance = self.plateThickness * self.plateClearanceOverThickness
		self.plateClearance = evaluate.getEvaluatedFloatDefault(self.plateClearance, 'plateClearance', xmlElement)
		self.rackLength = self.pitchRadius * self.rackLengthOverRadius
		self.rackLength = evaluate.getEvaluatedFloatDefault(self.rackLength, 'rackLength', xmlElement)
		self.rackDemilength = 0.5 * self.rackLength
		self.rackWidth = self.pinionThickness * self.rackWidthOverThickness
		self.rackWidth = evaluate.getEvaluatedFloatDefault(self.rackWidth, 'rackWidth', xmlElement)
		self.rimWidth = self.pitchRadius * self.rimWidthOverRadius
		self.rimWidth = evaluate.getEvaluatedFloatDefault(self.rimWidth, 'rimWidth', xmlElement)
		self.rootBevel = self.clearance * self.rootBevelOverClearance
		self.rootBevel = evaluate.getEvaluatedFloatDefault(self.rootBevel, 'rootBevel', xmlElement)
		self.shaftRadius = self.pitchRadius * self.shaftRadiusOverPitchRadius
		self.shaftRadius = evaluate.getEvaluatedFloatDefault(self.shaftRadius, 'shaftRadius', xmlElement)
		self.collarWidth = self.shaftRadius * self.collarWidthOverShaftRadius
		self.collarWidth = evaluate.getEvaluatedFloatDefault(self.collarWidth, 'collarWidth', xmlElement)
		self.keywayRadius = self.shaftRadius * self.keywayRadiusOverRadius
		self.keywayRadius = lineation.getFloatByPrefixBeginEnd('keywayRadius', 'keywayDiameter', self.keywayRadius, xmlElement)
		self.lighteningHoleMargin = self.rimWidth * self.lighteningHoleMarginOverRimWidth
		self.lighteningHoleMargin = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMargin, 'lighteningHoleMargin', xmlElement)
		self.rackHoleBelow = self.rackWidth * self.rackHoleBelowOverWidth
		self.rackHoleBelow = evaluate.getEvaluatedFloatDefault(self.rackHoleBelow, 'rackHoleBelow', xmlElement)
		self.rackHoleRadius = self.rackWidth * self.rackHoleRadiusOverWidth
		self.rackHoleRadius = lineation.getFloatByPrefixBeginEnd('rackHoleRadius', 'rackHoleDiameter', self.rackHoleRadius, xmlElement)
		self.rackHoleStep = self.rackWidth * self.rackHoleStepOverWidth
		self.rackHoleStep = evaluate.getEvaluatedFloatDefault(self.rackHoleStep, 'rackHoleStep', xmlElement)
		self.shaftDepthBottom = self.shaftRadius * self.shaftDepthBottomOverRadius
		self.shaftDepthBottom = evaluate.getEvaluatedFloatDefault(self.shaftDepthBottom, 'shaftDepthBottom', xmlElement)
		self.shaftDepthTop = self.shaftRadius * self.shaftDepthTopOverRadius
		self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepth', xmlElement)
		self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepthTop', xmlElement)
		self.shaftPath = evaluate.getTransformedPathByKey([], 'shaftPath', xmlElement)
		if len(self.shaftPath) < 3:
			self.shaftPath = shaft.getShaftPath(self.shaftDepthBottom, self.shaftDepthTop, self.shaftRadius, -self.shaftSides)
		self.tipBevel = self.clearance * self.tipBevelOverClearance
		self.tipBevel = evaluate.getEvaluatedFloatDefault(self.tipBevel, 'tipBevel', xmlElement)
		# Set derived values.
		self.helixRadian = math.radians(self.helixAngle)
		if self.teethGear <= 0.0 and self.operatingAngle != 180.0:
			print('Warning, an operatingAngle other than 180 degrees can only work with a positive number of gear teeth.')
			print('Therefore the operatingAngle will be reset to 180 degrees.')
			self.operatingAngle = 180.0
		self.tanHelix = math.tan(self.helixRadian)
		self.helixThickness = self.tanHelix * self.pinionThickness
		self.operatingRadian = math.radians(self.operatingAngle)
		self.pitchRadiusGear = self.pitchRadius * float(self.teethGear) / float(self.teethPinion)
		self.pressureRadian = math.radians(self.pressureAngle)
		self.cosPressure = math.cos(self.pressureRadian)
		self.sinPressure = math.sin(self.pressureRadian)
		self.tanPressure = math.tan(self.pressureRadian)
		self.halfWavelength = 0.5 * self.wavelength
		self.helixPath = euclidean.getComplexPath(evaluate.getTransformedPathByKey([], 'helixPath', xmlElement))
		if len(self.helixPath) < 1:
			self.helixPath = getHelixComplexPath(self, xmlElement)
		self.quarterWavelength = 0.25 * self.wavelength
		self.shaftRimRadius = self.shaftRadius + self.collarWidth
		self.toothProfileHalf = getToothProfileHalfCylinder(self, self.pitchRadius)
		self.toothProfileHalf = getWidthMultipliedPath(self.toothProfileHalf, self.toothWidthMultiplier)
		self.addendum = self.toothProfileHalf[-1].imag - self.pitchRadius
		self.dedendum = abs(self.toothProfileHalf[-1]) - self.pitchRadius + self.clearance
		self.pinionToothProfile = getToothProfileCylinderByProfile(self, self.pitchRadius, self.teethPinion, self.toothProfileHalf)
		self.xmlElement = xmlElement
Пример #26
0
def getNumberOfBezierPoints(begin, end, xmlElement):
	"Get the numberOfBezierPoints."
	numberOfBezierPoints = int(math.ceil(0.5 * evaluate.getSidesMinimumThreeBasedOnPrecision(abs(end - begin), xmlElement)))
	return evaluate.getEvaluatedIntDefault(numberOfBezierPoints, 'sides', xmlElement)
Пример #27
0
	def setToXMLElement(self, xmlElement):
		"Set to the xmlElement."
		self.bevelOverClearance = evaluate.getEvaluatedFloatDefault(self.bevelOverClearance, 'bevelOverClearance', xmlElement)
		self.clearanceOverWavelength = evaluate.getEvaluatedFloatDefault(
			self.clearanceOverWavelength, 'clearanceOverWavelength', xmlElement)
		self.collarWidthOverShaftRadius = evaluate.getEvaluatedFloatDefault(
			self.collarWidthOverShaftRadius, 'collarWidthOverShaftRadius', xmlElement)
		self.creationType = evaluate.getEvaluatedStringDefault(self.creationType, 'creationType', xmlElement)
		self.helixAngle = evaluate.getEvaluatedFloatDefault(self.helixAngle, 'helixAngle', xmlElement)
		self.helixType = evaluate.getEvaluatedStringDefault(self.helixType, 'helixType', xmlElement)
		self.lighteningHoleMarginOverRimWidth = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMarginOverRimWidth, 'lighteningHoleMarginOverRimWidth', xmlElement)
		self.lighteningHoleMinimumRadius = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMinimumRadius, 'lighteningHoleMinimumRadius', xmlElement)
		self.moveType = evaluate.getEvaluatedStringDefault(self.moveType, 'moveType', xmlElement)
		self.pitchRadius = evaluate.getEvaluatedFloatDefault(self.pitchRadius, 'pitchRadius', xmlElement)
		self.pressureAngle = evaluate.getEvaluatedFloatDefault(self.pressureAngle, 'pressureAngle', xmlElement)
		self.profileDefinitionSurfaces = evaluate.getEvaluatedIntDefault(
			self.profileDefinitionSurfaces, 'profileDefinitionSurfaces', xmlElement)
		self.rackLengthOverRadius = evaluate.getEvaluatedFloatDefault(self.rackLengthOverRadius, 'rackLengthOverRadius', xmlElement)
		self.rackWidthOverThickness = evaluate.getEvaluatedFloatDefault(
			self.rackWidthOverThickness, 'rackWidthOverThickness', xmlElement)
		self.rimWidthOverRadius = evaluate.getEvaluatedFloatDefault(self.rimWidthOverRadius, 'rimWidthOverRadius', xmlElement)
		self.shaftDepthBottomOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthBottomOverRadius, 'shaftDepthBottomOverRadius', xmlElement)
		self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthTopOverRadius, 'shaftDepthOverRadius', xmlElement)
		self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftDepthTopOverRadius, 'shaftDepthTopOverRadius', xmlElement)
		self.shaftRadiusOverPitchRadius = evaluate.getEvaluatedFloatDefault(
			self.shaftRadiusOverPitchRadius, 'shaftRadiusOverPitchRadius', xmlElement)
		self.shaftSides = evaluate.getEvaluatedIntDefault(self.shaftSides, 'shaftSides', xmlElement)
		self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teeth', xmlElement)
		self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teethPinion', xmlElement)
		self.teethSecond = evaluate.getEvaluatedIntDefault(self.teethSecond, 'teethSecond', xmlElement)
		self.thickness = evaluate.getEvaluatedFloatDefault(self.thickness, 'thickness', xmlElement)
		# Set absolute variables.
		self.wavelength = self.pitchRadius * 2.0 * math.pi / float(self.teethPinion)
		if self.clearance == None:
			self.clearance = self.wavelength * self.clearanceOverWavelength
		self.clearance = evaluate.getEvaluatedFloatDefault(self.clearance, 'clearance', xmlElement)
		if self.bevel == None:
			self.bevel = self.clearance * self.bevelOverClearance
		self.bevel = evaluate.getEvaluatedFloatDefault(self.bevel, 'bevel', xmlElement)
		if self.rackLength == None:
			self.rackLength = self.pitchRadius * self.rackLengthOverRadius
		self.rackLength = evaluate.getEvaluatedFloatDefault(self.rackLength, 'rackLength', xmlElement)
		if self.rackWidth == None:
			self.rackWidth = self.thickness * self.rackWidthOverThickness
		self.rackWidth = evaluate.getEvaluatedFloatDefault(self.rackWidth, 'rackWidth', xmlElement)
		if self.rimWidth == None:
			self.rimWidth = self.pitchRadius * self.rimWidthOverRadius
		self.rimWidth = evaluate.getEvaluatedFloatDefault(self.rimWidth, 'rimWidth', xmlElement)
		if self.shaftRadius == None:
			self.shaftRadius = self.pitchRadius * self.shaftRadiusOverPitchRadius
		self.shaftRadius = evaluate.getEvaluatedFloatDefault(self.shaftRadius, 'shaftRadius', xmlElement)
		if self.collarWidth == None:
			self.collarWidth = self.shaftRadius * self.collarWidthOverShaftRadius
		self.collarWidth = evaluate.getEvaluatedFloatDefault(self.collarWidth, 'collarWidth', xmlElement)
		if self.lighteningHoleMargin == None:
			self.lighteningHoleMargin = self.rimWidth * self.lighteningHoleMarginOverRimWidth
		self.lighteningHoleMargin = evaluate.getEvaluatedFloatDefault(
			self.lighteningHoleMargin, 'lighteningHoleMargin', xmlElement)
		if self.shaftDepthBottom == None:
			self.shaftDepthBottom = self.shaftRadius * self.shaftDepthBottomOverRadius
		self.shaftDepthBottom = evaluate.getEvaluatedFloatDefault(self.shaftDepthBottom, 'shaftDepthBottom', xmlElement)
		if self.shaftDepthTop == None:
			self.shaftDepthTop = self.shaftRadius * self.shaftDepthTopOverRadius
		self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepth', xmlElement)
		self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepthTop', xmlElement)
		# Set derived values.
		self.helixRadian = math.radians(self.helixAngle)
		self.tanHelix = math.tan(self.helixRadian)
		self.helixThickness = self.tanHelix * self.thickness
		self.pressureRadian = math.radians(self.pressureAngle)
		self.cosPressure = math.cos(self.pressureRadian)
		self.sinPressure = math.sin(self.pressureRadian)
		self.tanPressure = math.tan(self.pressureRadian)
		# tooth multiplied by 0.99 is because at greater than 0.99 there is an intersection
		self.xToothMultiplier = 0.99 - 0.01 * self.tanHelix
		self.halfWavelength = 0.5 * self.wavelength
		self.quarterWavelength = 0.25 * self.wavelength
		self.pinionToothProfile = getToothProfileHalfCylinder(self, self.pitchRadius, self.teethPinion)
		self.addendum = self.pinionToothProfile[-1].imag - self.pitchRadius
		self.dedendum = abs(self.pinionToothProfile[-1]) - self.pitchRadius + self.clearance
		self.xmlElement = xmlElement
Пример #28
0
 def __init__(self, xmlElement):
     'Set defaults.'
     self.axisEnd = evaluate.getVector3ByPrefix(None, 'axisEnd', xmlElement)
     self.axisStart = evaluate.getVector3ByPrefix(None, 'axisStart',
                                                  xmlElement)
     self.end = evaluate.getEvaluatedFloatDefault(360.0, 'end', xmlElement)
     self.loop = evaluate.getTransformedPathByKey([], 'loop', xmlElement)
     self.sides = evaluate.getEvaluatedIntDefault(None, 'sides', xmlElement)
     self.start = evaluate.getEvaluatedFloatDefault(0.0, 'start',
                                                    xmlElement)
     self.target = evaluate.getTransformedPathsByKey([], 'target',
                                                     xmlElement)
     if len(self.target) < 1:
         print('Warning, no target in derive in lathe for:')
         print(xmlElement)
         return
     firstPath = self.target[0]
     if len(firstPath) < 3:
         print(
             'Warning, firstPath length is less than three in derive in lathe for:'
         )
         print(xmlElement)
         self.target = []
         return
     if self.axisStart == None:
         if self.axisEnd == None:
             self.axisStart = firstPath[0]
             self.axisEnd = firstPath[-1]
         else:
             self.axisStart = Vector3()
     self.axis = self.axisEnd - self.axisStart
     axisLength = abs(self.axis)
     if axisLength <= 0.0:
         print('Warning, axisLength is zero in derive in lathe for:')
         print(xmlElement)
         self.target = []
         return
     self.axis /= axisLength
     firstVector3 = firstPath[1] - self.axisStart
     firstVector3Length = abs(firstVector3)
     if firstVector3Length <= 0.0:
         print(
             'Warning, firstVector3Length is zero in derive in lathe for:')
         print(xmlElement)
         self.target = []
         return
     firstVector3 /= firstVector3Length
     self.axisProjectiveSpace = euclidean.ProjectiveSpace(
     ).getByBasisZFirst(self.axis, firstVector3)
     if self.sides == None:
         distanceToLine = euclidean.getDistanceToLineByPaths(
             self.axisStart, self.axisEnd, self.target)
         self.sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(
             distanceToLine, xmlElement)
     endRadian = math.radians(self.end)
     startRadian = math.radians(self.start)
     self.isEndCloseToStart = euclidean.getIsRadianClose(
         endRadian, startRadian)
     if len(self.loop) < 1:
         self.loop = euclidean.getComplexPolygonByStartEnd(
             endRadian, 1.0, self.sides, startRadian)
     self.normal = euclidean.getNormalByPath(firstPath)