From 3d8f0e3907c15fa4007a21a2c317653a2eba1cb8 Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Wed, 19 Mar 2025 12:35:51 -0400 Subject: [PATCH] Code cleanup; fix astro example. --- examples/astro | 35 ++++++++++++++++++++++++++++++++--- src/moon.c | 5 +++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/examples/astro b/examples/astro index f3688853..a672f52f 100755 --- a/examples/astro +++ b/examples/astro @@ -62,7 +62,31 @@ ELSE REM [moondatetime(2)] +60 SPECIAL COLOR 0 0 0 Full moon: 🌕 [$T] %3 (%b) REM [moondatetime(3)] +60 SPECIAL COLOR 128 128 64 Last Quarter: 🌗 [$T] %3 (%b) ENDIF +EOF +echo "" + +remind -g "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF' +SET $AddBlankLines 0 +FSET angle_to_direction(x) \ +IIF(x > 348 && x <= 11, "North", \ + x > 11 && x <= 34, "North North-East", \ + x > 34 && x <= 56, "North-East", \ + x > 56 && x <= 79, "East North-East", \ + x > 79 && x <= 101, "East", \ + x > 101 && x <= 124, "East South-East", \ + x > 124 && x <= 146, "South-East", \ + x > 146 && x <= 169, "South South-East", \ + x > 169 && x <= 191, "South", \ + x > 191 && x <= 214, "South South-West", \ + x > 214 && x <= 236, "South-West", \ + x > 236 && x <= 259, "West South-West", \ + x > 259 && x <= 281, "West", \ + x > 281 && x <= 304, "West North-West", \ + x > 304 && x <= 326, "North-West", \ + "North North-West") + +BANNER % set mr moonrise() set ms moonset() set mr_a moonrisedir() @@ -72,11 +96,16 @@ IF mr < ms REM NOQUEUE [mr] MSG The moon rises %3 in the [angle_to_direction(mr_a)] ([mr_a] degrees) REM NOQUEUE [ms] MSG The moon sets %3 in the [angle_to_direction(ms_a)] ([ms_a] degrees) ELSE - REM NOQUEUE [ms] MSG The moon sets %3 in the [angle_to_direction(mr_a)] ([mr_a] degrees) - REM NOQUEUE [mr] MSG The moon rises %3 in the [angle_to_direction(ms_a)] ([ms_a] degrees) + REM NOQUEUE [ms] MSG The moon sets %3 in the [angle_to_direction(ms_a)] ([ms_a] degrees) + REM NOQUEUE [mr] MSG The moon rises %3 in the [angle_to_direction(mr_a)] ([mr_a] degrees) ENDIF -REM MSG +IF (datepart(mr) != today()) + REM MSG There is no moonrise today +ENDIF +IF (datepart(ms) != today()) + REM MSG There is no moonset today +ENDIF EOF echo "" diff --git a/src/moon.c b/src/moon.c index a45b41b1..5da1c171 100644 --- a/src/moon.c +++ b/src/moon.c @@ -782,9 +782,10 @@ static void test_moon_event(int k, double offset_days, struct MoonInfo *moon_inf hz = ha[0] + e * (ha[2] - ha[0]); // Azimuth of the moon at the event. nz = -cos(declination[1]) * sin(hz); dz = c * sin(declination[1]) - s * cos(declination[1]) * cos(hz); - az = atan2(nz, dz) / (PI / 180); - if (az < 0) + az = atan2(nz, dz) * (180 / PI); + if (az < 0) { az += 360; + } // If there is no previously recorded event of this type, save this event. //