WriteLog
[Top] [All Lists]

[WriteLog] Re: calculating distances between grids (makrothen)

To: writelog@contesting.com
Subject: [WriteLog] Re: calculating distances between grids (makrothen)
From: Steve Woodruff <sjwoodr@yahoo.com>
Date: Mon, 8 Mar 2004 20:55:50 -0800 (PST)
List-post: <mailto:writelog@contesting.com>
You asked....  makrothen calculates distance this way:

double dist(double lat1, double lon1, 
                double lat2, double lon2) {
  // convert from degrees to rad
  double a = lat1 * (PI/180);
  double b = lon1 * (PI/180);
  double c = lat2 * (PI/180);
  double d = lon2 * (PI/180);

  // same grid is 100km but we'll calc that later
  if((a==c) && (b==d)) return 0;

  // yow.
  return acos(cos(a)*cos(b)*cos(c)*cos(d)+cos(a) *    

    sin(b)*cos(c)*sin(d)+sin(a)*sin(c)) * 6378.16;
}

Should give you the dist in km between 2 grids.

The 6378.16 km distance is from the makrothen rules.
Some other calculators use a different value for the
diameter of the earth at the equator.  Whatever. 

Aren't you glad you asked?  :)

/steve n9oh

--- writelog-request@contesting.com wrote:
> From: "Dave W7DPW" <w7dpw@comcast.net>
> I would like to find the formula for calculating the
> distance between
> two gridSquares.
> 
> Can some one point me in the right direction ?
> 
> Dave W7DPW
> 


=====
----------------------------------------------------------
 Steve Woodruff, N9OH @ 42.18N 88.34W, sjwoodr@yahoo.com

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you?re looking for faster
http://search.yahoo.com
_______________________________________________
WriteLog mailing list
WriteLog@contesting.com
http://lists.contesting.com/mailman/listinfo/writelog
WriteLog on the web:  http://www.writelog.com/

<Prev in Thread] Current Thread [Next in Thread>
  • [WriteLog] Re: calculating distances between grids (makrothen), Steve Woodruff <=