help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: distance from Easter Island to Chile


From: Emanuel Berg
Subject: Re: distance from Easter Island to Chile
Date: Mon, 21 Apr 2014 12:50:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> Can you see where the first attempt fails? That looks
> like the way I perceived the formula but I get a bit
> dizzy by all those mapcars - I have the subtraction
> in the opposite order but that might be how we supply
> the arguments. Get back to you - never ending story,
> this...

Found it! The f's and l's were in the opposite (wrong)
places. Now this is 3758 as well. Everything in time...

Be sure to save your math functions. Might come in
handy some day (and not just for you).

(defun distance (l1-d f1-d l2-d f2-d)
  (interactive "nLatitude 1: \nnLongitude 1: \nnLatitude 2: \nnLongitude 2: ")
  (let ((l1 (degrees-to-radians l1-d))
        (f1 (degrees-to-radians f1-d))
        (l2 (degrees-to-radians l2-d))
        (f2 (degrees-to-radians f2-d)) )
    (message "%s"
             (* 2 6367.4447 ; Earth's radius
                (asin
                 (sqrt
                  (+ (sin2 (/ (- l2 l1) 2))
                     (* (cos l2) (cos l1) (sin2 (/ (- f2 f1) 2))) )))))))

(distance 33.4500    ; Santiago
          70.6667
          27.1167    ; Easter Island
          109.3667
          )          ; phew!

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


reply via email to

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