DataSetFilters.sample_over_line#
- DataSetFilters.sample_over_line(
- pointa: VectorLikeFloat,
- pointb: VectorLikeFloat,
- *,
- resolution: int | None = None,
- tolerance: float | None = None,
- progress_bar: bool = False,
Sample a dataset onto a line.
- Parameters:
- pointa
VectorLikeFloat Location in
[x, y, z].- pointb
VectorLikeFloat 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.
- pointa
- Returns:
pyvista.PolyDataLine object with sampled data from dataset.
Examples#
Download Python source code | Download Jupyter notebook
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()