[WriteLog] Re: calculating distances between grids (makrothen)
    Steve Woodruff 
    sjwoodr at yahoo.com
       
    Mon Mar  8 20:55:50 EST 2004
    
    
  
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 at contesting.com wrote:
> From: "Dave W7DPW" <w7dpw at 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 at yahoo.com
__________________________________
Do you Yahoo!?
Yahoo! Search - Find what youre looking for faster
http://search.yahoo.com
    
    
More information about the WriteLog
mailing list