pyvista.Cylinder#

Cylinder(center=(0.0, 0.0, 0.0), direction=(1.0, 0.0, 0.0), radius=0.5, height=1.0, resolution=100, capping=True)[source]#

Create the surface of a cylinder.

Warning

pyvista.Cylinder() function rotates the pyvista.CylinderSource ‘s pyvista.PolyData in its own way. It rotates the pyvista.CylinderSource.output 90 degrees in z-axis, translates and orients the mesh to a new center and direction.

See also pyvista.CylinderStructured().

Parameters:
centersequence[float], default: (0.0, 0.0, 0.0)

Location of the centroid in [x, y, z].

directionsequence[float], default: (1.0, 0.0, 0.0)

Direction cylinder points to in [x, y, z].

radiusfloat, default: 0.5

Radius of the cylinder.

heightfloat, default: 1.0

Height of the cylinder.

resolutionint, default: 100

Number of points on the circular face of the cylinder.

cappingbool, default: True

Cap cylinder ends with polygons.

Returns:
pyvista.PolyData

Cylinder surface.

Examples

>>> import pyvista as pv
>>> cylinder = pv.Cylinder(
...     center=[1, 2, 3], direction=[1, 1, 1], radius=1, height=2
... )
>>> cylinder.plot(show_edges=True, line_width=5, cpos='xy')
https://d33wubrfki0l68.cloudfront.net/288a1a50e508b70bf1be2df1602ccbb30ee4d215/87f39/_images/pyvista-cylinder-1_00_00.png
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(
...     pv.Cylinder(
...         center=[1, 2, 3], direction=[1, 1, 1], radius=1, height=2
...     ),
...     show_edges=True,
...     line_width=5,
... )
>>> pl.camera_position = "xy"
>>> pl.show()
https://d33wubrfki0l68.cloudfront.net/58bd8dbf15b7bef70bce64d3aef4b944ec2cd58a/cbc86/_images/pyvista-cylinder-1_01_00.png

The above examples are similar in terms of their behavior.