Acoular 25.03 documentation

ConvexSector

«  PolySector   ::   grids   ::   MultiSector  »

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

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

«  PolySector   ::   grids   ::   MultiSector  »