pyvista.DataSetFilters.sample_over_line#
- DataSetFilters.sample_over_line(
- pointa,
- pointb,
- resolution=None,
- tolerance=None,
- progress_bar=False,
Sample a dataset onto a line.
- Parameters:
- pointasequence[
float
] Location in
[x, y, z]
.- pointbsequence[
float
] Location in
[x, y, z]
.- resolution
int
,optional
Number of pieces to divide line into. Defaults to number of cells in the input mesh. Must be a positive integer.
- tolerance
float
,optional
Tolerance used to compute whether a point in the source is in a cell of the input. If not given, tolerance is automatically generated.
- progress_barbool, default:
False
Display a progress bar to indicate progress.
- pointasequence[
- Returns:
pyvista.PolyData
Line object with sampled data from dataset.
Examples
Sample over a plane that is interpolating a point cloud.
>>> import pyvista as pv >>> import numpy as np >>> rng = np.random.default_rng(12) >>> point_cloud = rng.random((5, 3)) >>> point_cloud[:, 2] = 0 >>> point_cloud -= point_cloud.mean(0) >>> pdata = pv.PolyData(point_cloud) >>> pdata['values'] = rng.random(5) >>> plane = pv.Plane() >>> plane.clear_data() >>> plane = plane.interpolate(pdata, sharpness=3.5) >>> sample = plane.sample_over_line((-0.5, -0.5, 0), (0.5, 0.5, 0)) >>> pl = pv.Plotter() >>> _ = pl.add_mesh( ... pdata, render_points_as_spheres=True, point_size=50 ... ) >>> _ = pl.add_mesh(sample, scalars='values', line_width=10) >>> _ = pl.add_mesh(plane, scalars='values', style='wireframe') >>> pl.show()