# Examples from pyvista.Plotter.enable_camera_distortion
# ======================================================

# Plot a grid through an undistorted camera. The coefficients act on
# the distance from the optical axis, so a wide-angle lens filling the
# frame is where the distortion is easiest to see – and the kind of
# lens that distorts most in the first place.
# The shader is not carried into an interactive scene, so these plots
# are rendered statically.
import pyvista as pv
grid = pv.Plane(i_size=3.0, j_size=3.0, i_resolution=16, j_resolution=16)
wide_angle = [(0.0, 0.0, 3.2), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)]
pl = pv.Plotter()
_ = pl.add_mesh(grid, show_edges=True, color='white')
pl.camera_position = wide_angle
pl.camera.view_angle = 70.0
pl.show()

# Now with barrel distortion, which bows the straight edges outward.
import pyvista as pv
grid = pv.Plane(i_size=3.0, j_size=3.0, i_resolution=16, j_resolution=16)
pl = pv.Plotter()
_ = pl.add_mesh(grid, show_edges=True, color='white')
pl.camera_position = [(0.0, 0.0, 3.2), (0.0, 0.0, 0.0), (0.0, 1.0, 0.0)]
pl.camera.view_angle = 70.0
pl.enable_camera_distortion((0.3, 0.1, 0.0, 0.0))
pl.show()

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
