in_hull#
- acoular.grids.in_hull(p, hull, border=True, tol=0)
Test if points in
pare inhull, in- or excluding the border.- Parameters:
- p
numpy.ndarrayoffloats, shape (N, K) Coordinates of N points in K dimensions.
- hull
numpy.ndarrayoffloats, shape (M, K), orDelaunayobject Coordinates of M points in K dimensions for which Delaunay triangulation will be computed.
- borderbool, optional
Points in
pon the border ofhullwill be kept in the return if True. If False, only points insidehullwill be kept. Default is True.- tol
float, optional Tolerance allowed in the
inside-triangle check. Default is0.
- p
- Returns:
numpy.ndarrayofboolsAn array of boolean values indicating which points in
pare inside the hull, same shape asp. Each entry isTrueif the corresponding point is inside the hull (or on the border, ifborder=True), andFalseotherwise.
Notes
This function uses Delaunay triangulation to determine if a point is inside the convex hull, which is efficient and robust for arbitrary shapes in higher-dimensional spaces.
Examples
>>> from acoular.grids import in_hull >>> import numpy as np >>> from scipy.spatial import Delaunay >>> points = np.array([[0, 0], [1, 0], [0, 1], [1, 1]]) >>> hull = Delaunay(points) >>> p = np.array([[0.5, 0.5], [2, 2]]) >>> in_hull(p, hull) array([ True, False])