def test_min_corner_offset(self):
     """
     Test with a non-zero min_corner.
     """
     points = np.array([[0.1, 0.1, 0.1], [1.1, 2.1, 3.1], [1.3, 2.2, 3.4]])
     vg = VoxelGrid(1, min_corner=Vector3f(-1, -2, -3), points=points)
     centers = vg.voxel_centers()
     expected_centers = np.array([[0.5, 0.5, 0.5], [1.5, 2.5, 3.5]])
     np.testing.assert_array_almost_equal(centers, expected_centers)
 def test_constructor_with_points(self):
     """
     Tests voxel_centers.  Verifies that multiple points in the same voxel
     are deduplicated.
     """
     points = np.array([[0.1, 0.1, 0.1], [1.1, 1.1, 1.1], [1.3, 1.2, 1.4]])
     vg = VoxelGrid(0.5, min_corner=Vector3f(0, 0, 0), points=points)
     centers = vg.voxel_centers()
     expected_centers = np.array([[0.25, 0.25, 0.25], [1.25, 1.25, 1.25]])
     np.testing.assert_array_almost_equal(centers, expected_centers)
    def test_add_points(self):
        """
        Add additional points to an initial set.  Checks that redundant
        voxels are counted only once.
        """

        points = np.array([[0.1, 0.1, 0.1], [1.1, 2.1, 3.1], [1.3, 2.2, 3.4]])
        vg = VoxelGrid(1, min_corner=Vector3f(-1, -2, -3), points=points)
        points2 = np.array([[0.2, 0.2, 0.3], [2, 2, 2], [4, 4, 4]])
        vg.add_points(points2)
        centers = vg.voxel_centers()
        expected_centers = np.array([[0.5, 0.5, 0.5], [2.5, 2.5, 2.5],
                                     [1.5, 2.5, 3.5], [4.5, 4.5, 4.5]])
        np.testing.assert_array_almost_equal(centers, expected_centers)