Axel,

This is a far cry from Eratosthenes measuring distance by the time of a Camel caravan, but it should help do distance problems: If we consider the earth a sphere, then the distance between two points on the earth and azimuth from one to another is as follows:

Let site1 have lat1 and lon1  for latitude and longitude
Let site2 have lat2 and lon2 for latitude and longitude

Convention for latitude + for north, - for south
Convention for longitude is + for east, - for west

We'll work in radian units for excel spreadsheets, etc but if you're doing it by a calculator that accepts degrees, then you can ignore the radian conversions and where comparing delta longitude (dlon) use 180 for pi or 360 for 2*pi.

pi = 3.141592654
ToRad = pi/180
ToDeg = 180/pi

dlon = ToRad*(lon2 - lon1);
if dlon >= pi or dlon < -pi
   if dlon>0
        dlon = dlon - 2*pi;
   else
        dlon = dlon + 2*pi;
   end
end

if lat1 == lat2 and dlon == 0
   gamma = 0.0;
   az = 0.0;
else
   %This is the main computation
   sinL1 = sin(lat1);       cosL1 = cos(lat1);
   sinL2 = sin(lat2);       cosL2 = cos(lat2);
   cL2cdo = cosL2*cos(dlon);
   sDsC    = sin(dlon)*cosL2;
   sDcC    = cosL1*sinL2 - sinL1*cL2cdo;

    sgm  = sqrt(sDsC*ScsC + sDcC*sDcC);
    cgm = sinL1*sinL2 + cosL1*cL2cdo;

    gamma = ToDeg*atan2(sgm,cgm);
    az = ToDeg*atan2(sDsC,sDcC);
end

Notes:
gamma is the distance between the two sites in arc degrees. To get kilometers multiply by 111.13

az is the azimuth from site1 to site2 measured counterclockwise from north (minus is counterclockwise)

Be careful about the atan2 function... in excel, the function expects reverse order (x,y) rather than the (sin,cos) form used above.

Example:
Washington DC  +39N    -77E
Seattle                +47.5  -122E


sin(Lat1)=0.6293    cos(Lat1)=0.7771
sin(Lat2)=0.7373    cos(Lat2)=0.6756
dlon    -45 deg
sin(dlon)=-0.7071    cos(dlon)=0.7071
cL2cdo =  0.4777
sDsC   = -0.4777
sDcC   =  0.2723

sgm    =  0.5499
cgm    =  0.8352

gamma  =  33.36 deg or  3707.3 km distance between sites
azimuth= -60.3133 (from site 1 to site 2)

A final note: to handle the oblate shape of the earth, the computation of the true geodesic is much more complicated than that given above. The method of Vincente is a practical form, but long. If you want it, email me for the code.

Regards
Bob


---------------------------------------------------
https://lists.uni-koeln.de/mailman/listinfo/sundial

Reply via email to