Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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??


in reply to How do I compute the longitude and latitude of a point at a certain distance?

($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?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://252219]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2015-07-29 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls