I am basically asking for some help in considering the CAST method for cosine, but have put my situation into context:
Consider a field of galaxies in the Cartesian coordinate system, as outlined in the figure.
The dot is the position of a given galaxy, and the cross represents the position of the centre of the field, which remains fixed.
The galaxy has position $(g_1, g_2)$, and the centre of the field has position $(x_{mid}, y_{mid})$.
In my particular case, I have 28,000 galaxies and I am trying to locate the angular position of each, $\phi\in [0, 2\pi]$. For example, in this case the galaxy would have angular position $\pi/4$.
I am having trouble taking into consideration the sign of cosine when doing this - probably a really simple problem that just doesn't fix itself in my head very well!
So when writing my code to do this I need to consider the quadrant in which the galaxy sits in order to correctly calculate its angular position.
My first observation is that:
If $g_2-y_{mid}<0,$ then $\phi = -\arccos{\Big(\frac{g_1-x_{mid}}{d}}\Big)+2\pi$, where $d$ is the distance from the centre of the field to said galaxy.
Is this correct? How can I correctly take into consideration the rest of the quadrant positions of the galaxies?
