Celestial Programming : Angle Between Two RA/Dec Points

Given two RA/Dec coordinates \( \alpha_1, \delta_1 \) and \(\alpha_2 , \delta_2 \), the angular separation between the two bodies can be calculated using the equations below. This method is taken from Meeus' Astronomical Algorithms, but credited to Thierry Pauwels of the Royal Observatory of Belgium.







$$ \begin{align*} x &= \cos\delta_1 \sin\delta_2 - \sin\delta_1 \cos\delta_2 \cos(\alpha_2 - \alpha_1) \\ y &= \cos\delta_2 \sin(\alpha_2 - \alpha_1) \\ z &= \sin\delta_1 \sin\delta_2 + \cos\delta_1 \cos\delta_2 \cos(\alpha_2 - \alpha_1) \\ \tan \theta &= \frac{\sqrt{x^2 + y^2}}{z} \end{align*} $$