Ejemplo n.º 1
0
def test_rt_transpose():
    rt = Rototrans.from_random_data()
    rt_t = Rototrans.from_transposed_rototrans(rt)

    rt_t_expected = np.zeros((4, 4, rt.time.size))
    rt_t_expected[3, 3, :] = 1
    for row in range(rt.row.size):
        for col in range(rt.col.size):
            for frame in range(rt.time.size):
                rt_t_expected[col, row, frame] = rt[row, col, frame]

    for frame in range(rt.time.size):
        rt_t_expected[:3, 3, frame] = -rt_t_expected[:3, :3, frame].dot(
            rt[:3, 3, frame])

    np.testing.assert_array_almost_equal(rt_t, rt_t_expected, decimal=10)
def test_rt_transpose():
    n_frames = 10
    angles = Angles.from_random_data(size=(3, 1, n_frames))
    rt = Rototrans.from_euler_angles(angles, angle_sequence="xyz")

    rt_t = Rototrans.from_transposed_rototrans(rt)

    rt_t_expected = np.zeros((4, 4, n_frames))
    rt_t_expected[3, 3, :] = 1
    for row in range(rt.row.size):
        for col in range(rt.col.size):
            for frame in range(rt.time.size):
                rt_t_expected[col, row, frame] = rt[row, col, frame]

    for frame in range(rt.time.size):
        rt_t_expected[:3, 3, frame] = -rt_t_expected[:3, :3, frame].dot(
            rt[:3, 3, frame])

    np.testing.assert_array_almost_equal(rt_t, rt_t_expected, decimal=10)