def test_quat2rot2quat(): """Test quaternion2rot3d and rotmat_to_quaternion consistency.""" n = 1000 orientations = generate.get_random_quat(n) for i in range(n): orientation = orientations[i] rot = convert.quaternion2rot3d(orientation) quat = convert.rotmat_to_quaternion(rot) assert np.allclose(orientation, quat) \ or np.allclose(orientation, -quat)
def test_rotmat_to_quaternion_z(): """Test rotmat_to_quaternion for 90deg rotations along z.""" quat = convert.rotmat_to_quaternion(cst.Rz90) assert np.allclose(quat, cst.quatz90)
def test_rotmat_to_quaternion_y(): """Test rotmat_to_quaternion for 90deg rotations along y.""" quat = convert.rotmat_to_quaternion(Ry90) assert np.allclose(quat, quaty90)