Mercurial > emacs
comparison lisp/calendar/solar.el @ 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 | b5434941b9b1 |
children | 66db908addc7 |
comparison
equal
deleted
inserted
replaced
14916:9d170829f227 | 14917:f353b7b88418 |
---|---|
230 ((equal quad 4) (+ deg 360)) | 230 ((equal quad 4) (+ deg 360)) |
231 (t deg)))) | 231 (t deg)))) |
232 | 232 |
233 (defun solar-atn2 (x y) | 233 (defun solar-atn2 (x y) |
234 "Arctan of point X, Y." | 234 "Arctan of point X, Y." |
235 (if (= y 0) | 235 (if (= x 0) |
236 (if (> x 0) 90 270) | 236 (if (> y 0) 90 270) |
237 (solar-arctan (/ x y) y))) | 237 (solar-arctan (/ y x) x))) |
238 | 238 |
239 (defun solar-arccos (x) | 239 (defun solar-arccos (x) |
240 "Arcos of X." | 240 "Arcos of X." |
241 (let ((y (sqrt (- 1 (* x x))))) | 241 (let ((y (sqrt (- 1 (* x x))))) |
242 (solar-arctan (/ y x) (solar-xy-to-quadrant x y)))) | 242 (solar-atn2 x y))) |
243 | 243 |
244 (defun solar-arcsin (y) | 244 (defun solar-arcsin (y) |
245 "Arcsin of Y." | 245 "Arcsin of Y." |
246 (let ((x (sqrt (- 1 (* y y))))) | 246 (let ((x (sqrt (- 1 (* y y))))) |
247 (solar-arctan (/ y x) (solar-xy-to-quadrant x y)))) | 247 (solar-atn2 x y) |
248 )) | |
248 | 249 |
249 (defsubst solar-degrees-to-hours (degrees) | 250 (defsubst solar-degrees-to-hours (degrees) |
250 "Convert DEGREES to hours." | 251 "Convert DEGREES to hours." |
251 (/ degrees 15.0)) | 252 (/ degrees 15.0)) |
252 | 253 |
288 (if (or (and (> latitude 0) solar-spring-or-summer-season) | 289 (if (or (and (> latitude 0) solar-spring-or-summer-season) |
289 (and (< latitude 0) (not solar-spring-or-summer-season))) | 290 (and (< latitude 0) (not solar-spring-or-summer-season))) |
290 (setq day-length 24) | 291 (setq day-length 24) |
291 (setq day-length 0)) | 292 (setq day-length 0)) |
292 (setq day-length (- set-time rise-time))) | 293 (setq day-length (- set-time rise-time))) |
293 (list (+ rise-time (/ calendar-time-zone 60.0)) | 294 (list (if rise-time (+ rise-time (/ calendar-time-zone 60.0)) nil) |
294 (+ set-time (/ calendar-time-zone 60.0)) day-length))) | 295 (if set-time (+ set-time (/ calendar-time-zone 60.0)) nil) |
296 day-length))) | |
295 | 297 |
296 (defun solar-moment (direction latitude longitude time) | 298 (defun solar-moment (direction latitude longitude time) |
297 "Sunrise/sunset at location. | 299 "Sunrise/sunset at location. |
298 Sunrise if DIRECTION =-1 or sunset if =1 at LATITUDE, LONGITUDE, with midday | 300 Sunrise if DIRECTION =-1 or sunset if =1 at LATITUDE, LONGITUDE, with midday |
299 being TIME. | 301 being TIME. |
334 (solar-horizontal-coordinates | 336 (solar-horizontal-coordinates |
335 (list t0 utmoment) latitude longitude t)))) | 337 (list t0 utmoment) latitude longitude t)))) |
336 (if (< hut -0.61) (setq utmin utmoment)) | 338 (if (< hut -0.61) (setq utmin utmoment)) |
337 (if (> hut -0.61) (setq utmax utmoment)) | 339 (if (> hut -0.61) (setq utmax utmoment)) |
338 ) | 340 ) |
339 (setq possible 0)) the sun never rises | 341 (setq possible 0)) ; the sun never rises |
340 (setq possible 0)) ; the sun never sets | 342 (setq possible 0)) ; the sun never sets |
341 (if (equal possible 0) nil utmoment))) | 343 (if (equal possible 0) nil utmoment))) |
342 | 344 |
343 (defun solar-time-string (time time-zone) | 345 (defun solar-time-string (time time-zone) |
344 "Printable form for decimal fraction TIME in TIME-ZONE. | 346 "Printable form for decimal fraction TIME in TIME-ZONE. |
510 (st (+ solar-sidereal-time-greenwich-midnight | 512 (st (+ solar-sidereal-time-greenwich-midnight |
511 (* ut 1.00273790935))) | 513 (* ut 1.00273790935))) |
512 (ah (- (* st 15) (* 15 (car ec)) (* -1 (calendar-longitude)))) | 514 (ah (- (* st 15) (* 15 (car ec)) (* -1 (calendar-longitude)))) |
513 ; hour angle (in degrees) | 515 ; hour angle (in degrees) |
514 (de (car (cdr ec))) | 516 (de (car (cdr ec))) |
515 (azimuth (solar-atn2 (solar-sin-degrees ah) | 517 (azimuth (solar-atn2 (- (* (solar-cosine-degrees ah) |
516 (- (* (solar-cosine-degrees ah) | |
517 (solar-sin-degrees latitude)) | 518 (solar-sin-degrees latitude)) |
518 (* (solar-tangent-degrees de) | 519 (* (solar-tangent-degrees de) |
519 (solar-cosine-degrees latitude))))) | 520 (solar-cosine-degrees latitude))) |
521 (solar-sin-degrees ah))) | |
520 (height (solar-arcsin | 522 (height (solar-arcsin |
521 (+ (* (solar-sin-degrees latitude) (solar-sin-degrees de)) | 523 (+ (* (solar-sin-degrees latitude) (solar-sin-degrees de)) |
522 (* (solar-cosine-degrees latitude) | 524 (* (solar-cosine-degrees latitude) |
523 (solar-cosine-degrees de) | 525 (solar-cosine-degrees de) |
524 (solar-cosine-degrees ah)))))) | 526 (solar-cosine-degrees ah)))))) |