pyransame.random_volume_points#
- pyransame.random_volume_points(mesh: DataSet, n: int = 1, weights: str | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None) ndarray #
Generate random points in a volume.
Supported cell types:
Hexagonal Prism
Hexahedron
Pentagonal Prism
Polyhedron
Pyramid
Tetrahedron
Voxel
Wedge
All cells must be convex.
- Parameters:
- meshpyvista.DataSet
The mesh for which to generate random points. Must have cells.
- nint, default: 1
Number of random points to generate.
- weightsstr, or array_like, optional
Weights to use for probability of choosing points inside each cell.
If a
str
is supplied, it will use the existing cell data onmesh
.
- Returns:
- pointsnp.ndarray
(n, 3)
points that exist inside cells onmesh
.
Examples
>>> import pyransame >>> import pyvista as pv >>> mesh = pv.ImageData(dimensions=(11, 11, 11)) >>> points = pyransame.random_volume_points(mesh, n=500)
Now plot result.
>>> pl = pv.Plotter() >>> _ = pl.add_mesh(mesh, style='wireframe') >>> _ = pl.add_points(points, render_points_as_spheres=True, point_size=10.0, color='red') >>> pl.show()