Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pyalphashape/AlphaShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ def contains_point(self, pt: np.ndarray, tol: float = 1e-8) -> bool:
True if the point lies inside or on the alpha shape; False otherwise.

"""
assert (
self._delaunay is not None
), "Delaunay triangulation must be performed first"
if self._delaunay is None or self.perimeter_points is None:
return False

# fast hull‐check
simplex_idx = self._delaunay.find_simplex(pt)
if simplex_idx < 0:
Expand Down
4 changes: 4 additions & 0 deletions unit_tests/test_AlphaShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def test_alpha_shape_basic_perimeter():
assert len(alpha_shape.perimeter_points) > 0
assert isinstance(alpha_shape.perimeter_edges, list)

def test_contains_point_incomplete():
points = np.array([[0, 0], [1, 0]])
shape = AlphaShape(points, alpha=0.0)
assert not shape.contains_point(np.array([0.5, 0.5]))

def test_contains_point_inside():
points = np.array([[0, 0], [1, 0], [0.5, 1]])
Expand Down