0
$\begingroup$

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?

enter image description here

1 Answers 1

1

Set $dx=g_1-x_{mid}$, $dy=g_2-y_{mid}$ and $d=\sqrt{dx^2+dy^2}$. If $d=0$ you must decide which angle to allocate (I suggest $\phi = 0$). Otherwise calculate $$\phi = arccos(\frac{dx}{d})$$

This takes care of the first and second quadrant where $arccos$ has its principal values. However, if $dy \lt 0$ then you are in the third or fourth quadrant and need to do the following adjustment $$\phi = 2\pi - \phi$$

That's it.