Warping by VectorsΒΆ

This example applies the warp_by_vector filter to a sphere mesh that has 3D displacement vectors defined at each node.

We first compare the unwarped sphere to the warped sphere.

import pyvista as pv
from pyvista import examples

sphere = examples.load_sphere_vectors()
warped = sphere.warp_by_vector()
warped.translate([0, 0., -7.])

p = pv.Plotter()
p.add_mesh(sphere, color='white')
p.add_mesh(warped, color='white')
p.show()
warp by vector

Out:

[(18.208314079596473, 18.058354992224647, 14.55831434185691),
 (0.0, -0.14995908737182617, -3.649999737739563),
 (0.0, 0.0, 1.0)]

We then use several values for the scale factor applied to the warp operation. Applying a warping factor that is too high can often lead to unrealistic results.

warp_factors = [0, 1.5, 3.5, 5.5]
p = pv.Plotter(shape=(2, 2))
for i in range(2):
    for j in range(2):
        idx = 2 * i + j
        p.subplot(i, j)
        p.add_mesh(sphere.warp_by_vector(factor=warp_factors[idx]))
        p.add_text(f'factor={warp_factors[idx]}')
p.show()
warp by vector

Out:

[(13.229537151962102, 11.82742228379804, 11.80935599675733),
 (0.0, -1.4021148681640625, -1.420181155204773),
 (0.0, 0.0, 1.0)]

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

Gallery generated by Sphinx-Gallery