Debian Codegraph @

examples/01-filter/project_plane.py

raw
1 """
2 .. _project_plane_example:
3
4 Project to a Plane
5 ~~~~~~~~~~~~~~~~~~
6
7 :class:`pyvista.PolyData` surfaces and pointsets can easily be projected to a
8 plane defined by a normal and origin using
9 :meth:`~pyvista.PolyDataFilters.project_points_to_plane`.
10 """
11
12 # sphinx_gallery_thumbnail_number = 2
13 import pyvista as pv
14 from pyvista import examples
15
16 poly = examples.load_random_hills()
17 poly.plot()
18
19 # %%
20 # Project that surface to a plane underneath the surface
21 origin = list(poly.center)
22 origin[-1] -= poly.length / 3.0
23 projected = poly.project_points_to_plane(origin=origin)
24
25 # Display the results
26 pl = pv.Plotter()
27 pl.add_mesh(poly)
28 pl.add_mesh(projected)
29 pl.show()
30 # %%
31 # .. tags:: filter