From celestial to projection plane coordinates

The angular distance $\theta$ and the position angle $p$ are defined by the spherical trigonometry relations:

$\displaystyle \cos\theta$ $\displaystyle =$ $\displaystyle \sin\delta\sin\delta_0 + \cos\delta\cos\delta_0\cos\Delta\alpha$ (36)
$\displaystyle \sin\theta \sin p$ $\displaystyle =$ $\displaystyle \cos\delta\sin\Delta\alpha$ (37)
$\displaystyle \sin\theta \cos p$ $\displaystyle =$ $\displaystyle \sin\delta\cos\delta_0 - \cos\delta\sin\delta_0\cos\Delta\alpha$ (38)

Equations [*], [*] and [*] are the AIPS memo 46 Eq. 3, 4, and 5. These 3 quantities are the coordinates of the unit vector pointing to $(\alpha,\delta)$, expressed in the orthonormal basis (East, North, reference point direction) attached to the reference point. Their squares sum to 1. Since $\theta$ is an angular distance, it is restricted to $0 \le \theta \le \pi$, i.e. $\sin\theta \ge 0$9:
$\displaystyle \theta$ $\displaystyle =$ atan2$\displaystyle \left(\sqrt{(\sin\theta\sin p)^2+(\sin\theta\cos p)^2},\cos\theta\right)$ (39)
$\displaystyle p$ $\displaystyle =$ atan2$\displaystyle (\sin\theta\sin p,\sin\theta\cos p)$ (40)

The position angle $p$ is undefined at the reference point and at its antipode ( $\sin\theta = 0$). The stereographic projection then defines the distance in the projection plane as (AIPS memo 46 section 2.1.2, and STG projection in CG02 section 5.1):

$\displaystyle r = 2\tan\frac{\theta}{2}
= \frac{2\sin\theta}{1+\cos\theta}
= \frac{2(1-\cos\theta)}{\sin\theta}$ (41)

and the projection plane coordinates are:
$\displaystyle x$ $\displaystyle =$ $\displaystyle r\sin(p+\psi)$ (42)
$\displaystyle y$ $\displaystyle =$ $\displaystyle r\cos(p+\psi)$ (43)

The main properties of this projection are: