Acoular 25.03 documentation

PolySector

«  CircSector   ::   grids   ::   ConvexSector  »

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(Float)

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])

«  CircSector   ::   grids   ::   ConvexSector  »