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)
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)
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(self.spiral, 'spiral', xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(1.0, 1.0), xmlElement) inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', inradius, xmlElement) demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', inradius.real, xmlElement) demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', inradius.imag, xmlElement) bottomDemiwidth = lineation.getFloatByPrefixBeginEnd('bottomdemiwidth', 'bottomwidth', demiwidth, xmlElement) topDemiwidth = lineation.getFloatByPrefixBeginEnd('topdemiwidth', 'topwidth', demiwidth, xmlElement) interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, 'interiorangle', xmlElement) topRight = complex(topDemiwidth, demiheight) topLeft = complex(-topDemiwidth, demiheight) bottomLeft = complex(-bottomDemiwidth, -demiheight) bottomRight = complex(bottomDemiwidth, -demiheight) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar(math.radians(interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft revolutions = evaluate.getEvaluatedIntOne('revolutions', xmlElement) lineation.setClosedAttribute(revolutions, xmlElement) complexLoop = [topRight, topLeft, bottomLeft, bottomRight] originalLoop = complexLoop[:] for revolution in xrange(1, revolutions): complexLoop += originalLoop spiral = lineation.Spiral(0.25, xmlElement) loop = [] loopCentroid = euclidean.getLoopCentroid(originalLoop) for point in complexLoop: unitPolar = euclidean.getNormalized(point - loopCentroid) loop.append(spiral.getSpiralPoint(unitPolar, Vector3(point.real, point.imag))) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def __init__(self, elementNode): 'Set defaults.' self.inradius = lineation.getComplexByPrefixes(elementNode, ['demisize', 'inradius'], complex(1.0, 1.0)) self.inradius = lineation.getComplexByMultiplierPrefix(elementNode, 2.0, 'size', self.inradius) self.demiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'demiwidth', 'width', self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd(elementNode, 'demiheight', 'height', self.inradius.imag) self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'bottomdemiwidth', 'bottomwidth', self.demiwidth) self.topDemiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, 'topdemiwidth', 'topwidth', self.demiwidth) self.interiorAngle = evaluate.getEvaluatedFloat(90.0, elementNode, 'interiorangle') self.revolutions = evaluate.getEvaluatedInt(1, elementNode, 'revolutions') self.spiral = evaluate.getVector3ByPrefix(None, elementNode, 'spiral')
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)
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)
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.getEvaluatedFloat(90.0, "interiorangle", xmlElement) self.revolutions = evaluate.getEvaluatedInt(1, "revolutions", xmlElement) self.spiral = evaluate.getVector3ByPrefix(None, "spiral", xmlElement)
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)
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.getEvaluatedInt(None, 'seed', xmlElement) self.target = evaluate.getTransformedPathsByKey([], 'target', xmlElement) self.typeMenuRadioStrings = 'hexagonal random rectangular'.split() self.typeString = evaluate.getEvaluatedString('rectangular', 'type', xmlElement) self.zigzag = evaluate.getEvaluatedBoolean(True, 'zigzag', xmlElement)
def __init__(self, elementNode): 'Set defaults.' self.sides = evaluate.getEvaluatedFloat(4.0, elementNode, 'sides') self.sideAngle = 2.0 * math.pi / self.sides cosSide = math.cos(0.5 * self.sideAngle) self.radius = lineation.getComplexByMultiplierPrefixes(elementNode, cosSide, ['apothem', 'inradius'], complex(1.0, 1.0)) self.radius = lineation.getComplexByPrefixes(elementNode, ['demisize', 'radius'], self.radius) self.radius = lineation.getComplexByMultiplierPrefixes(elementNode, 2.0, ['diameter', 'size'], self.radius) self.sidesCeiling = int(math.ceil(abs(self.sides))) self.start = evaluate.getEvaluatedInt(0, elementNode, 'start') end = evaluate.getEvaluatedInt(self.sidesCeiling, elementNode, 'end') self.revolutions = evaluate.getEvaluatedInt(1, elementNode, 'revolutions') self.extent = evaluate.getEvaluatedInt(end - self.start, elementNode, 'extent') self.extent += self.sidesCeiling * (self.revolutions - 1) self.spiral = evaluate.getVector3ByPrefix(None, elementNode, 'spiral')
def __init__(self, elementNode): "Set defaults." self.inradius = lineation.getComplexByPrefixes(elementNode, ["demisize", "inradius"], complex(10.0, 10.0)) self.inradius = lineation.getComplexByMultiplierPrefix(elementNode, 2.0, "size", self.inradius) self.demiwidth = lineation.getFloatByPrefixBeginEnd(elementNode, "demiwidth", "width", self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd(elementNode, "demiheight", "height", self.inradius.imag) self.packingDensity = evaluate.getEvaluatedFloatByKeys(0.2, elementNode, ["packingDensity", "density"]) self.radius = lineation.getComplexByPrefixBeginEnd( elementNode, "elementRadius", "elementDiameter", complex(1.0, 1.0) ) self.radius = lineation.getComplexByPrefixBeginEnd(elementNode, "radius", "diameter", self.radius) self.seed = evaluate.getEvaluatedInt(None, elementNode, "seed") self.target = evaluate.getTransformedPathsByKey([], elementNode, "target") self.typeMenuRadioStrings = "hexagonal random rectangular".split() self.typeString = evaluate.getEvaluatedString("rectangular", elementNode, "type") self.zigzag = evaluate.getEvaluatedBoolean(True, elementNode, "zigzag")
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)
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)
def getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." sides = evaluate.getEvaluatedFloatDefault(4.0, 'sides', xmlElement) sideAngle = 2.0 * math.pi / sides radius = complex(1.0, 1.0) radius = lineation.getComplexByMultiplierPrefixes(math.cos(0.5 * sideAngle), ['apothem', 'inradius'], radius, xmlElement) radius = lineation.getComplexByPrefixes(['demisize', 'radius'], radius, xmlElement) radius = lineation.getComplexByMultiplierPrefixes(2.0, ['diameter', 'size'], radius, xmlElement) loop = [] sidesCeiling = int(math.ceil(abs(sides))) startEnd = lineation.StartEnd(sidesCeiling, '', xmlElement) for side in xrange(startEnd.start, startEnd.end): angle = float(side) * sideAngle 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)
def __init__(self, elementNode): 'Set defaults.' self.inradius = lineation.getComplexByPrefixes( elementNode, ['demisize', 'inradius'], complex(1.0, 1.0)) self.inradius = lineation.getComplexByMultiplierPrefix( elementNode, 2.0, 'size', self.inradius) self.demiwidth = lineation.getFloatByPrefixBeginEnd( elementNode, 'demiwidth', 'width', self.inradius.real) self.demiheight = lineation.getFloatByPrefixBeginEnd( elementNode, 'demiheight', 'height', self.inradius.imag) self.bottomDemiwidth = lineation.getFloatByPrefixBeginEnd( elementNode, 'bottomdemiwidth', 'bottomwidth', self.demiwidth) self.topDemiwidth = lineation.getFloatByPrefixBeginEnd( elementNode, 'topdemiwidth', 'topwidth', self.demiwidth) self.interiorAngle = evaluate.getEvaluatedFloat( 90.0, elementNode, 'interiorangle') self.revolutions = evaluate.getEvaluatedInt(1, elementNode, 'revolutions') self.spiral = evaluate.getVector3ByPrefix(None, elementNode, 'spiral')
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." sides = evaluate.getEvaluatedFloatDefault(4.0, 'sides', xmlElement) sideAngle = 2.0 * math.pi / sides radius = complex(1.0, 1.0) radius = lineation.getComplexByMultiplierPrefixes(math.cos(0.5 * sideAngle), ['apothem', 'inradius'], radius, xmlElement) radius = lineation.getComplexByPrefixes(['demisize', 'radius'], radius, xmlElement) radius = lineation.getComplexByMultiplierPrefixes(2.0, ['diameter', 'size'], radius, xmlElement) loop = [] sidesCeiling = int(math.ceil(abs(sides))) startEnd = lineation.StartEnd(sidesCeiling, '', xmlElement) spiral = lineation.Spiral(0.5 * sideAngle / math.pi, xmlElement) for side in xrange(startEnd.start, startEnd.end): angle = float(side) * sideAngle unitPolar = euclidean.getWiddershinsUnitPolar(angle) vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * radius.real, unitPolar.imag * radius.imag)) loop.append(vertex) sideLength = sideAngle * lineation.getAverageRadius(radius) lineation.setClosedAttribute(startEnd.revolutions, xmlElement) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(1.0, 1.0), xmlElement) inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', inradius, xmlElement) demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', inradius.real, xmlElement) demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', inradius.imag, xmlElement) bottomDemiwidth = lineation.getFloatByPrefixBeginEnd( 'bottomdemiwidth', 'bottomwidth', demiwidth, xmlElement) topDemiwidth = lineation.getFloatByPrefixBeginEnd('topdemiwidth', 'topwidth', demiwidth, xmlElement) interiorAngle = evaluate.getEvaluatedFloatDefault(90.0, 'interiorangle', xmlElement) topRight = complex(topDemiwidth, demiheight) topLeft = complex(-topDemiwidth, demiheight) bottomLeft = complex(-bottomDemiwidth, -demiheight) bottomRight = complex(bottomDemiwidth, -demiheight) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar( math.radians(interiorAngle - 90.0)) topRight = (topRight - bottomRight) * interiorPlaneAngle + bottomRight topLeft = (topLeft - bottomLeft) * interiorPlaneAngle + bottomLeft revolutions = evaluate.getEvaluatedIntOne('revolutions', xmlElement) lineation.setClosedAttribute(revolutions, xmlElement) complexLoop = [topRight, topLeft, bottomLeft, bottomRight] originalLoop = complexLoop[:] for revolution in xrange(1, revolutions): complexLoop += originalLoop spiral = lineation.Spiral(0.25, xmlElement) loop = [] loopCentroid = euclidean.getLoopCentroid(originalLoop) for point in complexLoop: unitPolar = euclidean.getNormalized(point - loopCentroid) loop.append( spiral.getSpiralPoint(unitPolar, Vector3(point.real, point.imag))) return lineation.getGeometryOutputByLoop( lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." sides = evaluate.getEvaluatedFloatDefault(4.0, "sides", xmlElement) sideAngle = 2.0 * math.pi / sides radius = complex(1.0, 1.0) radius = lineation.getComplexByMultiplierPrefixes( math.cos(0.5 * sideAngle), ["apothem", "inradius"], radius, xmlElement ) radius = lineation.getComplexByPrefixes(["demisize", "radius"], radius, xmlElement) radius = lineation.getComplexByMultiplierPrefixes(2.0, ["diameter", "size"], radius, xmlElement) loop = [] sidesCeiling = int(math.ceil(abs(sides))) startEnd = lineation.StartEnd(sidesCeiling, "", xmlElement) spiral = lineation.Spiral(0.5 * sideAngle / math.pi, xmlElement) for side in xrange(startEnd.start, startEnd.end): angle = float(side) * sideAngle unitPolar = euclidean.getWiddershinsUnitPolar(angle) vertex = spiral.getSpiralPoint(unitPolar, Vector3(unitPolar.real * radius.real, unitPolar.imag * radius.imag)) loop.append(vertex) sideLength = sideAngle * lineation.getAverageRadius(radius) lineation.setClosedAttribute(startEnd.revolutions, xmlElement) return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, sideAngle, sideLength), xmlElement)
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.getEvaluatedInt(None, 'seed', xmlElement) self.target = evaluate.getTransformedPathsByKey([], 'target', xmlElement) self.typeMenuRadioStrings = 'hexagonal random rectangular'.split() self.typeString = evaluate.getEvaluatedString('rectangular', 'type', xmlElement) self.zigzag = evaluate.getEvaluatedBoolean(True, 'zigzag', xmlElement)
def getGeometryOutput(xmlElement): "Get vector3 vertices from attribute dictionary." inradius = complex( 1.0, 1.0 ) inradius = lineation.getComplexByPrefixes( ['demisize', 'inradius'], inradius, xmlElement ) inradius = lineation.getComplexByMultiplierPrefix( 2.0, 'size', inradius, xmlElement ) demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', inradius.real, xmlElement ) demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', inradius.imag, xmlElement ) bottomDemiwidth = lineation.getFloatByPrefixBeginEnd('bottomdemiwidth', 'bottomwidth', demiwidth, xmlElement ) topDemiwidth = lineation.getFloatByPrefixBeginEnd('topdemiwidth', 'topwidth', demiwidth, xmlElement ) interiorAngle = evaluate.getEvaluatedFloatDefault( 90.0, 'interiorangle', xmlElement ) topRight = complex( topDemiwidth, demiheight ) topLeft = complex( - topDemiwidth, demiheight ) bottomLeft = complex( - bottomDemiwidth, - demiheight ) bottomRight = complex( bottomDemiwidth, - demiheight ) if interiorAngle != 90.0: interiorPlaneAngle = euclidean.getWiddershinsUnitPolar( math.radians( interiorAngle - 90.0 ) ) topRight = ( topRight - bottomRight ) * interiorPlaneAngle + bottomRight topLeft = ( topLeft - bottomLeft ) * interiorPlaneAngle + bottomLeft loop = [ Vector3( topRight.real, topRight.imag ), Vector3( topLeft.real, topLeft.imag ), Vector3( bottomLeft.real, bottomLeft.imag ), Vector3( bottomRight.real, bottomRight.imag ) ] return lineation.getGeometryOutputByLoop( lineation.SideLoop( loop, 0.5 * math.pi ), xmlElement )
def getGeometryOutput(xmlElement): "Get vector3 vertexes from attribute dictionary." inradius = lineation.getComplexByPrefixes(['demisize', 'inradius'], complex(5.0, 5.0), xmlElement) inradius = lineation.getComplexByMultiplierPrefix(2.0, 'size', inradius, xmlElement) demiwidth = lineation.getFloatByPrefixBeginEnd('demiwidth', 'width', inradius.real, xmlElement) demiheight = lineation.getFloatByPrefixBeginEnd('demiheight', 'height', inradius.imag, xmlElement) radius = lineation.getComplexByPrefixBeginEnd('elementRadius', 'elementDiameter', complex(1.0, 1.0), xmlElement) radius = lineation.getComplexByPrefixBeginEnd('radius', 'diameter', radius, xmlElement) diameter = radius + radius typeString = evaluate.getEvaluatedStringDefault('rectangular', 'type', xmlElement) typeStringTwoCharacters = typeString.lower()[: 2] typeStringFirstCharacter = typeStringTwoCharacters[: 1] zigzag = evaluate.getEvaluatedBooleanDefault(True, 'zigzag', xmlElement) topRight = complex(demiwidth, demiheight) bottomLeft = -topRight loopsComplex = [euclidean.getSquareLoopWiddershins(bottomLeft, topRight)] paths = evaluate.getTransformedPathsByKey('target', xmlElement) if len(paths) > 0: loopsComplex = euclidean.getComplexPaths(paths) maximumComplex = euclidean.getMaximumByPathsComplex(loopsComplex) minimumComplex = euclidean.getMinimumByPathsComplex(loopsComplex) gridPath = None if typeStringTwoCharacters == 'he': gridPath = getHexagonalGrid(diameter, loopsComplex, maximumComplex, minimumComplex, zigzag) elif typeStringTwoCharacters == 'ra' or typeStringFirstCharacter == 'a': gridPath = getRandomGrid(diameter, loopsComplex, maximumComplex, minimumComplex, xmlElement) elif typeStringTwoCharacters == 're' or typeStringFirstCharacter == 'e': gridPath = getRectangularGrid(diameter, loopsComplex, maximumComplex, minimumComplex, zigzag) if gridPath == None: print('Warning, the step type was not one of (hexagonal, random or rectangular) in getGeometryOutput in grid for:') print(typeString) print(xmlElement) return [] loop = euclidean.getVector3Path(gridPath) xmlElement.attributeDictionary['closed'] = 'false' return lineation.getGeometryOutputByLoop(lineation.SideLoop(loop, 0.5 * math.pi), xmlElement)
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)