changeset 14917:f353b7b88418

Fixed solar-arcsin/arcos stuff.
author Edward M. Reingold <reingold@emr.cs.iit.edu>
date Sat, 30 Mar 1996 00:07:35 +0000
parents 9d170829f227
children 15b06c5dc608
files lisp/calendar/solar.el
diffstat 1 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/solar.el	Fri Mar 29 22:40:05 1996 +0000
+++ b/lisp/calendar/solar.el	Sat Mar 30 00:07:35 1996 +0000
@@ -232,19 +232,20 @@
 
 (defun solar-atn2 (x y)
    "Arctan of point X, Y."
-   (if (= y 0)
-       (if (> x 0) 90 270)
-     (solar-arctan (/ x y) y)))
+   (if (= x 0)
+       (if (> y 0) 90 270)
+     (solar-arctan (/ y x) x)))
 
 (defun solar-arccos (x)
-  "Arcos of X."
-  (let ((y (sqrt (- 1 (* x x)))))
-    (solar-arctan (/ y x) (solar-xy-to-quadrant x y))))
+     "Arcos of X."
+     (let ((y (sqrt (- 1 (* x x)))))
+       (solar-atn2 x y)))
 
 (defun solar-arcsin (y)
-  "Arcsin of Y."
-  (let ((x (sqrt (- 1 (* y y)))))
-    (solar-arctan (/ y x) (solar-xy-to-quadrant x y))))
+     "Arcsin of Y."
+     (let ((x (sqrt (- 1 (* y y)))))
+       (solar-atn2 x y)
+       ))
 
 (defsubst solar-degrees-to-hours (degrees)
   "Convert DEGREES to hours."
@@ -290,8 +291,9 @@
           (setq day-length 24)
           (setq day-length 0))
         (setq day-length (- set-time rise-time)))
-    (list (+ rise-time (/ calendar-time-zone 60.0)) 
-          (+ set-time (/ calendar-time-zone 60.0)) day-length)))
+    (list (if rise-time (+ rise-time (/ calendar-time-zone 60.0)) nil)
+          (if set-time (+ set-time (/ calendar-time-zone 60.0)) nil)
+          day-length)))
 
 (defun solar-moment (direction latitude longitude time)
   "Sunrise/sunset at location.
@@ -336,7 +338,7 @@
                     (if (< hut -0.61) (setq utmin utmoment))
                     (if (> hut -0.61) (setq utmax utmoment))
                    )
-                (setq possible 0)) the sun never rises
+                (setq possible 0)) ; the sun never rises
                 (setq possible 0)) ; the sun never sets
      (if (equal possible 0) nil utmoment)))
 
@@ -512,11 +514,11 @@
          (ah (- (* st 15) (* 15 (car ec)) (* -1 (calendar-longitude))))
                        ; hour angle (in degrees)
          (de (car (cdr ec)))
-         (azimuth (solar-atn2 (solar-sin-degrees ah)
-                             (- (* (solar-cosine-degrees ah)
+         (azimuth (solar-atn2 (- (* (solar-cosine-degrees ah)
                                    (solar-sin-degrees latitude))
                                 (* (solar-tangent-degrees de)
-                                   (solar-cosine-degrees latitude)))))
+                                   (solar-cosine-degrees latitude)))
+                              (solar-sin-degrees ah)))
          (height (solar-arcsin 
                   (+ (* (solar-sin-degrees latitude) (solar-sin-degrees de))
                      (* (solar-cosine-degrees latitude)