pglinx has asked for the wisdom of the Perl Monks concerning the following question:
Thanks for any help in advance.#!/usr/local/bin/perl5 use Math::Trig qw(deg2rad pi great_circle_distance asin acos); ############################ ## Distances are in Miles ## ############################ $lat1 = 51.29006786; $long1 = -114.0034133; $lat2 = 54.431963; $long2 = -110.20734554; { ($lat1, $long1, $lat2, $long2) = @_; $r=3956; $a = (pi/2)- deg2rad($lat1); $b = (pi/2)- deg2rad($lat2); $c = sqrt($a**2 + $b**2 - 2 * $a *$b *cos(deg2rad($long2)-deg2rad($long1))); $dist = $c * $r; } print "$dist\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: flat earth distance
by ikegami (Patriarch) on Apr 29, 2009 at 00:05 UTC | |
|
Re: flat earth distance
by Anonymous Monk on Apr 29, 2009 at 00:05 UTC | |
|
Re: flat earth distance
by bobf (Monsignor) on Apr 29, 2009 at 03:08 UTC | |
|
Re: flat earth distance
by swampyankee (Parson) on Apr 29, 2009 at 10:48 UTC | |
|
Re: flat earth distance
by Anonymous Monk on Apr 29, 2009 at 00:06 UTC |