def test_get_roto_translation_matrix_get_check_shape_and_translation():
    rt = get_roto_translation_matrix(np.pi / 8,
                                     rotation_axis=np.array([1, 0, 0]),
                                     translation=np.array([1, 2, 3]))
    assert rt.shape == (4, 4)
    assert_array_equal(rt[3, :], np.array([0, 0, 0, 1]))
    assert_array_equal(rt[:, 3], np.array([1, 2, 3, 1]))
def test_get_roto_translation_matrix_around_z_axis():
    # standard nifti convention (RAS) x -> pitch, y -> roll, z -> yaw.
    theta = np.pi / 9
    rot_axis = np.array([0, 0, 1])
    transl = np.array([1, 2, 3])
    expected_rot = np.array([[np.cos(theta), -np.sin(theta), 0],
                             [np.sin(theta), np.cos(theta), 0], [0, 0, 1]])

    rt = get_roto_translation_matrix(theta, rot_axis, transl)
    expected_rt = np.eye(4)
    expected_rt[:3, :3] = expected_rot
    expected_rt[:3, 3] = transl

    assert_array_equal(rt, expected_rt)
def test_get_roto_translation_matrix_too_small_rotation_axis():
    with assert_raises(IOError):
        get_roto_translation_matrix(np.pi / 4,
                                    rotation_axis=np.array([0.0009, 0, 0]),
                                    translation=np.array([0, 0, 0]))