Example #1
0
def test_transform_points_transpose_equivalence() -> None:
    input_points = np.random.rand(10, 3)
    input_points_t = input_points.transpose(1, 0)

    #  Generate some random transformation matrix
    tf = np.identity(4)
    tf[:3, :3] = transforms3d.euler.euler2mat(np.random.rand(),
                                              np.random.rand(),
                                              np.random.rand())
    tf[3, :3] = np.random.rand(3)

    output_points = transform_points(input_points, tf)
    output_points_t = transform_points_transposed(input_points_t, tf)

    np.testing.assert_array_equal(output_points.transpose(1, 0),
                                  output_points_t)
    tf_inv = np.linalg.inv(tf)

    input_points_recovered = transform_points(output_points, tf_inv)
    input_points_t_recovered = transform_points_transposed(
        output_points_t, tf_inv)

    np.testing.assert_almost_equal(input_points_recovered,
                                   input_points,
                                   decimal=10)
    np.testing.assert_almost_equal(input_points_t_recovered,
                                   input_points_t,
                                   decimal=10)
Example #2
0
    def test_wrong_input_shape(self) -> None:
        tf = np.eye(4)

        with self.assertRaises(ValueError):
            points = np.zeros((3, 10))
            transform_points(points, tf)

        with self.assertRaises(ValueError):
            points = np.zeros((10, 3))
            transform_points_transposed(points, tf)