This tutorial explains how to calculate topocentric RIGHT ASCENSION (R.A.) & DECLINATION for the Moon.
The JS simulation will also use these calculated coordinates to plot the Moon on the Celestial Sphere. The example code locates the observer at the Palomar Observatory. If desired, you can adjust the location in the SOURCE CODE.
This tutorial builds further upon the fourth tutorial in the series.
Therefore if you haven't followed the fourth tutorial yet for calculating the geocentric Epheremis for the Moon, we recommend you do that first:
TUTORIAL - EPHEMERIS MOON (GEOCENTRIC)
Credits for the calculations go to Jean Meeus & Peter Duffett-Smith.
△ = 385000.56 + (∑r / 1000) //Distance Earth-Moon given in kilometers
For more information on calculating the sum ∑r, please refer back to SECTION III of the last tutorial or see the source code for this tutorial located HERE.
sin π = 6378.14 / △
H = LST - Lunar Geocentric Right Ascension
u = atan (0.996647 * tan Φ)
p sin Φ' = (0.996647 * sin u) + ((observer altitude / 6378140) * sin Φ)
p cos Φ' = (cos u) + ((observer altitude / 6378140) * cos Φ)
tan △RIGHT_ASCENSION = (-(p cos Φ') * sin π * sin H) / (cos GEO_DECLINATION - (p cos Φ') * sin π * cos H)
TOPO_RIGHT ASCENSION = GEO_RIGHT_ASCENSION + △RIGHT_ASCENSION
tan TOPO_DECLINATION = ((sin GEO_DECLINATION - (p sin Φ') * sin π) * cos △RIGHT_ASCENSION) / (cos GEO_DECLINATION - (p cos Φ') * sin π * cos H)