Skip to content

Commit

Permalink
Add fallback method for Base.in predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Dec 26, 2023
1 parent 6d56ab4 commit 3e3a95a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/predicates/in.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Tells whether or not the `point` is in the `geometry`.
"""
function Base.in(::Point, ::Geometry) end
Base.in(p::Point, g::Geometry) = sideof(p, boundary(g)) == IN

Base.in(p₁::Point, p₂::Point) = p₁ == p₂

Expand Down
8 changes: 8 additions & 0 deletions test/predicates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
@test isconvex(b)
end

@testset "in" begin
h = first(CartesianGrid{T}(10, 10, 10))
@test P3(0, 0, 0) h
@test P3(0.5, 0.5, 0.5) h
@test P3(-1, 0, 0) h
@test P3(0, 2, 0) h
end

@testset "issubset" begin
point = P2(0.5, 0.5)
box = Box(P2(0, 0), P2(1, 1))
Expand Down

0 comments on commit 3e3a95a

Please sign in to comment.