注釈
Go to the end をクリックすると完全なサンプルコードをダウンロードできます.
ベクトルによるワープ#
This example applies the warp_by_vector()
filter to a sphere mesh that has 3D displacement vectors defined at each node.
まず,ワープしていない球体とワープしている球体を比較します.
from __future__ import annotations
from itertools import product
import pyvista as pv
from pyvista import examples
sphere = examples.load_sphere_vectors()
warped = sphere.warp_by_vector()
pl = pv.Plotter(shape=(1, 2))
pl.subplot(0, 0)
pl.add_text('Before warp')
pl.add_mesh(sphere, color='white')
pl.subplot(0, 1)
pl.add_text('After warp')
pl.add_mesh(warped, color='white')
pl.show()

次に,ワープ操作に適用されるスケール係数にいくつかの値を使用します.過度に高いワープ係数を適用すると,非現実的な結果になることがよくあります.
warp_factors = [0, 1.5, 3.5, 5.5]
pl = pv.Plotter(shape=(2, 2))
for i, j in product(range(2), repeat=2):
idx = 2 * i + j
pl.subplot(i, j)
pl.add_mesh(sphere.warp_by_vector(factor=warp_factors[idx]))
pl.add_text(f'factor={warp_factors[idx]}')
pl.show()

Total running time of the script: (0 minutes 0.729 seconds)