Results 1 to 3 of 3
  1. #1
    Eric's Avatar
    Eric Guest

    Default 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. #2
    Chris L Peterson's Avatar
    Chris L Peterson Guest

    Default 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
    are in radians.
    _________________________________________________

    Chris L Peterson
    Cloudbait Observatory
    http://www.cloudbait.com

  3. #3
    thad@thadlabs.com's Avatar
    thad@thadlabs.com Guest

    Default 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/>

 

 

Similar Threads

  1. The long distance runner.
    By Dublin sky watch in forum Off Topic Forum
    Replies: 0
    Last Post: 02-02-2010, 05:08 PM
  2. Replies: 2
    Last Post: 07-21-2008, 10:23 AM
  3. Replies: 0
    Last Post: 04-10-2008, 01:09 PM
  4. Replies: 2
    Last Post: 08-20-2006, 05:04 PM

Tags for this Thread

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« Version 4.2.0
Powered by vBulletin«
All times are GMT. The time now is 04:25 PM.