unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: distance from Easter Island to Chile
Date: Mon, 21 Apr 2014 12:35:31 +0200	[thread overview]
Message-ID: <87sip7dl70.fsf@nl106-137-194.student.uu.se> (raw)
In-Reply-To: mailman.19981.1398073560.10748.help-gnu-emacs@gnu.org

giacomo.boffi@gmail.com writes:

> Emanuel Berg <embe8573@student.uu.se> writes:
>
>> giacomo.boffi@gmail.com writes:
>>
>>>> I get an answer of 4301.199
>>>
>>> me too
>> Provided the implementation is correct that's what
>> you get with the Haversine method.
>
> (defun d2r (x) "degrees-to-radians is a macro, won't
> work with mapcar..."  (/ (* x pi) 180))
>
> ; wolfram's alpha says (setq average-earth-radius
> 6367.4447)
>
> ; there are sources that report different locations ;
> for Santiago and Easter Island (setq santiago (mapcar
> d2r '(33.4500 70.6667))) (setq easter_i (mapcar 'd2r
> (27.1167 109.3667)))
>
> (defun haversines (p1 p2) "Returns a list with
> sin^2(Delta_Lat/2) and sin^2(Delta_Lon/2).
> http://en.wikipedia.org/wiki/Haversine" (flet ((d2 (x)
> (/ x 2)) (p2 (x) (* x x))) (mapcar 'p2 (mapcar 'sin
> (mapcar 'd2 (mapcar* '- p1 p2))))))
>
> (defun central-angle (p1 p2) "Returns the central angle
> between two locations on a sphere, using the haversine
> formula.
> http://en.wikipedia.org/wiki/Great-circle_distance#Computational_formulas
> " (let* ( (hs (haversines p1 p2)) (hs-lat (car hs))
> (hs-lon (cadr hs)) (cos-lat1 (cos (car p1))) (cos-lat2
> (cos (car p2))) ) (* 2 (asin (sqrt (+ hs-lat (*
> cos-lat1 cos-lat2 hs-lon)))))))
>
> (insert (format "\n%f" (* 6378.1 (central-angle
> santiago easter_i))))
>
> (insert (format "\n%f" (* average-earth-radius
> (central-angle santiago easter_i))))

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...

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


  parent reply	other threads:[~2014-04-21 10:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sip7dl70.fsf@nl106-137-194.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).