Skip to content

Commit

Permalink
add docstrings
Browse files Browse the repository at this point in the history
true-real-michael committed Nov 10, 2023
1 parent 9357fee commit a59e659
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions octreelib/internal/point.py
Original file line number Diff line number Diff line change
@@ -21,25 +21,49 @@


class CloudManager:
"""
This class implements methods for point cloud manipulation.
"""
def __init__(self):
raise TypeError("This class is not intended to be instantiated")

@classmethod
def hash_point(cls, point: RawPoint):
"""
Hash point.
:param point: Point to hash.
:return: Hash of the point.
"""
return hash((point[0], point[1], point[2]))

@classmethod
def empty(cls):
"""
:return: Empty point cloud.
"""
return np.empty((0, 3), dtype=float)

@classmethod
def add(cls, points_a: RawPoint, points_b: RawPoint):
"""
Add two point clouds.
:param points_a: First point cloud.
:param points_b: Second point cloud.
:return: Combined point cloud.
"""
return np.vstack([points_a, points_b])

@classmethod
def distribute_grid(
cls, points: RawPointCloud, voxel_size: float, grid_start: RawPoint
):
"""
Distribute points into voxels.
:param points: Points to distribute.
:param voxel_size: Edge length of the voxel.
:param grid_start: Start of the grid.
:return: Dictionary of voxel coordinates and points in the voxel.
"""
voxel_indices = (((points - grid_start) // voxel_size) * voxel_size).astype(int)
voxel_dict = {}
unique_indices = np.unique(voxel_indices, axis=0)
@@ -54,6 +78,13 @@ def distribute_grid(
def distribute(
cls, points: RawPointCloud, corner_min: RawPoint, edge_length: float
) -> List[RawPointCloud]:
"""
Distribute points into 8 octants.
:param points: Points to distribute.
:param corner_min: Corner of the octree node.
:param edge_length: Edge length of the octree node.
:return: List of point clouds in the octants.
"""
clouds = []

for offset in itertools.product([0, edge_length / 2], repeat=3):

0 comments on commit a59e659

Please sign in to comment.