Пример #1
0
def test_check_screw_axis():
    random_state = np.random.RandomState(73)
    omega = norm_vector(random_vector(random_state, 3))
    v = random_vector(random_state, 3)

    assert_raises_regexp(ValueError, "Expected 3D vector with shape",
                         check_screw_axis, np.r_[0, 1, v])

    assert_raises_regexp(ValueError,
                         "Norm of rotation axis must either be 0 or 1",
                         check_screw_axis, np.r_[2 * omega, v])

    assert_raises_regexp(ValueError, "If the norm of the rotation axis is 0",
                         check_screw_axis, np.r_[0, 0, 0, v])

    S_pure_translation = np.r_[0, 0, 0, norm_vector(v)]
    S = check_screw_axis(S_pure_translation)
    assert_array_almost_equal(S, S_pure_translation)

    S_both = np.r_[omega, v]
    S = check_screw_axis(S_both)
    assert_array_almost_equal(S, S_both)
Пример #2
0
def test_random_screw_axis():
    random_state = np.random.RandomState(893)
    for _ in range(5):
        S = random_screw_axis(random_state)
        check_screw_axis(S)