waxmorph.data.sample_volume

Contents

waxmorph.data.sample_volume#

waxmorph.data.sample_volume(mesh, n_points, pitch=None, min_dist=None, seed=0)[source]#

Sample at most n_points centers from a normalized mesh interior.

Defaults use r=(3V/4 pi N)^(1/3), min_dist=1.2r, and pitch=0.4*min_dist. seed fixes candidate order. Returns float32 [M,3], M <= n_points; an empty fill returns [0,3]. The requested spacing stays fixed, so output may contain fewer points than n_points.

Examples

>>> mesh = trimesh.creation.box(extents=(1, 1, 1))
>>> pts = sample_volume(mesh, n_points=3, min_dist=0.4, pitch=0.2, seed=0)
>>> print(pts.shape)
(3, 3)
>>> print(pts.astype(float).round(1).tolist())
[[0.0, 0.2, 0.2], [0.4, 0.4, 0.0], [-0.2, 0.0, -0.2]]
Parameters:
Return type:

ndarray