99// by Cyrus Rahman, this work is subject to Stephen Schmitt's copyright:
1010//
1111// Copyright 2004 Stephen R. Schmitt
12- // Subsequent work Copyright 2020 Cyrus Rahman
12+ // Subsequent work Copyright 2020-2026 Cyrus Rahman
1313// You may use or modify this source code in any way you find useful, provided
14- // that you agree that the author(s) have no warranty, obligations or liability.
15- // You must determine the suitability of this source code for your use.
16-
17- #include " MoonPhase.h"
14+ // that you agree that the author(s) have no warranty, obligations or liability. You
15+ // must determine the suitability of this source code for your use.
1816
1917#include < math.h>
18+ #include " MoonPhase.h"
2019
2120// Names of lunar phases
2221static const char *phaseNames[] = {" New" , " Evening Crescent" , " First Quarter" ,
23- " Waxing Gibbous" , " Full" , " Waning Gibbous" ,
24- " Last Quarter" , " Morning Crescent" };
22+ " Waxing Gibbous" , " Full" , " Waning Gibbous" ,
23+ " Last Quarter" , " Morning Crescent" };
2524// Names of Zodiac constellations
2625static const char *zodiacNames[] = {" Pisces" , " Aries" , " Taurus" , " Gemini" , " Cancer" ,
27- " Leo" , " Virgo" , " Libra" , " Scorpio" , " Sagittarius" ,
28- " Capricorn" , " Aquarius" };
26+ " Leo" , " Virgo" , " Libra" , " Scorpio" , " Sagittarius" ,
27+ " Capricorn" , " Aquarius" };
2928// Ecliptic angles of Zodiac constellations
3029static const float zodiacAngles[] = {33.18 , 51.16 , 93.44 , 119.48 , 135.30 , 173.34 ,
31- 224.17 , 242.57 , 271.26 , 302.49 , 311.72 , 348.58 };
30+ 224.17 , 242.57 , 271.26 , 302.49 , 311.72 , 348.58 };
3231
3332// Constructor initialization.
3433MoonPhase::MoonPhase () {
@@ -39,7 +38,8 @@ MoonPhase::MoonPhase() {
3938 distance = 0 ;
4039 latitude = 0 ;
4140 longitude = 0 ;
42- phaseName = zodiacName = " " ;
41+ phaseName = phaseNames[0 ];
42+ zodiacName = zodiacNames[0 ];
4343}
4444
4545// Determine the Moon Phase and orbital positions for the specified time.
@@ -62,8 +62,8 @@ MoonPhase::calculate(time_t t) {
6262 double distancePhase = (jDate - MOON_DISTANCE_OFFSET ) / MOON_DISTANCE_PERIOD ;
6363 distancePhase -= floor (distancePhase);
6464 distance = 60.4 - 3.3 * cos (2 * M_PI * distancePhase)
65- - 0.6 * cos (2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
66- - 0.5 * cos (2 * 2 * M_PI * phase);
65+ - 0.6 * cos (2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
66+ - 0.5 * cos (2 * 2 * M_PI * phase);
6767
6868 // Calculate ecliptic latitude from nodal (draconic) phase.
6969 double latPhase = (jDate - MOON_LATITUDE_OFFSET ) / MOON_LATITUDE_PERIOD ;
@@ -74,15 +74,15 @@ MoonPhase::calculate(time_t t) {
7474 double longPhase = (jDate - MOON_LONGITUDE_OFFSET ) / MOON_LONGITUDE_PERIOD ;
7575 longPhase -= floor (longPhase);
7676 longitude = 360 * longPhase
77- + 6.3 * sin (2 * M_PI * distancePhase)
78- + 1.3 * sin (2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
79- + 0.7 * sin (2 * 2 * M_PI * phase);
77+ + 6.3 * sin (2 * M_PI * distancePhase)
78+ + 1.3 * sin (2 * 2 * M_PI * phase - 2 * M_PI * distancePhase)
79+ + 0.7 * sin (2 * 2 * M_PI * phase);
8080 if (longitude > 360 )
8181 longitude -= 360 ;
8282
8383 // Select the Zodiac name.
8484 zodiacName = zodiacNames[0 ];
85- for (unsigned i = 0 ; i < sizeof (zodiacAngles) / sizeof (float ); i++) {
85+ for (int i = 0 ; i < sizeof (zodiacAngles) / sizeof (float ); i++) {
8686 if (longitude < zodiacAngles[i]) {
8787 zodiacName = zodiacNames[i];
8888 break ;
0 commit comments