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.

# I. CALCULATE CENTER EARTH-MOON DISTANCE IN KM

In order to calculate the geocentric parallax angle in SECTION II, we first need to understand how far the center of the Earth is located from the center of the Moon at any point in time.
Just like in the previous tutorial, we use Meeus' method of linear combination of fundamental arguments with the help of a table. Once the sum of ∑r has been obtained, use the following formulate to calculate the distance Earth-Moon in kilometers:
``````
△ = 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.

# II. CALCULATE MOON HORIZONTAL PARALLAX ANGLE

Peter Duffett-Smith states that the geocentric parallax angle is the angle between the Observer and the Earth's centre as seen by the Moon. For additional information see the PARALLAX section in the GLOSSARY.
With the Earth-Moon distance △ calculated in SECTION I you can acquire the geocentric parallax π using the following formula (up to 1°):
``````
sin π = 6378.14 / △
``````

# III. CALCULATE GREENWICH & LOCAL SIDEREAL TIME

For later caculations, we need to take the Julian input day (JD) and convert it to Greenwich mean Sidereal Time (GST). According to Peter Duffett-Smith, GST can be used for observations made for the Greenwich meridian. The Greenwich meridian is also known as "The Prime Meridian". The Greenwich meridian is the arbitrary point chosen in the year 1884 at which the longitude on Earth is defined to be 0°. Meridians are the imaginary lines of longitude that run between the North and South Poles and encircle the earth. Greenwich is located in a neighborhood in Londen, UK.

Once we've acquired GST, we can use it to calculate Local Sidereal Time (LST) to adjust the time for the location of the observer (either West or East of the 0° meridian):
• Convert Julian Day (JD) to Greenwich mean Sidereal Time (GST)
• Convert Greenwich mean Sidereal Time (GST) to Local Sidereal Time (LST)

# IV. CALCULATE GEOCENTRIC HOUR ANGE

Using the LST value from the previous section and the Moon's Geocentric Right Ascension (R.A.) from the last tutorial, we can now calculate the geocentric hour angle using the following formula (Meeus):
``````
H = LST - Lunar Geocentric Right Ascension
``````

# V. CALCULATE CENTER EARTH-OBSERVER DISTANCE

Now we need to know the quantities p sin Φ' and p cos Φ'. These can be calculated using the formula's shown below. Note that p is the distance from the center of the Earth to the observer, Φ' is the geocentric latitude and Φ is the astronomical latitude.
``````
u = atan (0.996647 * tan Φ)
p sin Φ' = (0.996647 * sin u) + ((observer altitude / 6378140) * sin Φ)
p cos Φ' = (cos u) + ((observer altitude / 6378140) * cos Φ)
``````

# VI. CALCULATE TOPOCENTRIC R.A. & DECLINATION

Finally we can combine all the work we've done so far and obtain the Topocentric RIGHT ASCENSION (R.A.) and DECLINATION.
Note that these formula's use the Moon's Geocentric Right Ascension (R.A.) and Declination from the last tutorial.
``````
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)
``````

# VII. COMPLETE JS LUNAR EPHEMERIS SIMULATOR

The finished simulation on the right shows not only the calculated values for Topocentric RIGHT ASCENSION and DECLINATION for an observer located on Palomar Mountain, but also demonstrates how the Moon moves across the sky over time.

Get the full JavaScript source code HERE.

You can also verify the RIGHT ASCENSION and DECLINATION values using NASA's HORIZONS Web-Interface. Make sure to set the Observer Location to the appropriate Topocentric location for comparison.