Computing the angle in interval $[0,2\pi)$ between points on great circle

77 Views Asked by At

I'm trying to find a way to compute the angle that subtends the cartesian unit vector in the x direction $(1,0,0)$ and some arbitrary point on a unit sphere with spherical coordinates $(\phi,\theta)$ ($\phi$ and $\theta$ are the azimuthal and polar coordinates, respectively.) I want this angle to be in the interval $[0,2\pi)$. Let's call this angle $\omega$. For further clarity, $\omega$ is defined such that when $\phi = n\pi/2$ for $n = 0,1,2,3$, then $\omega = \phi$, and $\omega$ increases as you move around the sphere in the counter-clockiwse direction. I know that from properties of the dot/cross products and their relationship to the angle between the vectors in question that $$\cos(\omega) = \cos(\phi)sin(\theta)$$ and $$sin(\omega) = \sqrt{sin^2(\phi)sin^2(\theta)+cos^2(\theta)}$$. To get $\omega$ I tried inverting these functions and also tried to use $$\omega = arctan2(\sqrt{sin^2(\phi)sin^2(\theta)+cos^2(\theta)}/\cos(\phi)sin(\theta))$$, but they don't get me the correct values of omega. I was trying to think of a way to construct a piecewise relation with one of these inverse trig functions so that if $\phi \geq \pi$, which means that $\omega \geq \pi$, then I would add on $\pi$ to the output of the inverse trig function to get the correct value of omega. I'm wondering if this is the right idea to go about this or if there is a better way?

1

There are 1 best solutions below

0
On

As mentioned in your last paragraph, $\omega$ can be defined piecewise, depending on the azimuthal angle $\phi$. Though not exactly an addition of $\pi$, but

$$\begin{align*} \cos\omega = \cos(2\pi-\omega) &= \cos\phi\sin\theta\\ \omega &= \begin{cases}\arccos(\cos\phi\sin\theta)& \phi< \pi\\ 2\pi - \arccos(\cos\phi\sin\theta)& \phi > \pi \end{cases} \end{align*}$$

When $\phi = \pi$, $\omega$ may not be continuous, and may not be exactly $\phi$ (as suggested in your "For further clarity" clarification). Which side should $\omega$ match is up to you.