11 mat = ((1, 2), (3, 4))
12 self.assertEqual(mat, mod.matrixToTuple(np.matrix(mat)))
15 mat = ((1, 2), (3, 4))
16 self.assertEqual(mat, mod.matrixToTuple(np.array(mat)))
20 self.assertEqual(vec, mod.vectorToTuple(np.matrix(vec)))
21 self.assertEqual(vec, mod.vectorToTuple(np.array(vec)))
25 ((0, 0, 0), mod.matrixToTuple(np.identity(4))),
26 ((np.pi, 0, 0), ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))),
27 ((0, np.pi, 0), ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))),
28 ((0, 0, np.pi), ((-1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))),
30 np.testing.assert_allclose(tr, mod.rpy2tr(*rpy), atol=1e-15)
34 (mod.matrixToTuple(np.identity(4)), (0, 0, 0, 0, 0, 0)),
35 (mod.matrixToTuple(-np.identity(4)), (0, 0, 0, -np.pi, 0, -np.pi)),
37 np.testing.assert_allclose(rpy, mod.matrixToRPY(mat))
39 np.testing.assert_allclose(rpy, mod.matrixToRPY(mod.RPYToMatrix(rpy)))
41 def test_rotate(self):
42 for axis, angle, mat
in [
46 ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1)),
51 ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1)),
56 ((-1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)),
59 self.assertEqual(mat, mod.rotate(axis, angle))
61 def test_quat_mat(self):
63 ((0, 0, 0, 1), np.identity(3)),
64 ((0, 0, 1, 0), ((-1, 0, 0), (0, -1, 0), (0, 0, 1))),
65 ((0, -0.5, 0, 0.5), ((0.5, 0, -0.5), (0, 1, 0), (0.5, 0, 0.5))),
67 self.assertEqual(mat, mod.quaternionToMatrix(quat))
70 if __name__ ==
"__main__":
def test_vector_to_tuple(self)
def test_array_to_tuple(self)
def test_matrix_rpy(self)
def test_matrix_to_tuple(self)