In LUNEX, the phases are treated as following an endless circular cycle, like a clock, from 0 to 360 degrees with the quarter moon phases occuring when the sun is at the four 90-degree points along the phase circle.
The camera/eye is fixed between the sun and moon at mean lunar distance while the sun slowly moves clockwise around the phase circle. The angular position of the sun along the phase circle is the lunar phase angle, where zero is directly forward, producing the new moon phase, 90 degrees is directly to the right, producing the first quarter phase, etc..
Lunar Phase Phase Angle
------------- -----------
New Moon 0° / 360°
First Quarter 90°
Full Moon 180°
Last Quarter 270°
Given the geocentric ecliptical longitudes of the sun and moon at the same moment, the simple lunar
phase angle at the same moment can be computed to sufficient visual precision from a simple algorithm.
Let:
Ls = Geocentric Ecliptical Longitude of Sun (0 to 360°)
Lm = Geocentric Ecliptical Longitude of Moon (0 to 360°)
PA = Geocentric Lunar Phase Angle (0 to 360°)
Then:
a = 360 − Lm + Ls
if (a > 360) {a = a − 360}
PA = 360 − a
or:
a = 360 − Lm + Ls
PA = 360 − a −= (a > 360)? 360:0