Point Sampling
sample_AABB(box, n_pts, mode='uniform', return_point_cloud=False)
Sample a point cloud uniformly at random inside an axis-aligned bounding box. Works by sampling the unit cube and applying an affine transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
box
|
AABB
|
the domain of sampling |
required |
n_pts
|
int
|
number of points to sample. If mode is 'grid', the function may return a slightly smaller number of points (nearest perfect n-th root). |
required |
mode
|
str
|
sampling mode. 'uniform' or 'grid'. Uniform takes points at random, while 'grid' generates a grid of regularly spaced points. |
'uniform'
|
return_point_cloud
|
bool
|
whether to compile the points in a PointCloud object or return the raw numpy array. Is ignored if the bounding box has dimension >3. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
Exception
|
fails if the bounding box is empty. |
ValueError
|
fails if the dimension of the box is > 3 and return_point_cloud is set to True, so that no PointCloud object with dim > 3 is created. |
Returns:
Type | Description |
---|---|
PointCloud | np.ndarray: a sampled point cloud of |
sample_ball(center, radius, n_pts, return_point_cloud=False)
Samples points uniformly inside a 3D ball.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
Vec
|
center of the ball |
required |
radius
|
float
|
radius of the ball |
required |
n_pts
|
int
|
number of points to sample |
required |
return_point_cloud
|
bool
|
whether to compile the points in a PointCloud object or return the raw numpy array. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
PointCloud | np.ndarray: a sampled point cloud of |
sample_polyline(mesh, n_pts, return_point_cloud=False)
Sample a point cloud uniformly at random from a polyline
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh
|
PolyLine
|
the input polyline |
required |
n_pts
|
int
|
number of points to sample |
required |
return_point_cloud
|
bool
|
whether to compile the points in a PointCloud object or return the raw numpy array. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
PointCloud | np.ndarray: a sampled point cloud of |
sample_sphere(center, radius, n_pts, return_point_cloud=False)
Samples points uniformly on the surface of a 3D sphere
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center
|
Vec
|
center of the sphere |
required |
radius
|
float
|
radius of the spheres |
required |
n_pts
|
int
|
number of points to sample |
required |
return_point_cloud
|
bool
|
whether to compile the points in a PointCloud object or return the raw numpy array. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
PointCloud | np.ndarray: a sampled point cloud of |
sample_surface(mesh, n_pts, return_point_cloud=False, return_normals=False)
Sample a point cloud uniformly at random from a surface mesh
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh
|
SurfaceMesh
|
input mesh |
required |
n_pts
|
int
|
number of points to sample |
required |
return_point_cloud
|
bool
|
whether to compile the points in a PointCloud object or return the raw numpy array. Defaults to False. |
False
|
return_normals
|
bool
|
wether to assign the normal of the faces to sampled points. Only has effect if return_point_cloud is set to True. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
PointCloud | np.ndarray: a sampled point cloud of |
|
np.ndarray : the associated normals (if sample_normals was set to True) |