Acoular 25.03 documentation

Polygon

«  MultiSector   ::   grids   ::   acoular.grids.in_hull  »

Polygon

class acoular.grids.Polygon(x, y)

Bases: object

Create an object representing a general polygon in a 2D plane.

This class allows defining a polygon by specifying the coordinates of its vertices and provides methods for checking whether a set of points lies inside the polygon, or if a point is closer to a side or vertex of the polygon.

Parameters:
xarray_like

Array of x-coordinates of the vertices that define the polygon. These coordinates should form a closed shape (i.e., the last point should be the same as the first point).

yarray_like

Array of y-coordinates of the vertices that define the polygon. These coordinates should correspond to the x-coordinates, forming a closed shape.

Attributes:
xnumpy.ndarray

Array of x-coordinates of the polygon vertices.

ynumpy.ndarray

Array of y-coordinates of the polygon vertices.

is_inside(xpoint, ypoint, smalld=1e-12)

Check if a point or set of points are inside the polygon.

Parameters:
xpointfloat or array_like

Array of x-coordinates of the points to be tested.

ypointfloat or array_like

Array of y-coordinates of the points to be tested.

smalldfloat, optional

Tolerance used for floating point comparisons when checking if a point is exactly on a polygon’s edge. The default value is 1e-12.

Returns:
float or array_like

The distance from the point to the nearest point on the polygon. The values returned have the following meanings: - mindst < 0: Point is outside the polygon. - mindst = 0: Point is on an edge of the polygon. - mindst > 0: Point is inside the polygon.

Notes

The method uses an improved algorithm based on Nordbeck and Rydstedt for determining whether a point is inside a polygon [17].

«  MultiSector   ::   grids   ::   acoular.grids.in_hull  »