Пример #1
0
def test_always_outputs_float64():
    result = rotation_from_up_and_look(
        up=np.array(vg.basis.y, dtype=np.float32),
        look=np.array(vg.basis.z, dtype=np.float32),
    )
    assert result.dtype == np.float64
    np.testing.assert_array_almost_equal(result, np.eye(3))
Пример #2
0
def reorient_points(points, up, look):
    from polliwog.transform import rotation_from_up_and_look

    vg.shape.check(locals(), "up", (3,))
    vg.shape.check(locals(), "look", (3,))

    return np.dot(rotation_from_up_and_look(up, look), points.T).T
Пример #3
0
def test_vary_up_alone():
    np.testing.assert_array_almost_equal(
        euler([0, 0, 45]),
        rotation_from_up_and_look(up=np.array([1, 1, 0]), look=vg.basis.z),
    )
    np.testing.assert_array_almost_equal(
        euler([0, 0, 90]),
        rotation_from_up_and_look(up=vg.basis.x, look=vg.basis.z))
    np.testing.assert_array_almost_equal(
        euler([0, 0, 135]),
        rotation_from_up_and_look(up=np.array([1, -1, 0]), look=vg.basis.z),
    )
    np.testing.assert_array_almost_equal(
        euler([0, 0, 180]),
        rotation_from_up_and_look(up=vg.basis.neg_y, look=vg.basis.z),
    )
    np.testing.assert_array_almost_equal(
        euler([0, 0, 225]),
        rotation_from_up_and_look(up=np.array([-1, -1, 0]), look=vg.basis.z),
    )
    np.testing.assert_array_almost_equal(
        euler([0, 0, 270]),
        rotation_from_up_and_look(up=vg.basis.neg_x, look=vg.basis.z),
    )
    np.testing.assert_array_almost_equal(
        euler([0, 0, 315]),
        rotation_from_up_and_look(up=np.array([-1, 1, 0]), look=vg.basis.z),
    )
Пример #4
0
def test_starting_with_canonical_reference_frame_gives_identity():
    result = rotation_from_up_and_look(up=vg.basis.y, look=vg.basis.z)
    np.testing.assert_array_almost_equal(result, np.eye(3))
Пример #5
0
def test_normalizes_inputs():
    result = rotation_from_up_and_look(up=np.array([0, 42, 0]),
                                       look=np.array([0, 0, 13]))
    np.testing.assert_array_almost_equal(result, np.eye(3))
Пример #6
0
def test_raises_value_error_with_collinear_inputs():
    with pytest.raises(ValueError):
        rotation_from_up_and_look(up=vg.basis.z, look=vg.basis.z)
    with pytest.raises(ValueError):
        rotation_from_up_and_look(up=vg.basis.z, look=vg.basis.neg_z)
Пример #7
0
def test_raises_value_error_with_zero_length_inputs():
    with pytest.raises(ValueError):
        rotation_from_up_and_look(up=origin, look=vg.basis.z)
    with pytest.raises(ValueError):
        rotation_from_up_and_look(up=vg.basis.y, look=origin)