### Re: How do I compute the longitude and latitude of a point at a certain distance?

by I0 (Priest)
 on Apr 22, 2003 at 08:37 UTC ( #252219=note: print w/replies, xml ) Need Help??

```(\$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;
}
• Comment on Re: How do I compute the longitude and latitude of a point at a certain distance?

Create A New User
Node Status?
node history
Node Type: note [id://252219]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2017-11-23 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
In order to be able to say "I know Perl", you must have:

Results (328 votes). Check out past polls.

Notices?