emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 80b34d165d: ; Simplify eclipse calculation in calendar/lunar.el


From: Ulrich Müller
Subject: master 80b34d165d: ; Simplify eclipse calculation in calendar/lunar.el
Date: Wed, 15 Feb 2023 09:15:56 -0500 (EST)

branch: master
commit 80b34d165da8b65bf31be7fc4de09610d7bf66f6
Author: Ulrich Müller <ulm@gentoo.org>
Commit: Ulrich Müller <ulm@gentoo.org>

    ; Simplify eclipse calculation in calendar/lunar.el
    
    * lisp/calendar/lunar.el (eclipse-check): Do the calculation in
    degrees, and simplify.
---
 lisp/calendar/lunar.el | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el
index 8ced414410..1f827ca34b 100644
--- a/lisp/calendar/lunar.el
+++ b/lisp/calendar/lunar.el
@@ -155,25 +155,18 @@ remainder mod 4 gives the phase: 0 new moon, 1 first 
quarter, 2 full moon,
 ;; from "Astronomy with your Personal Computer", Subroutine Eclipse
 ;; Line 7000 Peter Duffett-Smith Cambridge University Press 1990
 (defun eclipse-check (moon-lat phase)
-  (let* ((moon-lat (* (/ float-pi 180) moon-lat))
-         ;; For positions near the ascending or descending node,
-         ;; calculate the absolute angular distance from that node.
-         (moon-lat (abs (- moon-lat (* (floor (/ moon-lat float-pi))
-                                       float-pi))))
-         (moon-lat (if (> moon-lat 0.37) ; FIXME (* 0.5 float-pi)
-                       (- float-pi moon-lat)
-                     moon-lat))
+  (let* ((node-dist (mod moon-lat 180))
+         ;; Absolute angular distance from the ascending or descending
+         ;; node, whichever is nearer.
+         (node-dist (min node-dist (- 180 node-dist)))
          (phase-name (cond ((= phase 0) "Solar")
                            ((= phase 2) "Lunar")
                            (t ""))))
-    (cond ((string= phase-name "")
-          "")
-         ((< moon-lat 2.42600766e-1)
-          (concat "** " phase-name " Eclipse **"))
-         ((< moon-lat 0.37)
-          (concat "** " phase-name " Eclipse possible **"))
-         (t
-          ""))))
+    (cond
+     ((string= phase-name "") "")
+     ((< node-dist 13.9) (concat "** " phase-name " Eclipse **"))
+     ((< node-dist 21.2) (concat "** " phase-name " Eclipse possible **"))
+     (t ""))))
 
 (defconst lunar-cycles-per-year 12.3685 ; 365.25/29.530588853
   "Mean number of lunar cycles per 365.25 day year.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]