Post Reply 
Phase of the Moon
06-24-2017, 02:30 AM
Post: #1
Phase of the Moon
The following program calculates the approximate phase of the moon. Calculation is based on the following:

1. A base date of August 11, 1999 is used, which was a New Moon.
2. The phases of the moon cycles approximately 29.530588853 days

The results is a phase indicator from 0 to 1.

If the indicator is close to 0 or 1, we have a New Moon.
If the indicator above 0 but below 0.5, it’s the Waxing Crescent Moon.
If the indicator is about or exactly 0.5, we have a Full Moon.
Finally, for an indicator from 0.5 to 1, it’s the Waning Crescent Moon.

Examples:
June 23, 2017: the indicator is 0.991190947
June 24, 2017: the indicator is 0.025054136

Values are approximate.

HP Prime Program: MOONPHASE

Input: MOONPHASE(yyyy.mmdd)
Code:

EXPORT MOONPHASE(d)
BEGIN
// Moon phase
// 0,1: New; 0.5: Full
LOCAL t,p;
t:=DDAYS(1999.0811,d);
p:=FP(t/29.530588853);
RETURN p;
END;

Source: “Moon Phase” voidware.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)