PolySector#

class acoular.grids.PolySector

Bases: SingleSector

Class for defining a polygon sector.

Inherits from SingleSector and provides functionality to define a polygonal sector on a 2D grid.

Notes

The polygon is specified by the Polygon class.

Examples

Load example data and set diffrent Sectors for intergration in the sector integration example.

edges

List of coordinates representing the polygon’s vertices. The coordinates must define a closed polygon like x1, y1, x2, y2, ... xn, yn.

contains(pos)

Check if the coordinates in a given array lie within the polygon sector.

If no coordinate is inside, the nearest one to the rectangle center is returned if default_nearest is True.

Parameters:
posarray of floats

A (3, N) array containing the positions of N grid points where each point is represented by its x, y, and z coordinates.

Returns:
numpy.ndarray of bools

A boolean array of shape (N,) indicating which of the given positions lie within the polygon sector. True if the grid point is inside the polygon, otherwise False.

Examples

>>> import acoular as ac
>>> grid = ac.RectGrid(increment=1)
>>> grid.pos
array([[-1., -1., -1.,  0.,  0.,  0.,  1.,  1.,  1.],
       [-1.,  0.,  1., -1.,  0.,  1., -1.,  0.,  1.],
       [ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.]])
>>> sec = ac.PolySector(edges=[0, 0, 1, 0, 1, 1, 0, 1])
>>> sec.contains(grid.pos)
array([False, False, False, False,  True,  True, False,  True,  True])
include_border

If True, grid points lying on the sector border are included in the sector. Default is True.

abs_tol

The absolute tolerance to apply when determining if a grid point lies on the sector border. Default is 1e-12.

default_nearest

If True, the contains method (as in RectSector.contains(), RectSector3D.contains(), CircSector.contains(), and PolySector.contains()) returns the nearest grid point if no grid points are inside the sector. Default is True.