Example #1
0
 def testMultipleRotates(self):
     r1 = matmath.xRotationMatrix(np.radians(90))
     r2 = matmath.zRotationMatrix(np.radians(90))
     mat = r1.dot(r2)
     pt = np.array([0, 0, 1, 1])
     npt = pt.dot(mat)
     np.testing.assert_almost_equal(npt, [1, 0, 0, 1])
Example #2
0
 def testRotX(self):
     mat = matmath.xRotationMatrix(math.radians(90))
     pt = np.array([1, 0, 0, 1])
     npt = pt.dot(mat)
     np.testing.assert_almost_equal(npt, [1, 0, 0, 1])
     pt = np.array([0, 1, 0, 1])
     npt = pt.dot(mat)
     np.testing.assert_almost_equal(npt, [0, 0, 1, 1])
     pt = np.array([0, 0, 1, 1])
     npt = pt.dot(mat)
     np.testing.assert_almost_equal(npt, [0, -1, 0, 1])
Example #3
0
    def testQuaternionMatrix(self):
        q = matmath.axisAngleToQuaternion([1, 0, 0], np.radians(90))
        qmat = matmath.quaternionToRotationMatrix(q)
        rmat = matmath.xRotationMatrix(math.radians(90))
        np.testing.assert_almost_equal(qmat, rmat)

        q = matmath.axisAngleToQuaternion([0, 1, 0], np.radians(90))
        qmat = matmath.quaternionToRotationMatrix(q)
        rmat = matmath.yRotationMatrix(math.radians(90))
        np.testing.assert_almost_equal(qmat, rmat)

        q = matmath.axisAngleToQuaternion([0, 0, 1], np.radians(90))
        qmat = matmath.quaternionToRotationMatrix(q)
        rmat = matmath.zRotationMatrix(math.radians(90))
        np.testing.assert_almost_equal(qmat, rmat)