skspatial.objects.Cylinder

class skspatial.objects.Cylinder(point: Union[numpy.ndarray, Sequence], vector: Union[numpy.ndarray, Sequence], radius: float)[source]

A cylinder in space.

The cylinder is defined by a point at its base, a vector along its axis, and a radius.

Parameters
pointarray_like

Centre of the cylinder base.

vectorarray_like

Normal vector of the cylinder base (the vector along the cylinder axis). The length of the cylinder is the length of this vector.

radius{int, float}

Radius of the cylinder. This is the radius of the circular base.

Raises
ValueError

If the point or vector are not 3D. If the vector is all zeros. If the radius is zero.

Examples

>>> from skspatial.objects import Cylinder
>>> Cylinder([0, 0], [1, 0, 0], 1)
Traceback (most recent call last):
...
ValueError: The point must be 3D.
>>> Cylinder([0, 0, 0], [1, 0], 1)
Traceback (most recent call last):
...
ValueError: The vector must be 3D.
>>> Cylinder([0, 0, 0], [0, 0, 0], 1)
Traceback (most recent call last):
...
ValueError: The vector must not be the zero vector.
>>> Cylinder([0, 0, 0], [0, 0, 1], 0)
Traceback (most recent call last):
...
ValueError: The radius must be positive.
>>> cylinder = Cylinder([0, 0, 0], [0, 0, 1], 1)
>>> cylinder
Cylinder(point=Point([0, 0, 0]), vector=Vector([0, 0, 1]), radius=1)
>>> cylinder.point
Point([0, 0, 0])
>>> cylinder.vector
Vector([0, 0, 1])
>>> cylinder.radius
1
>>> cylinder.dimension
3
Attributes
pointPoint

Centre of the cylinder base.

vectorVector

Normal vector of the cylinder base.

radius{int, float}

Radius of the cylinder.

dimensionint

Dimension of the cylinder.

Methods

from_points(point_a, point_b, radius)

Instantiate a cylinder from two points and a radius.

intersect_line(line[, n_digits, infinite])

Intersect the cylinder with a 3D line.

is_point_within(point)

Check if a point is within the cylinder.

lateral_surface_area()

Return the lateral surface area of the cylinder.

length()

Return the length of the cylinder.

plot_3d(ax_3d[, n_along_axis, n_angles])

Plot a 3D cylinder.

surface_area()

Return the total surface area of the cylinder.

to_mesh([n_along_axis, n_angles])

Return coordinate matrices for the 3D surface of the cylinder.

to_points(**kwargs)

Return points on the surface of the object.

volume()

Return the volume of the cylinder.