コード例 #1
0
ファイル: polygon.py プロジェクト: elmom/Skeinforge-Mirror
def getRadiusFromXMLElement( sideAngle, xmlElement ):
	"Get radius from attribute dictionary."
	if 'radius' in xmlElement.attributeDictionary:
		return evaluate.getEvaluatedFloatOne( 'radius', xmlElement )
	if 'apothem' in xmlElement.attributeDictionary:
		return getRadiusFromApothem( evaluate.getEvaluatedFloatOne( 'apothem', xmlElement ), sideAngle )
	if 'inradius' in xmlElement.attributeDictionary:
		return getRadiusFromApothem( evaluate.getEvaluatedFloatOne( 'inradius', xmlElement ), sideAngle )
	return 1.0
コード例 #2
0
def getRadiusFromXMLElement(sideAngle, xmlElement):
    "Get radius from attribute dictionary."
    if 'radius' in xmlElement.attributeDictionary:
        return evaluate.getEvaluatedFloatOne('radius', xmlElement)
    if 'apothem' in xmlElement.attributeDictionary:
        return getRadiusFromApothem(
            evaluate.getEvaluatedFloatOne('apothem', xmlElement), sideAngle)
    if 'inradius' in xmlElement.attributeDictionary:
        return getRadiusFromApothem(
            evaluate.getEvaluatedFloatOne('inradius', xmlElement), sideAngle)
    return 1.0
コード例 #3
0
ファイル: circle.py プロジェクト: clothbot/DotSkeinforge
def getGeometryOutput(xmlElement):
	"Get vector3 vertices from attribute dictionary."
	radius = complex(1.0, 1.0)
	radius = lineation.getComplexByPrefixes(['demisize', 'radius'], radius, xmlElement)
	radius = lineation.getComplexByMultiplierPrefixes(2.0, ['diameter', 'size'], radius, xmlElement)
	sides = evaluate.getSidesMinimumThree(max(radius.real, radius.imag), xmlElement)
	sides = evaluate.getEvaluatedFloatDefault(sides, 'sides', xmlElement)
	loop = []
	start = evaluate.getEvaluatedFloatZero('start', xmlElement)
	start = getWrappedFloat(start, 360.0)
	extent = evaluate.getEvaluatedFloatDefault(360.0 - start, 'extent', xmlElement)
	end = evaluate.getEvaluatedFloatDefault(start + extent, 'end', xmlElement)
	end = getWrappedFloat(end, 360.0)
	revolutions = evaluate.getEvaluatedFloatOne('revolutions', xmlElement)
	if revolutions > 1:
		end += 360.0 * (revolutions - 1)
	sidesCeiling = int(math.ceil(abs(sides) * extent / 360.0))
	sideAngle = math.radians(extent) / sidesCeiling
	startAngle = math.radians(start)
	for side in xrange(sidesCeiling + (extent != 360.0)):
		angle = float(side) * sideAngle + startAngle
		point = euclidean.getWiddershinsUnitPolar(angle)
		vertex = Vector3(point.real * radius.real, point.imag * radius.imag)
		loop.append(vertex)
	sideLength = sideAngle * lineation.getAverageRadius(radius)
	return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
コード例 #4
0
ファイル: circle.py プロジェクト: lImbus/giseburt-ReplicatorG
def getGeometryOutput(xmlElement):
	"Get vector3 vertexes from attribute dictionary."
	radius = lineation.getRadiusComplex(complex(1.0, 1.0), xmlElement)
	sides = evaluate.getSidesMinimumThreeBasedOnPrecisionSides(max(radius.real, radius.imag), xmlElement)
	loop = []
	start = evaluate.getEvaluatedFloatZero('start', xmlElement)
	start = getWrappedFloat(start, 360.0)
	extent = evaluate.getEvaluatedFloatDefault(360.0 - start, 'extent', xmlElement)
	end = evaluate.getEvaluatedFloatDefault(start + extent, 'end', xmlElement)
	end = getWrappedFloat(end, 360.0)
	revolutions = evaluate.getEvaluatedFloatOne('revolutions', xmlElement)
	if revolutions > 1:
		end += 360.0 * (revolutions - 1)
	angleTotal = math.radians(start)
	extent = end - start
	sidesCeiling = int(math.ceil(abs(sides) * extent / 360.0))
	sideAngle = math.radians(extent) / sidesCeiling
	spiral = lineation.Spiral(0.5 * sideAngle / math.pi, xmlElement)
	for side in xrange(sidesCeiling + (extent != 360.0)):
		unitPolar = euclidean.getWiddershinsUnitPolar(angleTotal)
		vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * radius.real, unitPolar.imag * radius.imag))
		angleTotal += sideAngle
		loop.append(vertex)
	sideLength = sideAngle * lineation.getAverageRadius(radius)
	lineation.setClosedAttribute(revolutions, xmlElement)
	return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
コード例 #5
0
	def setToObjectAttributeDictionary(self):
		"Set the shape of this carvable object info."
		self.inradius = evaluate.getVector3ByPrefixes( ['demisize', 'inradius', 'radius'], Vector3(1.0, 1.0, 1.0), self.xmlElement )
		self.inradius = evaluate.getVector3ByMultiplierPrefixes( 2.0, ['diameter', 'size'], self.inradius, self.xmlElement )
		self.inradius.z = 0.5 * evaluate.getEvaluatedFloatDefault( self.inradius.z + self.inradius.z, 'height', self.xmlElement )
		self.topOverBottom = evaluate.getEvaluatedFloatOne('topoverbottom', self.xmlElement )
		self.xmlElement.attributeDictionary['height'] = self.inradius.z + self.inradius.z
		self.xmlElement.attributeDictionary['radius.x'] = self.inradius.x
		self.xmlElement.attributeDictionary['radius.y'] = self.inradius.y
		self.xmlElement.attributeDictionary['topoverbottom'] = self.topOverBottom
		self.createShape()
コード例 #6
0
	def setToObjectAttributeDictionary( self ):
		"Set the shape of this carvable object info."
		radius = evaluate.getVector3ByPrefix( 'radius', Vector3( 1.0, 1.0, 1.0 ), self.xmlElement )
		radius = evaluate.getVector3ThroughSizeDiameter( radius, self.xmlElement )
		self.height = evaluate.getEvaluatedFloatDefault( radius.z + radius.z, 'height', self.xmlElement )
		self.radiusX = radius.x
		self.radiusY = radius.y
		self.radiusZ = None
		self.topOverBottom = evaluate.getEvaluatedFloatOne( 'topoverbottom', self.xmlElement )
		self.xmlElement.attributeDictionary[ 'height' ] = self.height
		self.xmlElement.attributeDictionary[ 'radiusx' ] = self.radiusX
		self.xmlElement.attributeDictionary[ 'radiusy' ] = self.radiusY
		self.xmlElement.attributeDictionary[ 'topoverbottom' ] = self.topOverBottom
		self.createShape()
コード例 #7
0
ファイル: cylinder.py プロジェクト: elmom/Skeinforge-Mirror
 def setToObjectAttributeDictionary(self):
     "Set the shape of this carvable object info."
     radius = evaluate.getVector3ByPrefix("radius", Vector3(1.0, 1.0, 1.0), self.xmlElement)
     radius = evaluate.getVector3ThroughSizeDiameter(radius, self.xmlElement)
     self.height = evaluate.getEvaluatedFloatDefault(radius.z + radius.z, "height", self.xmlElement)
     self.radiusX = radius.x
     self.radiusY = radius.y
     self.radiusZ = None
     self.topOverBottom = evaluate.getEvaluatedFloatOne("topoverbottom", self.xmlElement)
     self.xmlElement.attributeDictionary["height"] = self.height
     self.xmlElement.attributeDictionary["radiusx"] = self.radiusX
     self.xmlElement.attributeDictionary["radiusy"] = self.radiusY
     self.xmlElement.attributeDictionary["topoverbottom"] = self.topOverBottom
     self.createShape()