Re: compute lat/long given lat/long plus distance and bearing
- From: "Greg Neill" <gneillREM@xxxxxxxxxxxxxxx>
- Date: Tue, 24 Jun 2008 00:17:27 -0400
"Eric" <Scorpus@xxxxxxxxxxxxxx> wrote in message
news:Q5ydnYdFzYcp9v3VnZ2dnUVZ_jmdnZ2d@xxxxxxxxxxx
Has anyone got a formula that:
given a lat/long starting point plus a distance and bearing
will output the new lat/long position?
I found this but it doesnt seem to work right
double curLat=40.12345;
double curLong=-122.12345;
double bearing=90; // east
double dist=1609.344; // 1 mile in meters
d_lat = asin(sin(curLat)* cos(dist)+ cos(curLat)*
sin(dist)*cos(bearing)); d_lon =
atan2(sin(bearing)*sin(dist)*cos(curLat),
cos(dist)-sin(altitude)*sin(curLat)); d_long = fmod( curLong -
d_lon + pi, 2*pi )- pi;
printf("new coordinates: %lg x %lg\n", d_lat, d_long);
my results look like this:
new coordinates: -0.384715 x -6.1364
Your trig functions are probably looking for angles in
radians, not degrees.
You'll have to convert your distance to angular measure,
most likely by dividing it by the radius of the Earth.
What is that undeclared altitude variable in the atan2
calculation? I suspect it should be d_lat.
.
- Follow-Ups:
- Prev by Date: Re: compute lat/long given lat/long plus distance and bearing
- Next by Date: Re: compute lat/long given lat/long plus distance and bearing
- Previous by thread: Re: compute lat/long given lat/long plus distance and bearing
- Next by thread: Re: compute lat/long given lat/long plus distance and bearing
- Index(es):
Relevant Pages
|