def doit(self,mobAtoms):
        """
mobAtoms: AtomSet that is being frozen.
Assuming the AtomSet are from same molecule
        """

        # fixme: need checking for mat (matrix) and mobAtoms
        geomContainer = mobAtoms[0].top.geomContainer
        mGeom = geomContainer.masterGeom
        mat = mGeom.rotation
        mat = Numeric.reshape(mat, (4,4))

        # update coords
        mobAtoms = mobAtoms.findType(Atom)
        coords = mobAtoms.coords
        hCoords = Numeric.concatenate((coords,Numeric.ones((len(coords),1),\
                                                            'd')), 1)
        tCoords = Numeric.dot(hCoords, mat)[:,:3]
        tCoords = tCoords.tolist()
        mobAtoms.updateCoords(tCoords, 0) # overwritten the original coords
        
        # reset the rotation matrix of masterGeom
        identity = Numeric.identity(4,'f').ravel()
        mGeom.SetRotation(Numeric.identity(4,'f').ravel() ) 

        event = EditAtomsEvent('coords', mobAtoms)
        self.vf.dispatchEvent(event)
        
        mGeom.viewer.Redraw()
        
        return
    def getMatrices(self, mol=None, keyword='MTRIX'):
        if mol is None:
            return

        matrices = []
        next = 0

        lines = mol.data[0].parser.allLines
        arr = Numeric.identity(4).astype('f')
    
        for l in lines:
            
            spl = string.split(l)
            if spl[0][:-1] != keyword: continue
            index = int(spl[0][-1:])-1

            arr[index][0] = float(spl[2])
            arr[index][1] = float(spl[3])
            arr[index][2] = float(spl[4])

            if index == 2:
                matrices.append(arr)
                arr = Numeric.identity(4).astype('f')
                
        return matrices
示例#3
0
def inverse4X4(matrix):
    """ returns the inverse of the given 4x4 transformation matrix
t_1: the negetive of Translation vector
r_1: the inverse of rotation matrix

inversed transformation is
1) t_1 applied first
2) then r_1 is applied

to validate the result, N.dot(matrix, mat_inverse)==N.identity(4,'f')
"""
    # check the shape
    if matrix.shape !=(4,4) and matrix.shape !=(16,) :
        raise ValueError("Argument must Numeric array of shape (4,4) or (16,)")
        return None
    if matrix.shape ==(16,):            
        matrix=N.array(matrix,'f')
        matrix=N.reshape(matrix,(4,4))  # force the matrix to be (4,4)
    t_1=N.identity(4,'f')
    t_1[:2,3]= - matrix[:2, 3]
    r_1=N.identity(4,'f')
    r_1[:3,:3] = N.transpose(matrix[:3,:3])
    mat_inverse=N.dot(r_1, t_1)
    #asert N.dot(matrix, mat_inverse) is N.identity(4,'f')
    return mat_inverse
    def getMatrices(self):
        m=[]
        mat=Numeric.identity(4).astype('f')

        if self.length is None or self.length == 0:
            m.append( Numeric.identity(4).astype('f') )
            return m

        if self.identity == 1:
            m.append( Numeric.identity(4).astype('f') )

        mat[:3, 3] = (self.vector*self.length).astype('f')
        m.append(mat)
        return m
    def test_0031(self ):
        # example we test glMultMatrixf
        import Tkinter
        root = Tkinter.Tk()
        vi = OGLTkWidget(root)
        id = Numeric.array([1.,0.,0.,0.,
                            0.,1.,0.,0.,
                            0.,0.,1.,0.,
                            0.,0.,0.,1.], "d")
        from opengltk.extent import _gllib as gllib
        #GL.glMultMatrixf(id)
        try:
            gllib.cvar.checkArgumentsInCWrapper = 0
            GL.glMultMatrixf(id)
            # calling with bad argument
            gllib.cvar.checkArgumentsInCWrapper = 1
            #import numpy.oldnumeric as Numeric
            id = Numeric.identity(4).astype('d')
            try:
                GL.glMultMatrixf(id)
                raise RuntimeError('failed to catch type error in wrapper')
            except TypeError:
                print 'Type Error caught succefully in wrapper'
        except ImportError:
            pass

        root.after(1000, root.quit )
        root.mainloop()
        root.destroy()
示例#6
0
文件: Util.py 项目: Germanc/supreme
def rotz(angle):
    ret = numerix.identity(4).astype(numerix.Float)
    ret[0,0] = ret[1,1] = numerix.cos(angle)
    sn = numerix.sin(angle)
    ret[0,1] = -sn
    ret[1,0] = sn
    return ret
    def GetMatrix(self, root=None, instance=None, scale=True, transpose=True):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Returns the matrix by which this object is transformed
scale = False: returns the rotation and translation. no scaling info included
               Used to save the transformed geom --> coords --> new pdb file
instance is a list of integer instance indices for all parents
"""
        if root is None:
            root = self.viewer.rootObject

        if instance is None:
            instance = [0]
            p = self.parent
            while p:
                instance.append(0)
                p = p.parent

        GL.glPushMatrix()
        GL.glLoadIdentity()
        #print 'GetMatrix', instance
        self.BuildMat(self, root, scale, instance)
        #GL.glMultMatrixf(self.instanceMatricesFortran[instanceList[0]]])
        m = Numeric.array(GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX)).astype('f')
        GL.glPopMatrix()
        if Numeric.alltrue(m==Numeric.zeros(16).astype('f')):
            # this happens when Pmv has no GUI
            m = Numeric.identity(4)
        if transpose:
            return Numeric.transpose(Numeric.reshape(m, (4,4)))
        else:
            return Numeric.reshape(m, (4,4))
    def doit(self, geom, matrix):
        # gets called from NodeRepr()
        blender = []
        
        # if self.usePROTO is set to 1: don't convert instance matrices
        # geoms into geoms, but use the vrml2 USE 
        if self.usePROTOFlag:
            # create all the necessary data to be put in the PROTO which goes
            # in the header of the vrml2 file
            if geom.VRML2CreatedPROTOForThisGeom == 0:
                name = self.getGeomName(geom)
                blender.append("PROTO "+name+" [ ] {\n")
                identityMatrix = Numeric.identity(4).astype('f')
                blender.extend( self.doitReally(geom, identityMatrix) )
                blender.append("}\n")

                # now insert this into the header of self.output
                for i in range(len(vrml2)):
                    self.output.insert(i+1,blender[i])
                geom.VRML2CreatedPROTOForThisGeom = 1 # don't add this geom
                                                      # to the header next time
                # this PROTO flag will be deleted when we leave the recursive
                
            # and add it as USE to the body
            blender = [] # clear the list because this data has been added
            blender.extend( self.doitUsePROTO(geom, matrix) )
            return blender

        else:
            # here we save all the data for all geoms
            return self.doitReally(geom, matrix)
    def getMatrices(self):
        angle=360.0/self.symmetry
        m=[]
        t=Numeric.array(self.point)*-1

        if self.identity == 1:
            mat = Numeric.identity(4).astype('f')
            m.append(mat)
               
        T = Transformation(trans=t)
        T1 = T.inverse()
        for i in range(self.symmetry-1):
            newList=[]
            newList.extend(list(self.vector))
            newList.append(angle)

            R = Transformation(quaternion=newList)
            
            mt = T1 * R * T
            #newmat = mt.getMatrix()
            newmat = mt.getDejaVuMatrix()
            m.append(newmat)
            angle=angle+360.0/self.symmetry
            
        return m
示例#10
0
 def _checkOrth(self, T, TT, eps=0.0001, output=False):
     """check if the basis is orthogonal on a set of points x: TT == T*transpose(T) == c*Identity
     INPUT:  T: matrix of values of polynomials calculated at common reference points (x)
             TT = T * transpose(T)
             eps: max numeric error
     """
     TTd0 = (-1.*Numeric.identity(Numeric.shape(TT)[0])+1) * TT  # TTd0 = TT with 0s on the main diagonal
     s = Numeric.sum(Numeric.sum(Numeric.absolute(TTd0)))
     minT = MLab.min(MLab.min(T))
     maxT = MLab.max(MLab.max(T))
     minTTd0 = MLab.min(MLab.min(TTd0))
     maxTTd0 = MLab.max(MLab.max(TTd0))
     if not s < eps:
         out = "NOT ORTHOG, min(T), max(T):\t%f\t%f\n" % (minT, maxT)
         out += "  min(TTd0), max(TTd0), sum-abs-el(TTd0):\t%f\t%f\t%f" % (minTTd0, maxTTd0, s)
         if output:
             print out
             return False
         else:
             raise out
     elif output:
         out = "ORTHOGONAL, min(T), max(T):\t%f\t%f\n" % (minT, maxT)
         out += "  min(TTd0), max(TTd0), sum-abs-el(TTd0):\t%f\t%f\t%f" % (minTTd0, maxTTd0, s)
         print out
     return True
 def set(self, coords=None, matrices=None):
     if coords is None: return
     else: self.coords = Numeric.array(coords).astype('f')
     if matrices is None:
         self.matrices = [Numeric.identity(4).astype('f')] 
     else:
         #assert matrices.shape[-2] == 4 and matrices.shape[-1] == 4
         self.matrices = matrices
    def __call__(self, inMatrices, applyIndex=None):
        """outMatrices <- SymMerge(inMatrices, applyIndex=None)
        inMatrices: list of 4x4 matrices
        outMatrices: list of 4x4 matrices
        """

        if not inMatrices: inMatrices = [Numeric.identity(4).astype('f')]
        return inMatrices
示例#13
0
文件: Util.py 项目: Germanc/supreme
def scale(sxyz):
    ret = numerix.identity(4).astype(numerix.Float)
    s = numerix.ones(3, numerix.Float)
    s[0:len(sxyz)] = sxyz
    ret[0,0] = s[0]
    ret[1,1] = s[1]
    ret[2,2] = s[2]
    return ret
    def __init__(self, name='Common2d3dObject', check=1, **kw):
        """Constructor
"""
        #self.newList = GL.glGenLists(1)

        self.name = name
        self.viewer = None
        self.immediateRendering = False
        self.needsRedoDpyListOnResize = False
        self.protected = False      # False == not protected against deletion
        self.replace = True     # this is used to store in a geometry the 
          # desired behavior when adding the geom to the Viewer.
          # in AddObject, if replace is not specified, geom.replace will be
          # used
        self.isExpandedInObjectList = 1 # set to 1 when children of that geom
                                # are visible in ViewerGUI object list
        
        self.parent = None      # parent object
        self.fullName = name    # object's name including parent's name
        self.children = []      # list of children
        self.listed = True         # When true the name of this object appears
                                # in the GUI's object

        self.pickable = True       # when set the object can be picked

        self.pickNum = 0

        self.dpyList = None     # display list for drawing
        self.pickDpyList = None # display list for picking
        
        # FIXME: quick hack. Flag set by SetCurrentXxxx. When set object's
        # transformation and material are saved in log file
        self.hasBeenCurrent = False


        self.depthMask = 1 # 0: zbuffer is readOnly for transparent objects
                           # 1: zbuffer is read write for transparent objects
        self.srcBlendFunc = GL.GL_SRC_ALPHA
        #self.dstBlendFunc = GL.GL_ONE #GL.GL_ONE_MINUS_SRC_COLOR
        # ONE_MINUS_SRC_ALPHA works for colorMapEditor
        self.dstBlendFunc = GL.GL_ONE_MINUS_SRC_ALPHA 

        self.transparent = False #viewerConst.NO
        
        self.visible = True

        m = Numeric.reshape( Numeric.identity(4), (1,16) )
        self.instanceMatricesFortran = m.astype('f')

        self.ownGui = None

        self.animatable = True

        apply( self.Set, (check, 0), kw)

        self._modified = False  # used to decide if we should save state
 def __call__(self, inMatrices, applyIndex=None):
     """outMatrices <- SymSplit(inMatrices, applyIndex=None)
     inMatrices: list of 4x4 matrices
     outMatrices: list of 4x4 matrices
     """
     if not inMatrices:
         outMatrices = [Numeric.identity(4).astype('f')]
     else:
         outMatrices = self.getMatrices()
     return outMatrices
示例#16
0
def interpolate3DTransform(matrixList, indexList, percent):
    """ This function gets input of two list and a percent value.
Return value is a 4x4 matrix corresponding to percent% of the transformation.

matrixList: a list of 4x4 transformation matrix
indexList : a list of sorted index (positive float number)
percent   : a positive float number.
if only one matrix in the matrix list:
percent =   0.0  means no transformation (identity)
            1.0  means 100% of the transformation (returns mat)
            0.58 means 58% of translation and rotatetion 58% of rotation angle
            along the same rotation axis
percent can go above 1.0

If matrixList has more than one matrix:
matrixList=[M1,  M2,  M3]     #Attention: All M uses the same reference frame
indexList =[0.2, 0.5, 1.0]    #Attention: assume the list sorted ascendingly
p = 0.5 means apply M2
p = 0.8 means apply M3
p = 0.9 means apply M2 first, then apply 50% of M'.  M' is the transformation
                    from M2 to M3.   50% = (0.9-0.8) / (1.0-0.8)
                    M2 x M' = M3
                    -->  M2.inverse x M2 x M'= M2.inverse x M3 
                    -->  M'= M2.inverse x M
"""
    listLen = len(matrixList)
    if listLen != len(indexList):
        raise ValueError("matrix list should have same length of index list")
    if listLen == 0:
        raise ValueError("no matrix found in the matrix list")

    offset = -1
    for i in range(listLen):
        if indexList[i] >= percent:
            offset = i
            break

    prevMat = nextMat = N.identity(4,'f')
    if offset == -1:
        prevMat = matrixList[-1]
        p = percent/indexList[-1]
        return _interpolateMat(matrixList[-1], p)
    elif offset == 0:
        nextMat = matrixList[0]
        p = percent/indexList[0]
        return _interpolateMat(N.array(matrixList[0]), p)
    else:
        prevMat = matrixList[offset-1]
        nextMat = matrixList[offset]
        p = (percent-indexList[offset-1])/(
                                    indexList[offset]-indexList[offset-1])
        from numpy.oldnumeric.linear_algebra import inverse
        M = N.dot(inverse(prevMat), nextMat)
        Mat = _interpolateMat(M, p)
        return N.dot(prevMat, Mat)
 def transformIsIdentity(self):
     if __debug__:
      if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
     """return true if this object has the identity matrix as
     transformation"""
     mat = self.GetMatrix()
     diff = Numeric.sum( (mat-Numeric.identity(4)).ravel() )
     if math.fabs(diff) < 0.00001:
         return True
     else:
         return False
示例#18
0
def mat_to_axis_angle( matrix ):
    """
    NOTE: This function is added by Yong 2/01/04: given a 4x4 transformation
matrix of hinge motion, now returns the rotation angle and axis (defined by
vector and a point) Please be noticed that if the motion is not hinge, the
function will complain and return none
"""
    if matrix.shape != (16,) and matrix.shape != (4,4):
        raise ValueError("matrix should be of shape (4,4) or (16,)")
        return None

    if matrix.shape == (16,):
        matrix = N.reshape(matrix, (4,4))

    from math import sin, cos, pi, sqrt, fabs, acos
    degtorad = pi/180.

    transf = matrix
    from mglutil.math.rotax import mat_to_quat
    rotMat =  N.identity(4, 'f')
    rotMat[:3,:3] = transf[:3,:3]
    qB = mat_to_quat(matrix=N.array(rotMat).ravel())
    angle = qB[3]
    sa=sin(angle*degtorad/2.0)
    if(fabs(angle) < 0.0005):
        sa = 1
    if angle > 180.:
        vector=[-qB[0]/sa, -qB[1]/sa, -qB[2]/sa]
    else:
        vector=[qB[0]/sa, qB[1]/sa, qB[2]/sa]
    tranMat = transf[3,:3]

    # check if the transformation is a hinge motion
    a=vector
    b=tranMat
    c =[a[0]-b[0], a[1]-b[1], a[2]-b[2]]
    a2= a[0]*a[0] + a[1]*a[1] + a[2]*a[2]
    b2= b[0]*b[0] + b[1]*b[1] + b[2]*b[2]
    c2= c[0]*c[0] + c[1]*c[1] + c[2]*c[2]
    theta = acos((c2-a2-b2)/(2* sqrt(a2*b2))) / pi * 180
    if fabs(theta -90) > 1e-4:
        raise ValueError("The given transformation is not a hinge motion")
        return None, None, None
    
    ratio = sqrt( 1. / (2. * (1.- cos(degtorad * angle ))))
    p = [tranMat[0]*ratio, tranMat[1]*ratio, tranMat[2]*ratio]

    ang = 90. - angle/2.0
    rot = rotax([0.,0.,0.], vector, ang*degtorad, transpose=1)
    rot = rot[:3,:3]
    point = N.dot(p, rot)
    
    return vector, point, angle
    def ResetTransformation(self, redo=1):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
        """Reset the tranformations (Rotation, translation, pivot, scale)"""
	self.rotation = Numeric.identity(4).astype('f')
	self.rotation.shape = (16, )
	self.translation = Numeric.zeros( (3,), 'f')
	self.pivot = Numeric.zeros( (3,), 'f')
	self.scale = Numeric.ones( (3,), 'f')
        if self.viewer:
            if self.viewer.currentObject != self.viewer.rootObject \
               and redo:
                self.viewer.deleteOpenglList()
    def set(self, inA=None, inB=None):
        
        if inA is None and inB is not None:
            matInA = matInB = inB
        elif inA is not None and inB is None:
            matInA = matInB = inA
        elif inA is not None and inB is not None:
            matInA = inA
            matInB = inB
        elif inA is None and inB is None:
            matInA = matInB = Numeric.identity(4).astype('f') 

        return matInA, matInB
    def __init__(self, viewer=None):
        if __debug__:
         if hasattr(DejaVu, 'functionName'): DejaVu.functionName()
	"""Constructor"""

        self.inheritXform = 1                    # set to 0 not to inherit
	self.redirectXform = None                # object to which transf.
	                                         # should be redirected
	self.propagateRedirection = 1

	self.copyXform = []                      # list of objects to be
                                                 # transf. along with me

                                                 # Object's original transf.
                                                 # in OpenGL form (shape (16,))
        self.Matrix = Numeric.identity(4).astype('f')
        self.Matrix.shape = (16, )
        self.MatrixRot = self.Matrix
        self.MatrixRotInv = self.Matrix
        self.MatrixScale = Numeric.ones((3,), 'f')
        self.MatrixTransl = Numeric.zeros( (3,), 'f')
        self.viewer = viewer
        
	self.ResetTransformation(redo=0)               # init object's transf.

	self.R = Numeric.identity(4).astype('f') # Object's frame rotation
	self.R.shape = (16, )

	self.Ri = Numeric.identity(4) .astype('f') # Inverse of R
	self.Ri.shape = (16, )

	self.Si = Numeric.ones( (3, ) ).astype('f') # Inverse of frame's scale
	self.isScalable = 1

        self.immediateRendering = False
        #self.hasChildWithImmediateRendering = False # set to True if a child is not using dpyList
        self.needsRedoDpyListOnResize = False
示例#22
0
    def _uinv(self, mat):
        """Inverts a transformation matrix used to go from cartesian to cell
        coordinates"""

        dmat = Numeric.identity(3).astype('d')
        imat = Numeric.identity(3).astype('d')

        dmat[0][0]=mat[1][1]*mat[2][2]-mat[2][1]*mat[1][2]
        dmat[1][0]=mat[1][2]*mat[2][0]-mat[1][0]*mat[2][2]
        dmat[2][0]=mat[1][0]*mat[2][1]-mat[1][1]*mat[2][0]
        dmat[0][1]=mat[0][2]*mat[2][1]-mat[0][1]*mat[2][2]
        dmat[1][1]=mat[0][0]*mat[2][2]-mat[0][2]*mat[2][0]
        dmat[2][1]=mat[0][1]*mat[2][0]-mat[0][0]*mat[2][1]
        dmat[0][2]=mat[0][1]*mat[1][2]-mat[0][2]*mat[1][1]
        dmat[1][2]=mat[0][2]*mat[1][0]-mat[0][0]*mat[1][2]
        dmat[2][2]=mat[0][0]*mat[1][1]-mat[0][1]*mat[1][0]
        det = mat[0][0]*mat[1][1]*mat[2][2]+mat[1][0]*mat[2][1]*mat[0][2]+ \
              mat[2][0]*mat[0][1]*mat[1][2]-mat[2][2]*mat[0][1]*mat[1][0]- \
              mat[0][0]*mat[2][1]*mat[1][2]-mat[2][0]*mat[1][1]*mat[0][2]
        for i in (0,1,2):
            for j in (0,1,2):
                imat[j][i]=dmat[j][i]/det

        return Numeric.transpose(imat)
示例#23
0
def _interpolateMat(mat, percent):
    """ called only by interpolate3DTransform()
    """
    if mat.shape != (16,) and mat.shape != (4,4):
        raise ValueError("matrix should be of shape (4,4) or (16,)")
        return None

    if mat.shape == (16,):
        mat = N.reshape(mat, (4,4))

  #  if percent <0.0:
  #      raise ValueError('The parameter percent should be a positive float"')
  #      return

    p = percent
    transf = mat[:,:]
    rotMat =  N.identity(4, 'f')
    rotMat[:3,:3]=transf.astype(N.Float32)[:3,:3]

    from mglutil.math.rotax import mat_to_quat
    quat = mat_to_quat(matrix=N.array(rotMat).ravel())
    angle = quat[3] * p

    newRotMat = rotax([0.,0.,0.], quat[:3], angle*degtorad, transpose = 1)
    newTranMat =  N.identity(4, 'f')
    newTranMat[3][0] = transf[3][0]*p
    newTranMat[3][1] = transf[3][1]*p
    newTranMat[3][2] = transf[3][2]*p

    transform = newRotMat
    transform[3][0] = newTranMat[3][0]
    transform[3][1] = newTranMat[3][1]
    transform[3][2] = newTranMat[3][2]
    # That's it.. the self.transform is now updated.    
    
    return transform
    def doit(self, refAtoms, mobAtoms, updateGeom=True, showRMSD=True):
        """
        The SuperImposeAtomsCommand takes two set of Atoms of the same length
        compute the rotation and translation matrices to superimpose the
        mobAtoms onto the refAtoms using rigidFit module and then transform the
        corresponding geometry.

        updateGeom = True : transform the masterGeom of mobAtoms.
        showRMSD   = True : print and return RMSD 
        """

        if refAtoms is None or mobAtoms is None: return
        assert isinstance(refAtoms, TreeNodeSet)
        assert isinstance(mobAtoms, TreeNodeSet)

        refAtoms = refAtoms.findType(Atom)
        mobAtoms = mobAtoms.findType(Atom)
        # validate the inputs
        if len(refAtoms) !=len(mobAtoms):
            print "The two atomSet are not of equal length"
            return
        if len(refAtoms) < 3 :
            print "At least three atoms are needed for superimposition"
            return
        
        refCoords = refAtoms.coords
        mobCoords = mobAtoms.coords
        
        rigidfitAligner = RigidfitBodyAligner()
        rigidfitAligner.setRefCoords(refCoords)                
        rigidfitAligner.rigidFit(mobCoords)

        if updateGeom:
            rotMat =  Numeric.identity(4).astype('d')
            rotMat[:3,:3] = rigidfitAligner.rotationMatrix               
            transMat = Numeric.array(rigidfitAligner.translationMatrix)
            rotMat[3,:3] = transMat
            #print rotMat  # the matrix
            mGeom = mobAtoms[0].top.geomContainer.masterGeom        
            mGeom.SetRotation(Numeric.reshape(rotMat, (16,)).astype('f'))
            mGeom.viewer.Redraw()

        if showRMSD:
            rmsd=rigidfitAligner.rmsdAfterSuperimposition(mobCoords)
            print "RMSD = ", rmsd
            return rmsd
        else:
            return
    def __call__(self, inMatrices, applyIndex=None):
        """outMatrices <- SymOrient(inMatrices, applyIndex=None)
        inMatrices: list of 4x4 matrices
        outMatrices: list of 4x4 matrices
        """

        if not inMatrices: inMatrices = [Numeric.identity(4).astype('f')]
        matrices = Numeric.array(inMatrices)
        assert len(matrices.shape)==3
        assert matrices.shape[-2] == 4 and matrices.shape[-1] == 4
        ownmat = self.getMatrices()
        out = []
        for m in ownmat: # loop over this node's own transformation matrices
            for im in matrices: #loop over node's incoming matrices
                out.append( Numeric.dot(m, im) )
        return out
    def __call__(self, inMatrices=None, applyIndex=None):
        """outMatrices <- SymTranspose(inMatrices, applyIndex=None)
        inMatrices: list of 4x4 matrices
        outMatrices: list of 4x4 matrices
        """

        if not inMatrices:
            inMatrices = [Numeric.identity(4).astype('f')]

        matrices = Numeric.array(inMatrices)
        assert matrices.shape[-2] == 4 and matrices.shape[-1] == 4

        out = []
        for im in matrices: #loop over node's incoming matrices
            out.append( Numeric.transpose(im) )
        return out
    def __call__(self, inMatrices, scaleFactor, applyIndex=None, selection=[True,True,True]):
        """outMatrices <- SymScale(inMatrices, applyIndex=None, selection=[1,1,1])
        inMatrices: list of 4x4 matrices
        outMatrices: list of 4x4 matrices
        (selection: scale x,y, and/or z) can be 1,True or 0,False)
        """
        
        if not inMatrices:
            inMatrices = [Numeric.identity(4).astype('f')]

        matrices = Numeric.array(inMatrices)
        assert len(matrices.shape)==3
        assert matrices.shape[-2] == 4 and matrices.shape[-1] == 4
        ownmat = self.getMatrices(scaleFactor, selection)
        out = []
        for im in matrices: #loop over node's incoming matrices
                out.append( Numeric.dot(im, ownmat) )
        return out
    def __call__(self, inMatrices, applyIndex=None):
        """outMatrices <- SymNFold(inMatrices, applyIndex=None)
        inMatrices: list of 4x4 matrices
        outMatrices: list of 4x4 matrices
        if applyIndex is given it should be a list of 0-based indices of
        matrices to which this operator's transformation will be applied.
        """

        if not inMatrices: inMatrices = [Numeric.identity(4).astype('f')]
        matrices = Numeric.array(inMatrices)
        assert len(matrices.shape)==3
        assert matrices.shape[-2] == 4 and matrices.shape[-1] == 4
        ownmat = self.getMatrices()
        out = []
        for m in ownmat: # loop over this node's own transformation matrices
            for im in matrices: #loop over node's incoming matrices
                out.append( Numeric.dot(m, im) )
        return out
    def __call__(self, inMatrices=None, applyIndex=None):
        """outMatrices <- SymInverse(inMatrices, applyIndex=None)
        inMatrices: list of 4x4 matrices
        outMatrices: list of 4x4 matrices
        """

        import numpy.oldnumeric.linear_algebra as LinearAlgebra 

        if not inMatrices:
            inMatrices = [Numeric.identity(4).astype('f')]

        matrices = Numeric.array(inMatrices)
        assert matrices.shape[-2] == 4 and matrices.shape[-1] == 4

        out = []
        for im in matrices: #loop over node's incoming matrices
            out.append( LinearAlgebra.inverse(im) )
        return out
    def getMatrices(self):
        m=[]
        newList=[]
        mat = Numeric.identity(4).astype('f')
        if self.identity == 1:
            m.append(mat)

        newList.extend(list(self.vector))
        newList.append(self.angle)
        t=Numeric.array(self.center)*-1
        
        T = Transformation(trans=t)
        R = Transformation(quaternion=newList)

        mt = T.inverse() * R * T
        newmat = mt.getMatrix()

        m.append(newmat)
        return m