File: plot_over_circular_arc.py

package info (click to toggle)
python-pyvista 0.46.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176,968 kB
  • sloc: python: 94,346; sh: 216; makefile: 70
file content (59 lines) | stat: -rw-r--r-- 1,544 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
.. _plot_over_circular_arc_example:

Plot Scalars Over a Circular Arc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Interpolate the scalars of a dataset over a circular arc
using :meth:`~pyvista.DataSetFilters.plot_over_circular_arc_normal`.

"""

# sphinx_gallery_thumbnail_number = 2
from __future__ import annotations

import pyvista as pv
from pyvista import examples

# sphinx_gallery_start_ignore
# labels are not supported in vtk-js
PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT = True
# sphinx_gallery_end_ignore

# %%
# Volumetric Mesh
# +++++++++++++++
#
# Add the height scalars to a uniform 3D mesh.
mesh = examples.load_uniform()
mesh['height'] = mesh.points[:, 2]

# Make two points at the bounds of the mesh and one at the center to
# construct a circular arc.
normal = [0, 1, 0]
bnds = mesh.bounds
polar = [bnds.x_min, bnds.y_min, bnds.z_max]
center = [bnds.x_min, bnds.y_min, bnds.z_min]
angle = 90.0

# Preview how this circular arc intersects this mesh
# with :func:`~pyvista.CircularArcFromNormal`.
arc = pv.CircularArcFromNormal(
    center=center, resolution=100, normal=normal, polar=polar, angle=angle
)

p = pv.Plotter()
p.add_mesh(mesh, style='wireframe', color='w')
p.add_mesh(arc, color='b')
a = arc.points[0]
b = arc.points[-1]
p.add_point_labels([a, b], ['A', 'B'], font_size=48, point_color='red', text_color='red')
p.show()

# %%
# Run the filter and produce a line plot.
mesh.plot_over_circular_arc_normal(
    center=center, resolution=100, normal=normal, polar=polar, angle=angle, scalars='height'
)
# %%
# .. tags:: plot