PolyDataFilters.project_points_to_plane#
- PolyDataFilters.project_points_to_plane(
- origin: VectorLike[float] | None = None,
- normal: VectorLike[float] | _NormalsLiteral | None = None,
- inplace: bool = False,
- plane: PolyData | None = None,
Project points of this mesh to a plane.
The origin and normal may be set explicitly or implicitly using a
Plane().- Parameters:
- origin
VectorLike[float],optional Plane origin. Defaults to the approximate center of the input mesh minus half the length of the input mesh in the direction of the normal.
- normal
VectorLike[float] |str,optional Length-3 vector for the plane’s normal. Can also be specified as a string conventional direction such as
'x'for(1, 0, 0)or'-x'for(-1, 0, 0), etc. The'z'direction is used by default.- inplacebool, default:
False Whether to overwrite the original mesh with the projected points.
- plane
PolyData,optional Plane()mesh to project to. Use this as an alternative to settingoriginandnormal. The mean of the plane’s normal vectors is used for thenormalparameter and the mean of the plane’s points is used for theoriginparameter.Added in version 0.47.
- origin
- Returns:
pyvista.PolyDataThe points of this mesh projected onto a plane.
Examples#
Download Python source code | Download Jupyter notebook
Flatten a sphere to the XY plane.
>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> projected = sphere.project_points_to_plane()
Plot the projected sphere along with the original.
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(projected, show_edges=True, line_width=3)
>>> _ = pl.add_mesh(sphere)
>>> _ = pl.show_grid()
>>> cpos = pv.CameraPosition(
... position=(2.5, 2.5, 1.1),
... focal_point=(0.0, 0.0, -0.3),
... viewup=(-0.25, -0.25, 1.0),
... )
>>> pl.camera_position = cpos
>>> pl.show()
See Also#
Used In#
Gallery Examples