File: create-parametric-geometric-objects.py

package info (click to toggle)
python-pyvista 0.44.1-11
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 159,804 kB
  • sloc: python: 72,164; sh: 118; makefile: 68
file content (216 lines) | stat: -rw-r--r-- 3,469 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
"""
.. _parametric_example:

Parametric Geometric Objects
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Creating parametric objects from :ref:`parametric_api`.
"""

from __future__ import annotations

from math import pi

# sphinx_gallery_thumbnail_number = 12
import pyvista as pv

# %%
# This example demonstrates how to plot parametric objects using pyvista
#
# Supertoroid
# +++++++++++

supertoroid = pv.ParametricSuperToroid(n1=0.5)
supertoroid.plot(color='lightblue', smooth_shading=True)

# %%
# Parametric Ellipsoid
# ++++++++++++++++++++

# Ellipsoid with a long x axis
ellipsoid = pv.ParametricEllipsoid(10, 5, 5)
ellipsoid.plot(color='lightblue')


# %%
# Partial Parametric Ellipsoid
# ++++++++++++++++++++++++++++

# cool plotting direction
cpos = [
    (21.9930, 21.1810, -30.3780),
    (-1.1640, -1.3098, -0.1061),
    (0.8498, -0.2515, 0.4631),
]


# half ellipsoid
part_ellipsoid = pv.ParametricEllipsoid(10, 5, 5, max_v=pi / 2)
part_ellipsoid.plot(color='lightblue', smooth_shading=True, cpos=cpos)


# %%
# Pseudosphere
# ++++++++++++

pseudosphere = pv.ParametricPseudosphere()
pseudosphere.plot(color='lightblue', smooth_shading=True)

# %%
# Bohemian Dome
# +++++++++++++


bohemiandome = pv.ParametricBohemianDome()
bohemiandome.plot(color='lightblue')

# %%
# Bour
# ++++

bour = pv.ParametricBour()
bour.plot(color='lightblue')

# %%
# Boy's Surface
# +++++++++++++

boy = pv.ParametricBoy()
boy.plot(color='lightblue')

# %%
# Catalan Minimal
# +++++++++++++++

catalanminimal = pv.ParametricCatalanMinimal()
catalanminimal.plot(color='lightblue')

# %%
# Conic Spiral
# ++++++++++++

conicspiral = pv.ParametricConicSpiral()
conicspiral.plot(color='lightblue')

# %%
# Cross Cap
# +++++++++

crosscap = pv.ParametricCrossCap()
crosscap.plot(color='lightblue')

# %%
# Dini
# ++++

dini = pv.ParametricDini()
dini.plot(color='lightblue')

# %%
# Enneper
# +++++++

enneper = pv.ParametricEnneper()
enneper.plot(cpos="yz")

# %%
# Figure-8 Klein
# ++++++++++++++

figure8klein = pv.ParametricFigure8Klein()
figure8klein.plot()

# %%
# Henneberg
# +++++++++

henneberg = pv.ParametricHenneberg()
henneberg.plot(color='lightblue')

# %%
# Klein
# +++++

klein = pv.ParametricKlein()
klein.plot(color='lightblue')

# %%
# Kuen
# ++++

kuen = pv.ParametricKuen()
kuen.plot(color='lightblue')

# %%
# Mobius
# ++++++

mobius = pv.ParametricMobius()
mobius.plot(color='lightblue')

# %%
# Plucker Conoid
# ++++++++++++++

pluckerconoid = pv.ParametricPluckerConoid()
pluckerconoid.plot(color='lightblue')


# %%
# Random Hills
# ++++++++++++

randomhills = pv.ParametricRandomHills()
randomhills.plot(color='lightblue')

# %%
# Roman
# +++++

roman = pv.ParametricRoman()
roman.plot(color='lightblue')

# %%
# Super Ellipsoid
# +++++++++++++++

superellipsoid = pv.ParametricSuperEllipsoid(n1=0.1, n2=2)
superellipsoid.plot(color='lightblue')

# %%
# Torus
# +++++

torus = pv.ParametricTorus()
torus.plot(color='lightblue')

# %%
# Circular Arc
# ++++++++++++

pointa = [-1, 0, 0]
pointb = [0, 1, 0]
center = [0, 0, 0]
resolution = 100

arc = pv.CircularArc(pointa, pointb, center, resolution)

pl = pv.Plotter()
pl.add_mesh(arc, color='k', line_width=4)
pl.show_bounds()
pl.view_xy()
pl.show()


# %%
# Extruded Half Arc
# +++++++++++++++++

pointa = [-1, 0, 0]
pointb = [1, 0, 0]
center = [0, 0, 0]
resolution = 100

arc = pv.CircularArc(pointa, pointb, center, resolution)
poly = arc.extrude([0, 0, 1])
poly.plot(color='lightblue', cpos='iso', show_edges=True)