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.q1_inp = dcs.qrot(1, np.pi/2) self.q1_out = np.array([-np.sqrt(2)/2, 0, 0, np.sqrt(2)/2]) self.q2_inp = dcs.qrot(2, np.pi/3) self.q2_out = np.array([0, -0.5, 0, np.sqrt(3)/2]) self.q3_inp = np.column_stack((self.q1_inp, self.q2_inp)) self.q3_out = np.column_stack((self.q1_out, self.q2_out)) self.null = np.array([]) self.null_quat = np.ones((dcs.QUAT_SIZE, 0))
def setUp(self): self.q1_inp = dcs.qrot(1, np.pi / 2) self.q1_out = np.array([-np.sqrt(2) / 2, 0, 0, np.sqrt(2) / 2]) self.q2_inp = dcs.qrot(2, np.pi / 3) self.q2_out = np.array([0, -0.5, 0, np.sqrt(3) / 2]) self.q3_inp = np.column_stack((self.q1_inp, self.q2_inp)) self.q3_out = np.column_stack((self.q1_out, self.q2_out)) self.null = np.array([]) self.null_quat = np.ones((dcs.QUAT_SIZE, 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 setUp(self): self.q1 = dcs.qrot(1, np.pi/2) self.q2 = dcs.qrot(2, -np.pi) self.q3 = dcs.qrot(3, np.pi/3) self.q4 = np.array([ 0, -np.sqrt(2)/2, np.sqrt(2)/2, 0]) # q1*q2 self.q5 = np.array([0.5, -np.sqrt(3)/2, 0, 0]) # q2*q3 self.q6 = np.array([0.5, 0.5, 0.5, 0.5]) # q6 * q6 = q6**-1, and triggers negative scalar component self.q_array_in1 = np.column_stack((self.q1, self.q2)) self.q_array_in2 = np.column_stack((self.q2, self.q3)) self.q_array_out = np.column_stack((self.q4, self.q5)) self.null = np.array([]) self.null_quat = np.ones((dcs.QUAT_SIZE, 0))
def setUp(self): self.q1 = dcs.qrot(1, np.pi / 2) self.q2 = dcs.qrot(2, -np.pi) self.q3 = dcs.qrot(3, np.pi / 3) self.q4 = np.array([0, -np.sqrt(2) / 2, np.sqrt(2) / 2, 0]) # q1*q2 self.q5 = np.array([0.5, -np.sqrt(3) / 2, 0, 0]) # q2*q3 self.q6 = np.array( [0.5, 0.5, 0.5, 0.5]) # q6 * q6 = q6**-1, and triggers negative scalar component self.q_array_in1 = np.column_stack((self.q1, self.q2)) self.q_array_in2 = np.column_stack((self.q2, self.q3)) self.q_array_out = np.column_stack((self.q4, self.q5)) self.null = np.array([]) self.null_quat = np.ones((dcs.QUAT_SIZE, 0))
def test_all_vector_inputs(self): quat = dcs.qrot(self.axis, np.array([self.angle, self.angle, self.angle2])) np.testing.assert_array_almost_equal( quat, np.column_stack( (self.quat[0, :], self.quat[1, :], self.quat2[2, :])))
def setUp(self): self.time = np.array([1, 3, 5]) self.quat = np.column_stack( (dcs.qrot(1, 0), dcs.qrot(1, np.pi / 2), dcs.qrot(1, np.pi))) self.ti = np.array([1, 2, 4.5, 5]) self.qout = np.column_stack( (dcs.qrot(1, 0), dcs.qrot(1, np.pi / 4), dcs.qrot(1, 3.5 / 4 * np.pi), dcs.qrot(1, np.pi))) self.ti_extra = np.array([0, 1, 2, 4.5, 5, 10])
def test_null2(self): quat = dcs.qrot(self.null, self.angle) np.testing.assert_array_almost_equal(quat, self.null_quat)
def test_null1(self): quat = dcs.qrot(self.axis[0], self.null) np.testing.assert_array_almost_equal(quat, self.null_quat)
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_single2(self): quat1 = dcs.quat_from_euler(0.01, 3) quat2 = dcs.qrot(3, 0.01) 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_single_angle(self): quat = dcs.qrot(self.axis, self.angle) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat, self.quat.T)
def setUp(self): self.time = np.array([1, 3, 5]) self.quat = np.column_stack((dcs.qrot(1, 0), dcs.qrot(1, np.pi/2), dcs.qrot(1, np.pi))) self.ti = np.array([1, 2, 4.5, 5]) self.qout = np.column_stack((dcs.qrot(1, 0), dcs.qrot(1, np.pi/4), dcs.qrot(1, 3.5/4*np.pi), dcs.qrot(1, np.pi))) self.ti_extra = np.array([0, 1, 2, 4.5, 5, 10])
def test_single1(self): quat1 = dcs.quat_from_euler(self.a[0], self.seq[0]) quat2 = dcs.qrot(self.seq[0], self.a[0]) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)
def test_repeated(self): quat1 = dcs.quat_from_euler(np.hstack((self.a, self.a)), seq=np.array([1, 1, 1, 1, 1, 1])) quat2 = dcs.qrot(1, 2*np.sum(self.a)) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)
def test_vector_mismatch(self): with self.assertRaises(AssertionError): dcs.qrot(self.axis, np.array([self.angle, self.angle2]))
def test_all_vector_inputs(self): quat = dcs.qrot(self.axis, np.array([self.angle, self.angle, self.angle2])) np.testing.assert_array_almost_equal(quat, np.column_stack((self.quat[0,:], self.quat[1,:], self.quat2[2,:])))
def test_repeated(self): quat1 = dcs.quat_from_euler(np.hstack((self.a, self.a)), seq=np.array([1, 1, 1, 1, 1, 1])) quat2 = dcs.qrot(1, 2 * np.sum(self.a)) np.testing.assert_array_almost_equal(quat1, quat2) self.assertEqual(quat1.ndim, 1)
def test_single_axis(self): for i in range(len(self.axis)): quat = dcs.qrot(self.axis[i], np.array([self.angle, self.angle2])) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal(quat, np.column_stack((self.quat[i, :], self.quat2[i, :])))
def test_single_axis(self): for i in range(len(self.axis)): quat = dcs.qrot(self.axis[i], np.array([self.angle, self.angle2])) self.assertEqual(quat.ndim, 2) np.testing.assert_array_almost_equal( quat, np.column_stack((self.quat[i, :], self.quat2[i, :])))
def test_single_inputs(self): for i in range(len(self.axis)): quat = dcs.qrot(self.axis[i], self.angle) self.assertEqual(quat.ndim, 1) np.testing.assert_array_almost_equal(quat, self.quat[i, :])