Skip to content

Commit b1ec59f

Browse files
committed
Address code review
1 parent a0414e3 commit b1ec59f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/utils/UnitSpherical/cap.jl

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ SphericalCap(t::GI.PointTrait, geom) = SphericalCap(t, geom, 0)
2525
# TODO: exact-predicate intersection
2626
# This is all inexact and thus subject to floating point error
2727
function _intersects(x::SphericalCap, y::SphericalCap)
28-
spherical_distance(x.point, y.point) <= max(x.radius, y.radius)
28+
spherical_distance(x.point, y.point) <= x.radius + y.radius
2929
end
3030

3131
_disjoint(x::SphericalCap, y::SphericalCap) = !_intersects(x, y)
3232

3333
function _contains(big::SphericalCap, small::SphericalCap)
3434
dist = spherical_distance(big.point, small.point)
35-
return dist < big.radius #=small.point in big=# &&
36-
dist + small.radius < big.radius # small circle fits in big circle
35+
# small circle fits in big circle
36+
return dist + small.radius < big.radius
3737
end
3838

39-
4039
function circumcenter_on_unit_sphere(a::UnitSphericalPoint, b::UnitSphericalPoint, c::UnitSphericalPoint)
4140
LinearAlgebra.normalize(a × b + b × c + c × a)
4241
end

src/utils/UnitSpherical/point.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ spherical_distance(x::UnitSphericalPoint, y::UnitSphericalPoint) = acos(clamp(x
125125
# ## Random points
126126
Random.rand(rng::Random.AbstractRNG, ::Random.SamplerType{UnitSphericalPoint}) = rand(rng, UnitSphericalPoint{Float64})
127127
function Random.rand(rng::Random.AbstractRNG, ::Random.SamplerType{UnitSphericalPoint{T}}) where T <: Number
128-
θ = 2π * rand(rng, T)
129-
ϕ = acos(2 * rand(rng, T) - 1)
128+
ϕ = 2π * rand(rng, T)
129+
θ = acos(2 * rand(rng, T) - 1)
130130
sinθ, cosθ = sincos(θ)
131131
sinϕ, cosϕ = sincos(ϕ)
132132
return UnitSphericalPoint(

0 commit comments

Comments
 (0)