Polygon

class Polygon(vertices: List[_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]])

Shape defined by a list of vertices in a 2D plane

Attributes:
verticesList[array_like]

Must be defined in clockwise or counterclockwise order.

Attributes

lattice_offset

vertices

Methods

contains(x, y, z)

Return True if the given position is located within the shape

plot([ax])

Line plot of the polygon

with_offset(vector)

Return a copy that's offset by the given vector

contains(x: numpy.ndarray[numpy.float64[m, 1]], y: numpy.ndarray[numpy.float64[m, 1]], z: numpy.ndarray[numpy.float64[m, 1]])

Return True if the given position is located within the shape

Given arrays as input the return type is a boolean array.

Parameters:
x, y, zarray_like

Positions to test against the shape.

plot(ax: Axes | None = None, **kwargs) None

Line plot of the polygon

Parameters:
axOptional[plt.Axes]

The axis to plot on.

**kwargs

Forwarded to matplotlib.pyplot.plot().

with_offset(vector: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Polygon

Return a copy that’s offset by the given vector