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).
//Time "T" is centuries since J2000.0
T = (Julian Ephemeris Day - 2451545) / 36525
L' = 218.3164477 + (481267.88123421 * T) - (0.0015786 * Math.pow(T,2)) + (Math.pow(T,3) / 538841) - (Math.pow(T,4) / 65194000);
D = 297.8501921 + (445267.1114034 * T) - (0.0018819 * Math.pow(T,2)) + (Math.pow(T,3) / 545868) - (Math.pow(T,4) / 113065000);
M = 357.5291092 + (35999.0502909 * T) - (0.0001536 * Math.pow(T,2)) + (Math.pow(T,3) / 24490000);
M' = 134.9633964 + (477198.8675055 * T) + (0.0087414 * Math.pow(T,2)) + (Math.pow(T,3) / 69699) - (Math.pow(T,4) / 14712000);
F = 93.2720950 + (483202.0175233 * T) - (0.0036539 * Math.pow(T,2)) - (Math.pow(T,3) / 3526000) + (Math.pow(T,4) / 863310000);
Ω = 125.04452 - (1934.136261 * T) + (0.0020708 * Math.pow(T,2)) + (Math.pow(T,3) / 450000);
E = 1 - (0.002516 * T) - (0.0000074 * Math.pow(T,2));
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).
//Geocentric Longitude Moon
λ = L' + ∑l / 1000000
//Geocentric Latitude Moon
β = L' + ∑b / 1000000
ε0 = 23.43929 - (0.01300417 * T) - (0.0000001638889 * Math.pow(T,2)) - (0.0000005036111 * Math.pow(T,3));
The TRUE OBLIQUITY (ε) is then acquired by adding the OBLIQUITY NUTATION (△ε) from SECTION IV:
ε = ε0 + △ε
tan α = ((sin λ * cos ε) - (tan β * sin ε)) / (cos λ) //RIGHT ASCENSION
sin δ = (sin β * cos ε) + (cos β * sin ε * sin λ) //DECLINATION
function calculateMoonIlluminatedFraction(){
i = 180 - moonMeanElongation - (6.289 * Math.sin(moonMeanAnomaly)) + (2.100 * Math.sin(sunMeanAnomaly))
- (1.274 * Math.sin(2*moonMeanElongation - moonMeanAnomaly)) - (0.658 * Math.sin(2 * moonMeanElongation))
- (0.214 * Math.sin(2 * moonMeanAnomaly)) - (0.110 * Math.sin(moonMeanElongation));
k = (1 + Math.cos(i)) / 2;
return k;
}
Since the phase of the Moon is identical all around the world, you can use this function to figure out the next full Moon.