def test_flip_gamma(self): flip = np.eye(3) flip[0,0] = -1 flip[1,1] = -1 rot_alpha, rot_beta, rot_gamma = 0., 0., math.pi matrix = cm.euler_rotation_matrix(rot_alpha, rot_beta, rot_gamma) delta = np.abs(matrix - flip) self.assertTrue(delta.max() < 1e-5, "%s !=\n %s" % (matrix, flip))
def test_quarter_rotate_beta_gamma(self): flip = np.array([[0., -1., 0.], [0., 0., -1.], [1., 0., 0.]]) rot_alpha, rot_beta, rot_gamma = 0., math.pi/2., math.pi/2 matrix = cm.euler_rotation_matrix(rot_alpha, rot_beta, rot_gamma) delta = np.abs(matrix - flip) self.assertTrue(delta.max() < 1e-5, "%s !=\n %s" % (matrix, flip))
def test_rotation_orthogonal(self): eye = np.eye(3) for count in xrange(100): (rot_alpha, rot_beta, rot_gamma) = [random.random() * 2 * math.pi for i in xrange(3)] matrix = cm.euler_rotation_matrix(rot_alpha, rot_beta, rot_gamma) product = np.dot(matrix, matrix.transpose()) delta = np.abs(product - eye) self.assertTrue(delta.max() < 1e-5)