Exemple #1
0
 def test_equiv_quaternions(self):
     """Different Euler rotations give same quaternion, up to sign."""
     # Check if euler angles from to_zyz return same quaternion
     # up to a sign (2pi rotation)
     rot = [
         'xyz', 'xyx', 'xzy', 'xzx', 'yzx', 'yzy', 'yxz', 'yxy', 'zxy',
         'zxz', 'zyx', 'zyz'
     ]
     for value in rot:
         rnd = np.array([-1.57657536, 5.66384302, 2.91532185])
         quat1 = Quaternion.from_euler(rnd, value)
         euler = quat1.to_zyz()
         quat2 = Quaternion.from_euler(euler, 'zyz')
         assert_allclose(abs(quat1.data.dot(quat2.data)), 1)
Exemple #2
0
 def setUp(self):
     super().setUp()
     self.rnd_array = np.array([0.5, 0.8, 0.9, -0.3])
     self.quat_unnormalized = Quaternion(self.rnd_array)
     axes = ['x', 'y', 'z']
     rnd = np.array([-0.92545003, -2.19985357, 6.01761209])
     idx = np.array([0, 2, 1])
     self.mat1 = rotation_matrix(rnd[0], axes[idx[0]]).dot(
         rotation_matrix(rnd[1], axes[idx[1]]).dot(
             rotation_matrix(rnd[2], axes[idx[2]])))
     axes_str = ''.join(axes[i] for i in idx)
     quat = Quaternion.from_euler(rnd, axes_str)
     self.mat2 = quat.to_matrix()