# 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 tuple 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 tuple or np.ndarray) – Location of the centroid in [x, y, z]

• direction (list or tuple 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)
>>> cpos = 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 tuple or np.ndarray) – Location of the centroid in [x, y, z]

• direction (list or tuple 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 tuple 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 tuple or np.ndarray) – Location of the centroid in [x, y, z]

• direction (list or tuple or np.ndarray) – Direction of the plane’s normal 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), level=0, quads=True)

Create a box with solid faces for the given bounds.

Parameters
• bounds (np.ndarray or list) – Specify the bounding box of the cube. `(xMin, xMax, yMin, yMax, zMin, zMax)`

• level (int) – Level of subdivision of the faces.

• quads (bool, optional) – Flag to tell the source to generate either a quad or two triangle for a set of four points. Default `True`.

`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 in 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 polygon.

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 polygon.

• 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 disc.

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

• c_res (int) – 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)
```
`pyvista.``Wavelet`(extent=(- 10, 10, - 10, 10, - 10, 10), center=(0, 0, 0), maximum=255, x_freq=60, y_freq=30, z_freq=40, x_mag=10, y_mag=18, z_mag=5, std=0.5, subsample_rate=1)

Create a wavelet.

`pyvista.``CircularArc`(pointa, pointb, center, resolution=100, negative=False)

Create a circular arc defined by two endpoints and a center.

The number of segments composing the polyline is controlled by setting the object resolution.

Parameters
• pointa (np.ndarray or list) – Position of the first end point.

• pointb (np.ndarray or list) – Position of the other end point.

• center (np.ndarray or list) – Center of the circle that defines the arc.

• resolution (int, optional) – The number of segments of the polyline that draws the arc. Resolution of 1 will just create a line.

• negative (bool, optional) –

By default the arc spans the shortest angular sector between `pointa` and `pointb`.

By setting this to `True`, the longest angular sector is used instead (i.e. the negative coterminal angle to the shortest one).

Examples

Create a quarter arc centered at the origin in the xy plane.

```>>> import pyvista
>>> arc = pyvista.CircularArc([-1, 0, 0], [0, 1, 0], [0, 0, 0])
>>> pl = pyvista.Plotter()
>>> _ = pl.add_mesh(arc, color='k', line_width=4)
>>> _ = pl.show_bounds(location='all')
>>> _ = pl.view_xy()
>>> cpos = pl.show()
```
`pyvista.``CircularArcFromNormal`(center, resolution=100, normal=None, polar=None, angle=None)

Create a circular arc defined by normal to the plane of the arc, and an angle.

The number of segments composing the polyline is controlled by setting the object resolution.

Parameters
• center (np.ndarray or list) – Center of the circle that defines the arc.

• resolution (int, optional) – The number of segments of the polyline that draws the arc. Resolution of 1 will just create a line.

• normal (np.ndarray or list, optional) – The normal vector to the plane of the arc. By default it points in the positive Z direction.

• polar (np.ndarray or list, optional) – Starting point of the arc in polar coordinates. By default it is the unit vector in the positive x direction.

• angle (float, optional) – Arc length (in degrees) beginning at the polar vector. The direction is counterclockwise. By default it is 90.

Examples

Quarter arc centered at the origin in the xy plane.

```>>> import pyvista
>>> normal = [0, 0, 1]
>>> polar = [-1, 0, 0]
>>> arc = pyvista.CircularArcFromNormal([0, 0, 0], normal=normal, polar=polar)
>>> pl = pyvista.Plotter()
>>> _ = pl.add_mesh(arc, color='k', line_width=4)
>>> _ = pl.show_bounds(location='all')
>>> _ = pl.view_xy()
>>> cpos = pl.show()
```
`pyvista.``Pyramid`(points)

Create a pyramid defined by 5 points.

Parameters

points (np.ndarray or list) – Points of the pyramid. Points are ordered such that the first four points are the four counterclockwise points on the quadrilateral face, and the last point is the apex.

Returns

pyramid

Return type

pyvista.UnstructuredGrid

Examples

```>>> import pyvista
>>> pointa = [1.0, 1.0, 1.0]
>>> pointb = [-1.0, 1.0, 1.0]
>>> pointc = [-1.0, -1.0, 1.0]
>>> pointd = [1.0, -1.0, 1.0]
>>> pointe = [0.0, 0.0, 0.0]
>>> pyramid = pyvista.Pyramid([pointa, pointb, pointc, pointd, pointe])
>>> cpos = pyramid.plot()
```