ConvexSector#

class acoular.grids.ConvexSector

Bases: SingleSector

Class for defining a convex hull sector.

This class defines a convex hull sector for 2D grids. The sector is created using a list of edge coordinates edges which represent the vertices of a polygon. The convex hull is the smallest convex shape that contains all the given vertices.

Examples

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

edges

List of edge coordinates that define the convex hull. The coordinates must define a closed polygon that forms the convex hull like x1, y1, x2, y2, … xn, yn.

contains(pos)

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

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

Parameters:
posarray of floats

Array containing the positions of N grid points, shape (3, N).

Returns:
numpy.ndarray of bools

An array of shape (N,) indicating which of the given positions lie within the given sector.

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.ConvexSector(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.