Thread: compute lat/long given lat/long plus distance and bearing

1. compute lat/long given lat/long plus distance and bearing

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

Thanks
Eric 2. compute lat/long given lat/long plus distance and bearing

On Mon, 23 Jun 2008 20:36:18 -0700, Eric <Scorpus@gordinator.org> wrote:

Try converting your input coordinates to radians (degrees * pi / 180).
In C, and virtually every other language, trig functions assume angles
_________________________________________________

Chris L Peterson
Cloudbait Observatory
http://www.cloudbait.com 3. compute lat/long given lat/long plus distance and bearing

On Jun 23, 10:13 pm, Chris L Peterson <c...@alumni.caltech.edu> wrote:

Very true. And another problem that sticks out like a sore thumb
is the distance; at the least it should be converted to arc-something,
probably radians -- at present the calcs are mixing apples and
oranges and producing squash :-)

And, then, what's the "altitude"? ALso, since the above appears to
be a fragment of C code, make sure "#include <math.h>" appears
in the program; depending whose compiler, the functions could be
assumed integer, not double, with haphazard castings.

Best reference for such calculations is Bowditch's "The American
Practical Navigator", available in PDF here:

<http://www.irbs.com/bowditch/> Tags for this Thread

bearing, compute, distance, lat or long  Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
• Powered by vBulletin®