This tutorial explains how to calculate geocentric 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 as well as show the percentage of the illuminated disc.
This tutorial is unrelated to the first three tutorials in the series, and can be followed independently.
However, the orbit of the Moon is perturbed by the Sun and Earth which requires various corrections.
If you haven't followed the third tutorial yet for calculating the Epheremis for the Sun and the Planets, we recommend you do that first: TUTORIAL - EPHEMERIS PLANETS
Credits for all calculations go to Jean Meeus, as this example was taken directly from his book Astronomical Algorithms.
If you have the book at hand, you can follow along in Chapter 47 (Position of the Moon).
I. CALCULATE CENTURIES SINCE EPOCH J2000.0
All calculations in this tutorial are based on the J2000.0 epoch (JD = 2451545). The value of time "T" is measured in Julian centuries since the Epoch J2000.0.
For a refresher on how to convert a Gregorian Date to a Julian Date, see our first tutorial: TUTORIAL - PLANETS
Once you have converted the desired Julian Ephemeris Day, use this formula to calculate time "T":
//Time "T" is centuries since J2000.0T = (Julian Ephemeris Day - 2451545) / 36525
II. CALCULATE MOON & SUN ANGLES
Now that we know the value T, we can calculate the following angles (taken from Meeus):
To calculate the Moon's Latitude and Longitude, the angles calculated in SECTION II
are used in a so-called "linear combination" using a table of periodic terms. A linear combination represents the sum of the fundamental arguments D, M, M' & F with a coefficent placed in front of it as a multiplier.
Next to that, some of these terms also require the Earth's eccentricity of its orbit around the Sun:
For a detailed understanding of the table with periodic terms and the precise calculation, please refer to the SOURCE CODE for more information (see calculateMoon_LUNAR() function).
After calculating the periodic terms for the Moon, several "additive terms" are applied (A1, A2 & A3). The last step is to calculate the coordinates of the Moon using the following formula's (taken from Meeus):
//Geocentric Longitude Moonλ = L' + ∑l / 1000000
//Geocentric Latitude Moonβ = L' + ∑b / 1000000
IV. CALCULATE LONGITUDE & OBLIQUITY NUTATION
To get a more accurate value for the Moon's position, we need to take into account the phenomenon of nutation. For additional information see the NUTATION section in the GLOSSARY.
This nutation adjustment will be applied to the Moon's Longitude (λ) and the Obliquity of the Ecliptic (ε).
The values for △ψ (nutation in longitude) and △ε (nutation in obliquity) are again calculated using linear combination with a table of periodic terms. Please refer again to the SOURCE CODE for details.
V. CALCULATE MEAN & TRUE OBLIQUITY
We first need to calculate the MEAN OBLIQUITY. The formula is:
The TRUE OBLIQUITY (ε) is then acquired by adding the OBLIQUITY NUTATION (△ε) from SECTION IV:
ε = ε0 + △ε
VI. CONVERT ECLIPTIC TO EQUATORIAL COORDS.
Now use the following formula's to convert the ecliptical coordinates calculated in SECTION III and corrections from SECTION IV and SECTION V into equatorial coordinates to acquire the RIGHT ASCENSION & DECLINATION:
tan α = ((sin λ * cos ε) - (tan β * sin ε)) / (cos λ) //RIGHT ASCENSIONsin δ = (sin β * cos ε) + (cos β * sin ε * sin λ) //DECLINATION
VII. SIMULATOR ACCURACY
To get a better idea of the accuracy of this method to calculate the position of the moon, the results are plotted against NASA's HORIZONS Web-Interface for the year 2025.
The graph displays the error in degrees for both the RIGHT ASCENSION and DECLINATION.
This error translates roughly to a maximum of 3 minutes for RIGHT ASCENSION and 9 minutes for DECLINATION.
VIII. CALCULATE ILLUMINATED FRACTION OF DISK
Using the Moon and Sun angles calculated in SECTION II, we can also calculate the Moon's illuminated fraction.