def getMatrixTetragridM(matrixTetragrid, prefix, xmlElement): "Get the matrix Tetragrid from the xmlElement m values." matrixKeys = getMatrixKeys(prefix) evaluatedDictionary = evaluate.getEvaluatedDictionary( matrixKeys, xmlElement) if len(evaluatedDictionary.keys()) < 1: return matrixTetragrid for row in xrange(4): for column in xrange(4): key = getMatrixKey(row, column, prefix) if key in evaluatedDictionary: value = evaluatedDictionary[key] if value == None or value == 'None': print( 'Warning, value in getMatrixTetragridM in matrix is None for key for dictionary:' ) print(key) print(evaluatedDictionary) else: matrixTetragrid = getIdentityMatrixTetragrid( matrixTetragrid) matrixTetragrid[row][column] = float(value) euclidean.removeListFromDictionary(xmlElement.attributeDictionary, matrixKeys) return matrixTetragrid
def getFromXMLElement( self, xmlElement ): "Get the values from row column attribute strings, counting from one." attributeDictionary = xmlElement.attributeDictionary if attributeDictionary == None: return self self.multiplyByKeyFunction( xmlElement, 'scalex', getMatrixScaleX ) self.multiplyByKeyFunction( xmlElement, 'scaley', getMatrixScaleY ) self.multiplyByKeyFunction( xmlElement, 'scalez', getMatrixScaleZ ) self.multiplyByKeysFunction( xmlElement, [ 'axisclockwisez', 'observerclockwisez', 'rotationz' ], getMatrixRotationZ ) self.multiplyByKeysFunction( xmlElement, [ 'axiscounterclockwisez', 'observercounterclockwisez' ], getMatrixRotationZCounter ) self.multiplyByKeysFunction( xmlElement, [ 'axisclockwisex', 'observerclockwisex', 'rotationx' ], getMatrixRotationX ) self.multiplyByKeysFunction( xmlElement, [ 'axiscounterclockwisex', 'observercounterclockwisex' ], getMatrixRotationXCounter ) self.multiplyByKeysFunction( xmlElement, [ 'axiscounterclockwisey', 'observerclockwisey', 'rotationy' ], getMatrixRotationY ) self.multiplyByKeysFunction( xmlElement, [ 'axisclockwisey', 'observercounterclockwisey' ], getMatrixRotationYCounter ) self.multiplyByKeyFunction( xmlElement, 'x', getMatrixTranslationX ) self.multiplyByKeyFunction( xmlElement, 'y', getMatrixTranslationY ) self.multiplyByKeyFunction( xmlElement, 'z', getMatrixTranslationZ ) # http://en.wikipedia.org/wiki/Rotation_matrix zxy matrixKeys = getMatrixKeys() evaluatedDictionary = evaluate.getEvaluatedDictionary( matrixKeys, xmlElement ) if len( evaluatedDictionary.keys() ) > 0: multiplicationMatrix4X4 = Matrix4X4().getFromMatrixValues( evaluatedDictionary ) self.matrixTetragrid = self.getOtherTimesSelf( multiplicationMatrix4X4 ).matrixTetragrid euclidean.removeListFromDictionary( xmlElement.attributeDictionary, matrixKeys ) return self
def addXML(self, depth, output): "Add xml for this object." attributeCopy = {} if self.xmlElement != None: attributeCopy = evaluate.getEvaluatedDictionary( [], self.xmlElement ) euclidean.removeListFromDictionary( attributeCopy, matrix.getMatrixKeys() ) euclidean.removeTrueFromDictionary( attributeCopy, 'visible') innerOutput = cStringIO.StringIO() self.addXMLInnerSection( depth + 1, innerOutput ) self.addXMLArchivableObjects( depth + 1, innerOutput ) xml_simple_writer.addBeginEndInnerXMLTag( attributeCopy, self.getXMLClassName(), depth, innerOutput.getvalue(), output )
def getMatrixTetragridMatrix(matrixTetragrid, prefix, xmlElement): "Get the matrix Tetragrid from the xmlElement matrix value." matrixKey = prefix + 'matrix' evaluatedDictionary = evaluate.getEvaluatedDictionary([matrixKey], xmlElement) if len(evaluatedDictionary.keys()) < 1: return matrixTetragrid value = evaluatedDictionary[matrixKey] if value == None or value == 'None': print('Warning, value in getMatrixTetragridMatrix in matrix is None for matrixKey for dictionary:') print(matrixKey) print(evaluatedDictionary) else: matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid) for rowIndex, row in enumerate(value): for elementIndex, element in enumerate(row): matrixTetragrid[rowIndex][elementIndex] = element euclidean.removeListFromDictionary(xmlElement.attributeDictionary, [matrixKey]) return matrixTetragrid
def getTetragridMatrix(prefix, tetragrid, xmlElement): 'Get the tetragrid from the xmlElement matrix value.' matrixKey = prefix + 'matrix' evaluatedDictionary = evaluate.getEvaluatedDictionary([matrixKey], xmlElement) if len(evaluatedDictionary.keys()) < 1: return tetragrid value = evaluatedDictionary[matrixKey] if value == None or value == 'None': print('Warning, value in getTetragridMatrix in matrix is None for matrixKey for dictionary:') print(matrixKey) print(evaluatedDictionary) else: tetragrid = getIdentityTetragrid(tetragrid) for rowIndex, row in enumerate(value): for elementIndex, element in enumerate(row): tetragrid[rowIndex][elementIndex] = element euclidean.removeElementsFromDictionary(xmlElement.attributeDictionary, [matrixKey]) return tetragrid
def getMatrixTetragridR(matrixTetragrid, prefix, xmlElement): "Get the matrix Tetragrid from the xmlElement r values." rowKeys = 'Pr1 Pr2 Pr3 Pr4'.replace('P', prefix).split() evaluatedDictionary = evaluate.getEvaluatedDictionary(rowKeys, xmlElement) if len(evaluatedDictionary.keys()) < 1: return matrixTetragrid for rowKeyIndex, rowKey in enumerate(rowKeys): if rowKey in evaluatedDictionary: value = evaluatedDictionary[rowKey] if value == None or value == 'None': print('Warning, value in getMatrixTetragridR in matrix is None for rowKey for dictionary:') print(rowKey) print(evaluatedDictionary) else: matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid) for elementIndex, element in enumerate(value): matrixTetragrid[rowKeyIndex][elementIndex] = element euclidean.removeListFromDictionary(xmlElement.attributeDictionary, rowKeys) return matrixTetragrid
def getMatrixTetragridC(matrixTetragrid, prefix, xmlElement): "Get the matrix Tetragrid from the xmlElement c values." columnKeys = 'Pc1 Pc2 Pc3 Pc4'.replace('P', prefix).split() evaluatedDictionary = evaluate.getEvaluatedDictionary(columnKeys, xmlElement) if len(evaluatedDictionary.keys()) < 1: return matrixTetragrid for columnKeyIndex, columnKey in enumerate(columnKeys): if columnKey in evaluatedDictionary: value = evaluatedDictionary[columnKey] if value == None or value == 'None': print('Warning, value in getMatrixTetragridC in matrix is None for columnKey for dictionary:') print(columnKey) print(evaluatedDictionary) else: matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid) for elementIndex, element in enumerate(value): matrixTetragrid[elementIndex][columnKeyIndex] = element euclidean.removeListFromDictionary(xmlElement.attributeDictionary, columnKeys) return matrixTetragrid
def getTetragridR(prefix, tetragrid, xmlElement): 'Get the tetragrid from the xmlElement letter r values.' rowKeys = 'Pr1 Pr2 Pr3 Pr4'.replace('P', prefix).split() evaluatedDictionary = evaluate.getEvaluatedDictionary(rowKeys, xmlElement) if len(evaluatedDictionary.keys()) < 1: return tetragrid for rowKeyIndex, rowKey in enumerate(rowKeys): if rowKey in evaluatedDictionary: value = evaluatedDictionary[rowKey] if value == None or value == 'None': print('Warning, value in getTetragridR in matrix is None for rowKey for dictionary:') print(rowKey) print(evaluatedDictionary) else: tetragrid = getIdentityTetragrid(tetragrid) for elementIndex, element in enumerate(value): tetragrid[rowKeyIndex][elementIndex] = element euclidean.removeElementsFromDictionary(xmlElement.attributeDictionary, rowKeys) return tetragrid
def getTetragridC(prefix, tetragrid, xmlElement): 'Get the matrix Tetragrid from the xmlElement letter c values.' columnKeys = 'Pc1 Pc2 Pc3 Pc4'.replace('P', prefix).split() evaluatedDictionary = evaluate.getEvaluatedDictionary(columnKeys, xmlElement) if len(evaluatedDictionary.keys()) < 1: return tetragrid for columnKeyIndex, columnKey in enumerate(columnKeys): if columnKey in evaluatedDictionary: value = evaluatedDictionary[columnKey] if value == None or value == 'None': print('Warning, value in getTetragridC in matrix is None for columnKey for dictionary:') print(columnKey) print(evaluatedDictionary) else: tetragrid = getIdentityTetragrid(tetragrid) for elementIndex, element in enumerate(value): tetragrid[elementIndex][columnKeyIndex] = element euclidean.removeElementsFromDictionary(xmlElement.attributeDictionary, columnKeys) return tetragrid
def getMatrixTetragridM(matrixTetragrid, prefix, xmlElement): "Get the matrix Tetragrid from the xmlElement m values." matrixKeys = getMatrixKeys(prefix) evaluatedDictionary = evaluate.getEvaluatedDictionary(matrixKeys, xmlElement) if len(evaluatedDictionary.keys()) < 1: return matrixTetragrid for row in xrange(4): for column in xrange(4): key = getMatrixKey(row, column, prefix) if key in evaluatedDictionary: value = evaluatedDictionary[key] if value == None or value == 'None': print('Warning, value in getMatrixTetragridM in matrix is None for key for dictionary:') print(key) print(evaluatedDictionary) else: matrixTetragrid = getIdentityMatrixTetragrid(matrixTetragrid) matrixTetragrid[row][column] = float(value) euclidean.removeListFromDictionary(xmlElement.attributeDictionary, matrixKeys) return matrixTetragrid
def getTetragridM(prefix, tetragrid, xmlElement): 'Get the tetragrid from the xmlElement letter m values.' keysM = getKeysM(prefix) evaluatedDictionary = evaluate.getEvaluatedDictionary(keysM, xmlElement) if len(evaluatedDictionary.keys()) < 1: return tetragrid for row in xrange(4): for column in xrange(4): key = getKeyM(row, column, prefix) if key in evaluatedDictionary: value = evaluatedDictionary[key] if value == None or value == 'None': print('Warning, value in getTetragridM in matrix is None for key for dictionary:') print(key) print(evaluatedDictionary) else: tetragrid = getIdentityTetragrid(tetragrid) tetragrid[row][column] = float(value) euclidean.removeElementsFromDictionary(xmlElement.attributeDictionary, keysM) return tetragrid