From projection plane to celestial coordinates

For each point, the rotation by the projection angle is first removed (variables xr and yr):

$\displaystyle x'$ $\displaystyle =$ $\displaystyle x\cos\psi - y\sin\psi \quad (=r\sin p)$ (58)
$\displaystyle y'$ $\displaystyle =$ $\displaystyle y\cos\psi + x\sin\psi \quad (=r\cos p)$ (59)

Since $\tan(\theta/2) = r/2$, the trigonometric functions of $\theta$ are rational functions of $r$:

$\displaystyle \sin\theta = \frac{4r}{4+r^2}$   and$\displaystyle \quad
\cos\theta = \frac{4-r^2}{4+r^2}$ (60)

Injecting them in the spherical trigonometry relations of section [*] gives the cartesian coordinates of the point on the celestial sphere, scaled by the positive factor $4+r^2$ (variables rho2, cx, cy, and cz):
$\displaystyle r^2$ $\displaystyle =$ $\displaystyle x'^2 + y'^2$ (61)
$\displaystyle c_x$ $\displaystyle =$ $\displaystyle 4x' \quad (= (4+r^2)\cos\delta\sin\Delta\alpha)$ (62)
$\displaystyle c_y$ $\displaystyle =$ $\displaystyle \cos\delta_0(4-r^2) - 4\sin\delta_0 y' \quad (= (4+r^2)\cos\delta\cos\Delta\alpha)$ (63)
$\displaystyle c_z$ $\displaystyle =$ $\displaystyle \sin\delta_0(4-r^2) + 4\cos\delta_0 y' \quad (= (4+r^2)\sin\delta)$ (64)

The scaling factor cancels in the atan2 functions, and the celestial coordinates are:
$\displaystyle \delta$ $\displaystyle =$ atan2$\displaystyle \left(c_z,\sqrt{c_x^2+c_y^2}\right)$ (65)
$\displaystyle \alpha$ $\displaystyle =$ $\displaystyle \alpha_0 +$   atan2$\displaystyle (c_x,c_y)$ (66)

where $\sqrt{c_x^2+c_y^2}$ is computed with the Fortran intrinsic function hypot (variable cxy). At the celestial poles ( $c_x = c_y = 0$), the right ascension is undefined and is set to $\alpha_0$. The reasons for this formulation are: