evan@telly.UUCP (Evan Leibovitch) (07/19/88)
Might any of you folk have C code for calculating the distance between two latitude/longitude pairs? If not, I can work with a raw algorithm, as long as I can understand it with an average ability in trig. The intent is to build this into my mailer, so that users can see the actual distance their messages will travel (using the Lat/Long listings in the map files). I just want my users to see what the net is doing for them. Many thanks. -- _______ The great mystery revealed: | Evan Leibovitch, SA, System Telly 1st - Egg: 2 min 41 sec | Located in beautiful Brampton, Ontario 2nd - Chicken: 2 min 49 sec | evan@telly.UUCP -or- utzoo!telly!evan
olsen@XN.LL.MIT.EDU (Jim Olsen) (07/21/88)
Here is a C expression which calculates the great-circle distance from point (lat1,lon1) to point (lat2,lon2). All quantities are in radians. To convert the distance to kilometers, multiply by 6367. distance = acos(cos(lat2-lat1) * cos((lon2-lon1)*cos(lat1)));