Ejemplo n.º 1
0
def test_slerp_single_time():
    rot = TimeDependentRotation([[0, 0, 0, 1]], [0],
                                1,
                                2,
                                av=[[np.pi / 2, 0, 0]])
    new_rot, new_avs = rot._slerp([-1, 3])
    expected_quats = [[-1 / np.sqrt(2), 0, 0, 1 / np.sqrt(2)],
                      [1 / np.sqrt(2), 0, 0, -1 / np.sqrt(2)]]
    expected_av = [[np.pi / 2, 0, 0], [np.pi / 2, 0, 0]]
    np.testing.assert_almost_equal(new_rot.as_quat(), expected_quats)
    np.testing.assert_equal(new_avs, expected_av)
Ejemplo n.º 2
0
def test_slerp():
    test_quats = Rotation.from_euler('x',
                                     np.array([-135, -90, 0, 45, 90]),
                                     degrees=True).as_quat()
    rot = TimeDependentRotation(test_quats, [-0.5, 0, 1, 1.5, 2], 1, 2)
    new_rots, new_avs = rot._slerp(np.arange(-3, 5))
    expected_rot = Rotation.from_euler(
        'x', [-360, -270, -180, -90, 0, 90, 180, 270], degrees=True)
    np.testing.assert_almost_equal(new_rots.as_quat(), expected_rot.as_quat())
    np.testing.assert_almost_equal(np.degrees(new_avs),
                                   np.repeat([[90, 0, 0]], 8, 0))
Ejemplo n.º 3
0
def test_slerp_variable_velocity():
    test_quats = Rotation.from_euler(
        'xyz', [[0, 0, 0], [-90, 0, 0], [-90, 180, 0], [-90, 180, 90]],
        degrees=True).as_quat()
    rot = TimeDependentRotation(test_quats, [0, 1, 2, 3], 1, 2)
    new_rots, new_avs = rot._slerp([-0.5, 0.5, 1.5, 2.5, 3.5])
    expected_rot = Rotation.from_euler('xyz',
                                       [[45, 0, 0], [-45, 0, 0], [-90, 90, 0],
                                        [-90, 180, 45], [-90, 180, 135]],
                                       degrees=True)
    np.testing.assert_almost_equal(new_rots.as_quat(), expected_rot.as_quat())
    np.testing.assert_almost_equal(
        np.degrees(new_avs),
        [[-90, 0, 0], [-90, 0, 0], [0, 180, 0], [0, 0, 90], [0, 0, 90]])
Ejemplo n.º 4
0
def test_slerp_constant_rotation():
    rot = TimeDependentRotation([[0, 0, 0, 1]], [0], 1, 2)
    new_rot, new_avs = rot._slerp([-1, 3])
    np.testing.assert_equal(new_rot.as_quat(), [[0, 0, 0, 1], [0, 0, 0, 1]])
    np.testing.assert_equal(new_avs, [[0, 0, 0], [0, 0, 0]])