acoular.grids.in_hull¶
- acoular.grids.in_hull(p, hull, border=True, tol=0)¶
Test if points in
p
are inhull
, in- or excluding the border.- Parameters:
- p
numpy.ndarray
offloats
, shape (N, K) Coordinates of N points in K dimensions.
- hull
numpy.ndarray
offloats
, shape (M, K), orDelaunay
object Coordinates of M points in K dimensions for which Delaunay triangulation will be computed.
- borderbool, optional
Points in
p
on the border ofhull
will be kept in the return if True. If False, only points insidehull
will be kept. Default is True.- tol
float
, optional Tolerance allowed in the
inside-triangle check
. Default is0
.
- p
- Returns:
numpy.ndarray
ofbools
An array of boolean values indicating which points in
p
are inside the hull, same shape asp
. Each entry isTrue
if the corresponding point is inside the hull (or on the border, ifborder=True
), andFalse
otherwise.
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])