Skip to content

Commit

Permalink
Update parameterization implementation of Ball and Sphere (#1097)
Browse files Browse the repository at this point in the history
* Update parameterization implementation of 'Ball' and 'Sphere'

* Apply suggestions
  • Loading branch information
eliascarv authored Oct 4, 2024
1 parent c6c7f4d commit 3dac1fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
21 changes: 9 additions & 12 deletions src/geometries/primitives/ball.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ function (b::Ball{𝔼{2}})(ρ, φ)
end
c = b.center
r = b.radius
l = T(ρ) * r
sφ, cφ = sincospi(2 * T(φ))
x = l *
y = l *
c + Vec(x, y)
ρ′ = T(ρ) * r
φ′ = T(φ) * 2 * T(π) * u"rad"
p = Point(convert(crs(b), Polar(ρ′, φ′)))
p + to(c)
end

function (b::Ball{𝔼{3}})(ρ, θ, φ)
Expand All @@ -57,11 +56,9 @@ function (b::Ball{𝔼{3}})(ρ, θ, φ)
end
c = b.center
r = b.radius
l = T(ρ) * r
sθ, cθ = sincospi(T(θ))
sφ, cφ = sincospi(2 * T(φ))
x = l **
y = l **
z = l *
c + Vec(x, y, z)
ρ′ = T(ρ) * r
θ′ = T(θ) * T(π) * u"rad"
φ′ = T(φ) * 2 * T(π) * u"rad"
p = Point(convert(crs(b), Spherical(ρ′, θ′, φ′)))
p + to(c)
end
17 changes: 7 additions & 10 deletions src/geometries/primitives/sphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ function (s::Sphere{𝔼{2}})(φ)
end
c = s.center
r = s.radius
sφ, cφ = sincospi(2 * T(φ))
x = r *
y = r *
c + Vec(x, y)
φ′ = T(φ) * 2 * T(π) * u"rad"
p = Point(convert(crs(s), Polar(r, φ′)))
p + to(c)
end

function (s::Sphere{𝔼{3}})(θ, φ)
Expand All @@ -93,10 +92,8 @@ function (s::Sphere{𝔼{3}})(θ, φ)
end
c = s.center
r = s.radius
sθ, cθ = sincospi(T(θ))
sφ, cφ = sincospi(2 * T(φ))
x = r **
y = r **
z = r *
c + Vec(x, y, z)
θ′ = T(θ) * T(π) * u"rad"
φ′ = T(φ) * 2 * T(π) * u"rad"
p = Point(convert(crs(s), Spherical(r, θ′, φ′)))
p + to(c)
end

0 comments on commit 3dac1fe

Please sign in to comment.