Пример #1
0
def dcquat( dc0, dc1 ):
    """
    Get the quaternions describing rotation from one double couple to
    another.  dc0 is the one we're rotating from.
    """

    q0 = quat( A=dc0.pbt )  # make quaternions based on pbt as a rotation matrix
    q1 = quat( A=dc1.pbt )

    # quaternion for rotation from dc0 to dc1 is the same as inverse of dc0 then dc1
    qdiff = q1*q0.conjugate()   # equivelent to q1 then q0
    
    # return the four different rotations
    return qdiff, qdiff*quat([0,1,0,0]), qdiff*quat([0,0,1,0]), qdiff*quat([0,0,0,1]) 
Пример #2
0
def dcquat(dc0, dc1):
    """
    Get the quaternions describing rotation from one double couple to
    another.  dc0 is the one we're rotating from.
    """

    q0 = quat(A=dc0.pbt)  # make quaternions based on pbt as a rotation matrix
    q1 = quat(A=dc1.pbt)

    # quaternion for rotation from dc0 to dc1 is the same as inverse of dc0 then dc1
    qdiff = q1 * q0.conjugate()  # equivelent to q1 then q0

    # return the four different rotations
    return qdiff, qdiff * quat([0, 1, 0, 0]), qdiff * quat(
        [0, 0, 1, 0]), qdiff * quat([0, 0, 0, 1])
Пример #3
0
    def quats( self ):
        """
        Get the 4 quaternions describing rotation from the reference
        orientation where p = (1,0,0), t=(0,0,1)
        """
        # get direct mapping from rotation matrix
        q0 = quat( A=self.pbt )

        # get other four options by quaternion multiplication
        q1, q2, q3 = q0*quat([0,1,0,0]), q0*quat([0,0,1,0]), q0*quat([0,0,0,1]) 

        # force the scalar part to be positive
        for q in ( q0, q1, q2, q3 ):
            if q.w < 0: q*= -1

        return q0, q1, q2, q3
Пример #4
0
    def quats(self):
        """
        Get the 4 quaternions describing rotation from the reference
        orientation where p = (1,0,0), t=(0,0,1)
        """
        # get direct mapping from rotation matrix
        q0 = quat(A=self.pbt)

        # get other four options by quaternion multiplication
        q1, q2, q3 = q0 * quat([0, 1, 0, 0]), q0 * quat(
            [0, 0, 1, 0]), q0 * quat([0, 0, 0, 1])

        # force the scalar part to be positive
        for q in (q0, q1, q2, q3):
            if q.w < 0: q *= -1

        return q0, q1, q2, q3
Пример #5
0
# get file to test
srcpath = os.path.join( os.getcwd(), '..' )
sys.path.append( srcpath )
from quaternions import quatn as quat

D2R = pi/180.0
R2D = 180/pi

# reference 
A0 = np.array( [[ 1, 0, 0 ],
                [ 0, 1, 0 ],
                [ 0, 0, 1 ]], dtype=float )

print "reference rotation matrix"
print A0
q0 = quat( A=A0 )
print "q = ", q0
print ""

# make x1->-x3, x3->x1
A1 = dc1 = np.array( [[ 0,  0, 1 ],
                      [ 0,  1, 0 ],
                      [ -1, 0, 0 ]] , dtype=float)

print "posn 1"
print A1
q1 = quat( A=A1 )
print "q1 = ", q1
(a, u) = q1.toAngleAxis()
print "angle", a*R2D, "ACW around axis",u
print ""
Пример #6
0
from numpy import pi, cos, sin, arccos as acos

# get file to test
srcpath = os.path.join(os.getcwd(), '..')
sys.path.append(srcpath)
from quaternions import quatn as quat

D2R = pi / 180.0
R2D = 180 / pi

# reference
A0 = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]], dtype=float)

print "reference rotation matrix"
print A0
q0 = quat(A=A0)
print "q = ", q0
print ""

# make x1->-x3, x3->x1
A1 = dc1 = np.array([[0, 0, 1], [0, 1, 0], [-1, 0, 0]], dtype=float)

print "posn 1"
print A1
q1 = quat(A=A1)
print "q1 = ", q1
(a, u) = q1.toAngleAxis()
print "angle", a * R2D, "ACW around axis", u
print ""

# make x1->-x3, x2->-x1, x3->x2