예제 #1
0
    def __init__(self, latVec, recipVec):
        
        self.latVec   = mU.normalized(latVec)
        self.recipVec = mU.normalized(recipVec)

        self.qBase  = q1  = Quat(RotInv('align', 
                                                self.latVec,
                                                self.recipVec)
                                     )
        e1 = q1.q
        rFiber = RotInv(0.5, self.recipVec) # 0.5 is a very arbitary distance along the fiber
        q2 = Quat(rFiber)
        q12 = (q2*q1).q
        e2 = mU.normalized(q12 - num.dot(q12,e1) * e1)
        #
        self.e1 = e1
        self.e2 = e2
        
        return
예제 #2
0
def rotMatrixFromCrystalVectors(cvs1=None, cvs2=None, cvs3=None):
    """\
    Make a rotation matrix in the RotationParameterization convention
    from components of crystal vectors that are along given sample directions
    """
    mat = zeros([3,3], dtype='float64')
    if cvs1 == None:
        if ((cvs2 == None) or (cvs3 == None)):
            print >> sys.stderr, "need more inputs"
            raise RuntimeError, "unrecoverable error"
        cvs1 = cross(cvs2,cvs3)
        cvs1 = normalized(cvs1)
    if cvs2 == None:
        if ((cvs1 == None) or (cvs3 == None)):
            print >> sys.stderr, "need more inputs"
            raise RuntimeError, "unrecoverable error"
        cvs2 = cross(cvs1,cvs3)
        cvs2 = normalized(cvs2)
    if cvs3 == None:
        if ((cvs1 == None) or (cvs2 == None)):
            print >> sys.stderr, "need more inputs"
            raise RuntimeError, "unrecoverable error"
        cvs3 = cross(cvs1,cvs2)
        cvs3 = normalized(cvs3)
    mat[0,:] = cvs1[:]
    mat[1,:] = cvs2[:]
    mat[2,:] = cvs3[:]
    det = determinant3(mat)
    if (abs(det-1.0) < 1e-12):
        return mat
    elif (abs(det+1.0) < 1e-12):
        mat = -mat
        return mat
    else:
        print >> sys.stderr, "vectors not close enough to orthonormal"
        raise RuntimeError, "unrecoverable error"