def test_deg2quat(self): self.assertAlmostEqual(quat.deg2quat(10), 0.087155742747658166) result = quat.deg2quat(array([10, 170, 190, -10])) correct = array([0.08715574, 0.9961947, -0.9961947, -0.08715574]) error = norm(result - correct) self.assertTrue(error < self.delta)
def test_deg2quat(self): self.assertAlmostEqual(quat.deg2quat(10), 0.087155742747658166) result = quat.deg2quat(array([10, 170, 190, -10])) correct = array([ 0.08715574, 0.9961947 , -0.9961947 , -0.08715574]) error = norm(result - correct) self.assertTrue(error < self.delta)
def test_target2orient(self): a = [1, 1, 0] b = [1., 0, 1] angle = 45 result = vector.target2orient(np.array([a, b]), 'Helmholtz') correct = np.array([[0., angle, 0.], [-angle, 0., 0.]]) error = norm(result - correct) self.assertAlmostEqual(error, 0) result = vector.target2orient(np.array([a, b]), 'Fick') correct = np.array([[angle, 0., 0], [0, -angle, 0.]]) error = norm(result - correct) self.assertAlmostEqual(error, 0) q_angle = quat.deg2quat(angle) result = vector.target2orient(np.array([a, b])) correct = np.array([[0, 0, q_angle], [0, -q_angle, 0.]]) error = norm(result - correct) self.assertAlmostEqual(error, 0) result = vector.target2orient(a) correct = np.array([0, 0, q_angle]) error = norm(result - correct) self.assertAlmostEqual(error, 0)
def test_target2orient(self): a = [1,1,0] b = [1., 0, 1] angle = 45 result = vector.target2orient(np.array([a,b]), 'Helmholtz') correct = np.array([[ 0., angle, 0.], [-angle, 0., 0.]] ) error = norm(result-correct) self.assertAlmostEqual(error, 0) result = vector.target2orient(np.array([a,b]), 'Fick') correct = np.array([[angle, 0., 0], [0, -angle, 0.]] ) error = norm(result-correct) self.assertAlmostEqual(error, 0) q_angle = quat.deg2quat(angle) result = vector.target2orient(np.array([a,b])) correct = np.array([[0, 0, q_angle], [0, -q_angle, 0.]] ) error = norm(result-correct) self.assertAlmostEqual(error, 0) result = vector.target2orient(a) correct = np.array([0, 0, q_angle]) error = norm(result-correct) self.assertAlmostEqual(error, 0)
def test_analyze3dmarkers(self): t = np.arange(0,10,0.1) translation = (np.c_[[1,1,0]]*t).T M = np.empty((3,3)) M[0] = np.r_[0,0,0] M[1]= np.r_[1,0,0] M[2] = np.r_[1,1,0] M -= np.mean(M, axis=0) q = np.vstack((np.zeros_like(t), np.zeros_like(t),quat.deg2quat(100*t))).T M0 = vector.rotate_vector(M[0], q) + translation M1 = vector.rotate_vector(M[1], q) + translation M2 = vector.rotate_vector(M[2], q) + translation data = np.hstack((M0,M1,M2)) (pos, ori) = markers.analyze3Dmarkers(data, data[0]) self.assertAlmostEqual(np.max(np.abs(pos-translation)), 0) self.assertAlmostEqual(np.max(np.abs(ori-q)), 0)
def test_analyze3dmarkers(self): t = np.arange(0,10,0.1) translation = (np.c_[[1,1,0]]*t).T M = np.empty((3,3)) M[0] = np.r_[0,0,0] M[1]= np.r_[1,0,0] M[2] = np.r_[1,1,0] M -= np.mean(M, axis=0) q = np.vstack((np.zeros_like(t), np.zeros_like(t),quat.deg2quat(100*t))).T M0 = vector.rotate_vector(M[0], q) + translation M1 = vector.rotate_vector(M[1], q) + translation M2 = vector.rotate_vector(M[2], q) + translation data = np.hstack((M0,M1,M2)) (pos, ori) = markers.analyze3Dmarkers(data, data[0]) self.assertAlmostEqual(np.max(np.abs(pos-translation)), 0) self.assertAlmostEqual(np.max(np.abs(ori-q)), 0)