# Geometric Objects¶

PyVista includes a few functions to generate simple geometric objects. The code documentation for these functions are on this page; to see what these functions create, check out the example: Geometric Objects.

`pyvista.``Sphere`(radius=0.5, center=0, 0, 0, direction=0, 0, 1, theta_resolution=30, phi_resolution=30, start_theta=0, end_theta=360, start_phi=0, end_phi=180)

Create a vtk Sphere.

Parameters

• center (np.ndarray or list, optional) – Center in [x, y, z]

• direction (list or np.ndarray) – Direction the top of the sphere points to in [x, y, z]

• theta_resolution (int , optional) – Set the number of points in the longitude direction (ranging from start_theta to end theta).

• phi_resolution (int, optional) – Set the number of points in the latitude direction (ranging from start_phi to end_phi).

• start_theta (float, optional) – Starting longitude angle.

• end_theta (float, optional) – Ending longitude angle.

• start_phi (float, optional) – Starting latitude angle.

• end_phi (float, optional) – Ending latitude angle.

Returns

sphere – Sphere mesh.

Return type

pyvista.PolyData

`pyvista.``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, **kwargs)

Create the surface of a cylinder.

Parameters
• center (list or np.ndarray) – Location of the centroid in [x, y, z]

• direction (list or np.ndarray) – Direction cylinder points to in [x, y, z]

• height (float) – Height of the cylinder.

• resolution (int) – Number of points on the circular face of the cylinder.

• capping (bool, optional) – Cap cylinder ends with polygons. Default True

Returns

cylinder – Cylinder surface.

Return type

pyvista.PolyData

Examples

```>>> import pyvista
>>> import numpy as np
>>> cylinder = pyvista.Cylinder(np.array([1, 2, 3]), np.array([1, 1, 1]), 1, 1)
>>> cylinder.plot()
```
`pyvista.``CylinderStructured`(radius=0.5, height=1.0, center=0.0, 0.0, 0.0, direction=1.0, 0.0, 0.0, theta_resolution=32, z_resolution=10)

Create a cylinder mesh as a `pyvista.StructuredGrid`.

The end caps are left open. This can create a surface mesh if a single value for the `radius` is given or a 3D mesh if multiple radii are given as a list/array in the `radius` argument.

Parameters

• height (float) – Height (length) of the cylinder along its Z-axis

• center (list or np.ndarray) – Location of the centroid in [x, y, z]

• direction (list or np.ndarray) – Direction cylinder Z-axis in [x, y, z]

• theta_resolution (int) – Number of points on the circular face of the cylinder.

• z_resolution (int) – Number of points along the height (Z-axis) of the cylinder

`pyvista.``Arrow`(start=0.0, 0.0, 0.0, direction=1.0, 0.0, 0.0, tip_length=0.25, tip_radius=0.1, tip_resolution=20, shaft_radius=0.05, shaft_resolution=20, scale=None)

Create a vtk Arrow.

Parameters
• start (np.ndarray) – Start location in [x, y, z]

• direction (list or np.ndarray) – Direction the arrow points to in [x, y, z]

• tip_length (float, optional) – Length of the tip.

• tip_resolution (int, optional) – Number of faces around the tip.

• shaft_resolution (int, optional) – Number of faces around the shaft.

• scale (float or str, optional) – Scale factor of the entire object, default is None (i.e. scale of 1). ‘auto’ scales to length of direction array.

Returns

arrow – Arrow surface.

Return type

pyvista.PolyData

`pyvista.``Plane`(center=0, 0, 0, direction=0, 0, 1, i_size=1, j_size=1, i_resolution=10, j_resolution=10)

Create a plane.

Parameters
• center (list or np.ndarray) – Location of the centroid in [x, y, z]

• direction (list or np.ndarray) – Direction cylinder points to in [x, y, z]

• i_size (float) – Size of the plane in the i direction.

• j_size (float) – Size of the plane in the j direction.

• i_resolution (int) – Number of points on the plane in the i direction.

• j_resolution (int) – Number of points on the plane in the j direction.

Returns

plane – Plane mesh

Return type

pyvista.PolyData

`pyvista.``Line`(pointa=- 0.5, 0.0, 0.0, pointb=0.5, 0.0, 0.0, resolution=1)

Create a line.

Parameters
• pointa (np.ndarray or list) – Location in [x, y, z].

• pointb (np.ndarray or list) – Location in [x, y, z].

• resolution (int) – number of pieces to divide line into

`pyvista.``Cube`(center=0.0, 0.0, 0.0, x_length=1.0, y_length=1.0, z_length=1.0, bounds=None)

Create a cube.

It’s possible to specify either the center and side lengths or just the bounds of the cube. If `bounds` are given, all other arguments are ignored.

Parameters
• center (np.ndarray or list) – Center in [x, y, z].

• x_length (float) – length of the cube in the x-direction.

• y_length (float) – length of the cube in the y-direction.

• z_length (float) – length of the cube in the z-direction.

• bounds (np.ndarray or list) – Specify the bounding box of the cube. If given, all other arguments are ignored. `(xMin,xMax, yMin,yMax, zMin,zMax)`

`pyvista.``Box`(bounds=- 1.0, 1.0, - 1.0, 1.0, - 1.0, 1.0)

Create a box with solid faces for the given bounds.

Parameters

bounds (np.ndarray or list) – Specify the bounding box of the cube. If given, all other arguments are ignored. `(xMin,xMax, yMin,yMax, zMin,zMax)`

`pyvista.``Cone`(center=0.0, 0.0, 0.0, direction=1.0, 0.0, 0.0, height=1.0, radius=None, capping=True, angle=None, resolution=6)

Create a cone.

Parameters
• center (np.ndarray or list) – Center in [x, y, z]. middle of the axis of the cone.

• direction (np.ndarray or list) – direction vector in [x, y, z]. orientation vector of the cone.

• height (float) – height along the cone in its specified direction.

• capping (bool) – Turn on/off whether to cap the base of the cone with a polygon.

• angle (float) – The angle degrees between the axis of the cone and a generatrix.

• resolution (int) – number of facets used to represent the cone

`pyvista.``Polygon`(center=0.0, 0.0, 0.0, radius=1, normal=0, 0, 1, n_sides=6)

Create a polygonal disk with a hole in the center.

The disk has zero height. The user can specify the inner and outer radius of the disk, and the radial and circumferential resolution of the polygonal representation.

Parameters
• center (np.ndarray or list) – Center in [x, y, z]. middle of the axis of the polygon.

• normal (np.ndarray or list) – direction vector in [x, y, z]. orientation vector of the cone.

• n_sides (int) – Number of sides of the polygon

`pyvista.``Disc`(center=0.0, 0.0, 0.0, inner=0.25, outer=0.5, normal=0, 0, 1, r_res=1, c_res=6)

Create a polygonal disk with a hole in the center.

The disk has zero height. The user can specify the inner and outer radius of the disk, and the radial and circumferential resolution of the polygonal representation.

Parameters
• center (np.ndarray or list) – Center in [x, y, z]. middle of the axis of the disc.

• inner (float) – The inner radius

• outer (float) – The outer radius

• normal (np.ndarray or list) – direction vector in [x, y, z]. orientation vector of the cone.

• r_res (int) – number of points in radius direction.

• r_res – number of points in circumferential direction.

`pyvista.``Text3D`(string, depth=0.5)

Create 3D text from a string.

`pyvista.``Spline`(points, n_points=None)

Create a spline from points.

Parameters
• points (np.ndarray) – Array of points to build a spline out of. Array must be 3D and directionally ordered.

• n_points (int, optional) – Number of points to interpolate along the points array.

Returns

spline – Line mesh of spline.

Return type

pyvista.PolyData

Examples

Construct a spline

```>>> import numpy as np
>>> import pyvista as pv
>>> theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
>>> z = np.linspace(-2, 2, 100)
>>> r = z**2 + 1
>>> x = r * np.sin(theta)
>>> y = r * np.cos(theta)
>>> points = np.column_stack((x, y, z))
>>> spline = pv.Spline(points, 1000)
```