($latitude,$longitude)=ll(
MILES=>5,
LATITUDE=>51+29/60,
LONGITUDE=>0+0/60,
DIRECTION=>315,
);
if( $latitude < 0 ){
$latitude *= -1;
$ns='S';
}else{
$ns='N';
}
if( $longitude < 0 ){
$longitude *= -1;
$ew='W';
}else{
$ew='E';
}
print int $latitude,"°",60*($latitude-int $latitude),"' $ns\n",
int $longitude,"°",60*($longitude-int $longitude),"' $ew\n";
use Math::Trig;
sub ll{
my %l=@_;
use constant PI=>4*atan2(1,1);
my $nm = $l{MILES}*.87;
my $A=$l{DIRECTION}*PI/180;
my $b=(90-$l{LATITUDE})*PI/180;
my $c=$nm/60/180*PI;
my $a=acos(cos($b)*cos($c)+sin($b)*sin($c)*cos($A));
my $latitude=90-180/PI*$a;
my $C=asin(sin($c)*sin($A)/sin($a));
my $longitude=$l{LONGITUDE}+180/PI*$C;
return $latitude,$longitude;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|