PolySector#
- class acoular.grids.PolySector
Bases:
SingleSectorClass for defining a polygon sector.
Inherits from
SingleSectorand provides functionality to define a polygonal sector on a 2D grid.Notes
The polygon is specified by the
Polygonclass.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_nearestisTrue.- 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.
- posarray of
- Returns:
numpy.ndarrayofboolsA boolean array of shape (N,) indicating which of the given positions lie within the polygon sector.
Trueif the grid point is inside the polygon, otherwiseFalse.
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 isTrue.
- 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, thecontainsmethod (as inRectSector.contains(),RectSector3D.contains(),CircSector.contains(), andPolySector.contains()) returns the nearest grid point if no grid points are inside the sector. Default isTrue.