Solution (source code)

= Solution

Use the <gnomonic projection> associated with an undistorted <focal plane>. Write $\Delta=\alpha-A$ and rotate the celestial <Cartesian coordinate system> so that the pointing meridian has longitude zero. The stellar direction and an <orthonormal basis> adapted to the <optical axis> are
$$
\mathbf s=(\cos\delta\cos\Delta,\cos\delta\sin\Delta,\sin\delta),\quad
\mathbf b=(\cos D,0,\sin D),\quad
\mathbf e=(0,1,0),\quad
\mathbf n=(-\sin D,0,\cos D).
$$
Here $\mathbf e$ points east and $\mathbf n$ points north. Intersect the ray $t\mathbf s$ with the plane $\mathbf x\cdot\mathbf b=f$. It gives $t=f/(\mathbf s\cdot\mathbf b)$, so the detector coordinates are
$$
\xi=f\frac{\cos\delta\sin\Delta}{\cos\delta\cos\Delta\cos D+\sin\delta\sin D},\qquad
\eta=f\frac{\sin\delta\cos D-\cos\delta\cos\Delta\sin D}{\cos\delta\cos\Delta\cos D+\sin\delta\sin D}.
$$
These equations also avoid spurious singularities caused by writing individual tangents or cotangents.

To put this <gnomonic projection> in the desired form, let $\rho=(\cos^2\delta\cos^2\Delta+\sin^2\delta)^{1/2}$ and choose $q$ locally by
$$
\rho\cos q=\cos\delta\cos\Delta,\qquad \rho\sin q=\sin\delta.
$$
Thus $\cot q=\cot\delta\cos\Delta$. The denominator becomes $\rho\cos(q-D)$, the numerator for $\eta$ becomes $\rho\sin(q-D)$, and $\cos\delta\sin\Delta=\rho\cos q\tan\Delta$. Consequently
$$
\boxed{\xi=f\frac{\cos q\tan(\alpha-A)}{\cos(q-D)},\qquad \eta=f\tan(q-D).}
$$
Use the local meridian chart $\cos\Delta>0$, with $q\in[-\pi/2,\pi/2]$ chosen continuously near $D$ and $q=D$ at the image centre. A visible <gnomonic projection> requires $\mathbf s\cdot\mathbf b>0$, but this front-hemisphere condition alone does not select that meridian chart. A narrow field near a celestial pole can cross the opposite meridian; for such fields use the Cartesian expressions above and distinguish the oriented <great circle> parameter from ordinary <declination>. In particular, the small-field limit is $\xi\simeq f\cos D(\alpha-A)$ and $\eta\simeq f(\delta-D)$, with angles in radians. The factor $\cos D$ is the shrinking angular distance per unit <right ascension> near the pole.