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: 4 additions & 2 deletions src/utils/UnitSpherical/cap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ _disjoint(x::SphericalCap, y::SphericalCap) = !_intersects(x, y)

function _contains(big::SphericalCap, small::SphericalCap)
dist = spherical_distance(big.point, small.point)
# small circle fits in big circle
return dist + small.radius < big.radius
# small circle fits in big circle; `<=` so internally-tangent small
# caps count as contained, matching the point overload below and
# S2's `S2Cap::Contains(const S2Cap&)` convention.
return dist + small.radius <= big.radius
end
function _contains(cap::SphericalCap, point::UnitSphericalPoint)
spherical_distance(cap.point, point) <= cap.radius
Expand Down
2 changes: 1 addition & 1 deletion test/utils/unitspherical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ end
# Test containment
big_cap = SphericalCap(UnitSphericalPoint(1.0, 0.0, 0.0), π/2)
small_cap = SphericalCap(UnitSphericalPoint(1/√2, 1/√2, 0.0), π/4)
@test_broken UnitSpherical._contains(big_cap, small_cap)
@test UnitSpherical._contains(big_cap, small_cap)
@test !UnitSpherical._contains(small_cap, big_cap)
end

Expand Down
Loading