Moon phase = degrees. | |
Above is a table of the current Moon phase along with predictions of the next four quarters of the Moon's orbit. It is updated every second.
This is a sample page for the open-source Astronomy Engine. All of the source code and documentation is available there. Also, try using your browser's View Source command to look at how this page works.
The phases of the Moon are calculated using relative ecliptic longitudes. This means that the Moon's position is measured as an angle away from the Sun counterclockwise as seen from above the Earth's north pole. This is the same direction as the Moon orbits the Earth.
The angle is defined along the ecliptic plane, which is the plane of the Earth's orbit around the Sun. The Moon does not stay within this plane, so its position above or below the ecliptic plane is ignored for the sake of calculating phases. This is the way almanacs and calendars historically have reported the dates and times of moon phases.
The phase angle increases from 0 degrees to 360 degrees over the span of each synodic month. Certain values of the phase angle define the four lunar quarters:
In your own code, to calculate the Moon's current phase angle, call
the function Astronomy.MoonPhase
.
To predict upcoming lunar quarter phases, call
Astronomy.SearchMoonQuarter
passing in a Date object to find the first quarter phase after that date and time.
Then if you want, you can call
Astronomy.NextMoonQuarter
in a loop to iterate over the next consecutive quarter phases.
Each time, you pass the return value of the previous function call as the argument
to Astronomy.NextMoonQuarter
so it knows where to resume the search.
Here is an example that finds the next 100 lunar quarter phases:
let date = new Date();
let mq = Astronomy.SearchMoonQuarter(date);
console.log(mq.quarter, mq.time.date);
for (let i=1; i < 100; ++i) {
mq = Astronomy.NextMoonQuarter(mq);
console.log(mq.quarter, mq.time.date);
}