Haversine formula: Difference between revisions

No edit summary
Line 2,317:
 
=={{header|Perl}}==
 
===Low-Level===
 
{{libheader|ntheory}}
<lang perl>use ntheory qw/Pi/;
Line 2,339 ⟶ 2,342:
{{out}}
<pre>Distance: 2887.260 km</pre>
 
===Idiomatic===
 
Contrary to ntheory, Math::Trig is part of the Perl core distribution.
It comes with a great circle distance built-in.
 
<lang perl>use Math::Trig qw(great_circle_distance deg2rad);
# Notice the 90 - latitude: phi zero is at the North Pole.
# Parameter order is: LON, LAT
my @BNA = (deg2rad(-86.67), deg2rad(90 - 36.12));
my @LAX = (deg2rad(-118.4), deg2rad(90 - 33.94));
 
print "Distance: ", great_circle_distance(@BNA, @LAX, 6372.8), " km\n";</lang>
{{out}}
<pre>Distance: 2887.25995060711 km</pre>
 
=={{header|Phix}}==
Anonymous user