def test_default_seq(self): quat = dcs.quat_from_euler(self.a) temp = dcs.quat_mult( dcs.quat_mult(dcs.qrot(3, self.a[0]), dcs.qrot(1, self.a[1])), dcs.qrot(2, self.a[2])) np.testing.assert_array_almost_equal(quat, temp) self.assertEqual(quat.ndim, 1)
def setUp(self): self.quat1 = np.array([0.5, 0.5, 0.5, 0.5]) self.dq1 = dcs.qrot(1, 0.001) self.dq2 = dcs.qrot(2, 0.05) self.dqq1 = dcs.quat_mult(self.dq1, self.quat1) self.dqq2 = dcs.quat_mult(self.dq2, self.quat1) self.theta = np.array([0.001, 0.05]) self.comp = np.array([[0.001, 0], [0, 0.05], [0, 0]]) self.null = np.array([]) self.null_quat = np.zeros((4, 0))
def setUp(self): self.quat1 = np.array([0.5, 0.5, 0.5, 0.5]) self.dq1 = dcs.qrot(1, 0.001) self.dq2 = dcs.qrot(2, 0.05) self.dqq1 = dcs.quat_mult(self.dq1, self.quat1) self.dqq2 = dcs.quat_mult(self.dq2, self.quat1) self.theta = np.array([0.001, 0.05]) self.comp = np.array([[0.001, 0], [0, 0.05], [0, 0]]) self.null = np.array([]) self.null_quat = np.zeros((4, 0))
def test_array_scalar3(self): quat = dcs.quat_mult(self.q6, np.column_stack((self.q6, self.q6))) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal( quat, np.column_stack((dcs.quat_inv(self.q6), dcs.quat_inv(self.q6)))) np.testing.assert_array_equal(quat.shape, (4, 2))
def test_nominal2(self): quat = dcs.quat_mult(self.q2, self.q3) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, self.q5) np.testing.assert_array_equal(quat.shape, self.q5.shape)
def test_nominal1(self): quat = dcs.quat_mult(self.q1, self.q2) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, self.q4) np.testing.assert_array_equal(quat.shape, self.q4.shape)
def test_long(self): quat1 = dcs.quat_from_euler(np.hstack((self.a, self.b)), seq=np.hstack((self.seq, self.seq))) quat2 = dcs.quat_mult(self.quat[:, 0], self.quat[:, 1]) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)
def test_short(self): quat1 = dcs.quat_from_euler(self.a[0:2], self.seq[0:2]) quat2 = dcs.quat_mult(dcs.qrot(self.seq[0], self.a[0]), dcs.qrot(self.seq[1], self.a[1])) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)
def test_nominal1(self): quat = dcs.quat_mult(self.q1, self.q2) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, self.q4) np.testing.assert_array_equal(quat.shape, self.q4.shape)
def test_array(self): quat = dcs.quat_mult(self.q_array_in1, self.q_array_in2) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat, self.q_array_out) np.testing.assert_array_equal(quat.shape, self.q_array_out.shape)
def test_array_scalar2(self): quat = dcs.quat_mult(self.q1, self.q_array_in2) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat[:, 0], self.q4) np.testing.assert_array_equal(quat.shape, self.q_array_out.shape)
def test_array(self): quat = dcs.quat_mult(self.q_array_in1, self.q_array_in2) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat, self.q_array_out) np.testing.assert_array_equal(quat.shape, self.q_array_out.shape)
def test_array_scalar3(self): quat = dcs.quat_mult(self.q6, np.column_stack((self.q6, self.q6))) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat, np.column_stack((dcs.quat_inv(self.q6), dcs.quat_inv(self.q6)))) np.testing.assert_array_equal(quat.shape, (4, 2))
def test_array_scalar2(self): quat = dcs.quat_mult(self.q1, self.q_array_in2) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat[:,0], self.q4) np.testing.assert_array_equal(quat.shape, self.q_array_out.shape)
def test_reverse(self): quat1 = dcs.quat_mult(self.q2, self.q1) quat2 = dcs.quat_inv(dcs.quat_mult(dcs.quat_inv(self.q1), dcs.quat_inv(self.q2))) np.testing.assert_array_almost_equal(quat1, quat2)
def test_nominal3(self): quat = dcs.quat_mult(self.q6, self.q6) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, dcs.quat_inv(self.q6)) np.testing.assert_array_equal(quat.shape, self.q6.shape)
def test_nominal2(self): quat = dcs.quat_mult(self.q2, self.q3) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, self.q5) np.testing.assert_array_equal(quat.shape, self.q5.shape)
def test_nominal3(self): quat = dcs.quat_mult(self.q6, self.q6) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, dcs.quat_inv(self.q6)) np.testing.assert_array_equal(quat.shape, self.q6.shape)
def test_reverse(self): quat1 = dcs.quat_mult(self.q2, self.q1) quat2 = dcs.quat_inv( dcs.quat_mult(dcs.quat_inv(self.q1), dcs.quat_inv(self.q2))) np.testing.assert_array_almost_equal(quat1, quat2)
def test_null_input8(self): quat = dcs.quat_mult(self.null, self.null_quat) np.testing.assert_array_equal(quat, self.null) np.testing.assert_array_equal(quat.shape, self.null.shape)
def test_default_seq(self): quat = dcs.quat_from_euler(self.a) temp = dcs.quat_mult(dcs.quat_mult(dcs.qrot(3, self.a[0]), dcs.qrot(1, self.a[1])), dcs.qrot(2, self.a[2])) np.testing.assert_array_almost_equal(quat, temp) self.assertEqual(quat.ndim, 1)
def test_short(self): quat1 = dcs.quat_from_euler(self.a[0:2], self.seq[0:2]) quat2 = dcs.quat_mult(dcs.qrot(self.seq[0], self.a[0]), dcs.qrot(self.seq[1], self.a[1])) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)
def test_null_input8(self): quat = dcs.quat_mult(self.null, self.null_quat) np.testing.assert_array_equal(quat, self.null) np.testing.assert_array_equal(quat.shape, self.null.shape)
def test_long(self): quat1 = dcs.quat_from_euler(np.hstack((self.a, self.b)), seq=np.hstack((self.seq, self.seq))) quat2 = dcs.quat_mult(self.quat[:,0], self.quat[:,1]) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)