I need to simplify my Spherical Coordinate Representation in order to get a unique representation of the point. I'm using $r$ for radius, $\theta$ for elevation, and $\phi$ for azimuthal angle (Physics convention).
To get a unique representation of any point in the space, I know I need to apply some constraints: $r \in [0, \infty)$, $\theta \in [0, \pi]$ and $\phi \in [0, 2\pi)$.
While it's very straightforward for $\phi$ (it's just $\phi\gets\operatorname{mod}(\phi, 2\pi)$), and I figured it out for $\theta$, I can't correctly simplify $r<0$.
This is what I am doing:
function simplify(r, θ, ϕ)
θ = mod(θ, 2π)
if θ > π
θ = 2π - θ
ϕ += π
end
ϕ = mod(ϕ, 2π)
return r, θ, ϕ
end
While this works, it doesn't guarantee $r\in[0,\infty)$ (of course, I didn't implement it). How can I apply this last restriction?
Hint: antipodal points on a sphere are related by $(-r, \theta, \phi) = (r, \pi - \theta, \pi + \phi)$.