pyvista.Cylinder

Contents

pyvista.Cylinder#

Cylinder(
center: VectorLike[float] = (0.0, 0.0, 0.0),
direction: VectorLike[float] = (1.0, 0.0, 0.0),
radius: float = 0.5,
height: float = 1.0,
resolution: int = 100,
capping: bool = True,
) PolyData[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')
../../../_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()
../../../_images/pyvista-Cylinder-1_01_00.png

The above examples are similar in terms of their behavior.