PolyDataFilters.project_points_to_plane

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,
)[source]#

Project points of this mesh to a plane.

The origin and normal may be set explicitly or implicitly using a Plane().

Parameters:
originVectorLike[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.

normalVectorLike[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.

planePolyData, optional

Plane() mesh to project to. Use this as an alternative to setting origin and normal. The mean of the plane’s normal vectors is used for the normal parameter and the mean of the plane’s points is used for the origin parameter.

Added in version 0.47.

Returns:
pyvista.PolyData

The 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()
../../../_images/pyvista-PolyDataFilters-project_points_to_plane-f6492be937984cbe_00_00.png

See Also#

Project Points to a Plane and Tessellate