From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: giacomo.boffi@gmail.com Newsgroups: gmane.emacs.help Subject: Re: distance from Easter Island to Chile Date: Mon, 21 Apr 2014 11:45:29 +0200 Organization: The Sun and the Rain. Message-ID: <87ha5n818m.fsf@pascolo.net> References: <87mwfguasr.fsf@nl106-137-194.student.uu.se> <87mwfg823s.fsf@nl106-137-194.student.uu.se> <8761m3tq89.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1398073576 5052 80.91.229.3 (21 Apr 2014 09:46:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Apr 2014 09:46:16 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 21 11:46:10 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WcAni-0003mH-07 for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Apr 2014 11:46:10 +0200 Original-Received: from localhost ([::1]:48203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcAnh-0005kM-LA for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Apr 2014 05:46:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcAnR-0005gr-VK for help-gnu-emacs@gnu.org; Mon, 21 Apr 2014 05:45:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcAnM-0001SY-MH for help-gnu-emacs@gnu.org; Mon, 21 Apr 2014 05:45:53 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:57520) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcAnM-0001SO-EU for help-gnu-emacs@gnu.org; Mon, 21 Apr 2014 05:45:48 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WcAnF-0003LM-DI for help-gnu-emacs@gnu.org; Mon, 21 Apr 2014 11:45:41 +0200 Original-Received: from ppp-116-22.21-151.libero.it ([151.21.22.116]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Apr 2014 11:45:41 +0200 Original-Received: from giacomo.boffi by ppp-116-22.21-151.libero.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 21 Apr 2014 11:45:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ppp-116-22.21-151.libero.it User-Agent: Gnus/5.101 (Gnus v5.10.10) XEmacs/21.5-b34 (linux) Cancel-Lock: sha1:pdxyhuqFWfzUN+TimE+bV7dSDPo= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97286 Archived-At: Emanuel Berg 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))))