all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* distance from Easter Island to Chile
@ 2014-04-20  0:03 Emanuel Berg
  2014-04-20  3:55 ` Frank Stutzman
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Emanuel Berg @ 2014-04-20  0:03 UTC (permalink / raw)
  To: help-gnu-emacs

;; As you know, the Easter Bunny isn't the kind of guy
;; to go on vacation, neglecting his duty. Instead, he
;; dropped me this interesting piece of Elisp to
;; calculate the distance between Earth locations,
;; based on the "Haversine formula".
;;
;; According to the program, the Easter Island (the
;; world's most desolate place) is 4301 kilometers from
;; the capital of Chile. I Googled that selfsame
;; distance, and the result makes me think the Easter
;; Bunny pulled of a successful implementation, though
;; no one, of course, should be above criticism.
;;
;; Enjoy!

(defun sin2 (p)
  (let ((sin-p (sin p)))
    (* sin-p sin-p) ))

(defun distance (l1-r f1-r l2-r f2-r)
  (interactive)
  (let ((l1 (degrees-to-radians l1-r))
        (f1 (degrees-to-radians f1-r))
        (l2 (degrees-to-radians l2-r))
        (f2 (degrees-to-radians f2-r)) )
    (* 2 6378.1 ; Earth's radius
       (asin
        (sqrt
         (+ (sin2 (/ (- f2 f1) 2))
            (* (cos f2) (cos f1) (sin2 (/ (- l2 l1) 2))) ))))))

(distance 33.45    ; Santiago
          70.6667
          27.1167  ; Easter Island
          109.3667
          ) ; should be 3757.41 [1]

;; [1] http://www.mapcrow.info/Distance_between_Santiago_CI_and_Easter_Island_CI.html

-- 
underground experts united:
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-04-23  2:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-20  0:03 distance from Easter Island to Chile Emanuel Berg
2014-04-20  3:55 ` Frank Stutzman
2014-04-20 15:14   ` Emanuel Berg
2014-04-20 22:39     ` giacomo.boffi
     [not found]     ` <mailman.19957.1398033917.10748.help-gnu-emacs@gnu.org>
2014-04-21  1:40       ` Emanuel Berg
2014-04-21  1:50         ` Emanuel Berg
2014-04-21  9:45         ` giacomo.boffi
     [not found]         ` <mailman.19981.1398073560.10748.help-gnu-emacs@gnu.org>
2014-04-21 10:35           ` Emanuel Berg
2014-04-21 10:50             ` Emanuel Berg
2014-04-23  2:49               ` Emanuel Berg
2014-04-21  2:16       ` Emanuel Berg
2014-04-20  4:44 ` Barry Margolin
2014-04-20 15:06   ` Emanuel Berg
2014-04-20  6:28 ` Eli Zaretskii
     [not found] ` <mailman.19905.1397975330.10748.help-gnu-emacs@gnu.org>
2014-04-20  7:01   ` Barry Margolin
2014-04-20  7:48     ` Eli Zaretskii
2014-04-20 10:26       ` Thorsten Jolitz
2014-04-20 11:03         ` Eli Zaretskii
2014-04-20 15:22     ` Emanuel Berg
2014-04-21  6:04       ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.