Results 1 to 2 of 2

Thread: Calculating new Lat/Long from current point, distance & bearing

  1. #1
    Jan 2011

    Calculating new Lat/Long from current point, distance & bearing

    I have been hitting myself over the head for a couple hours now. I am trying to calculate the new latitude & longitude (position) when all I have is old latitude & longitude, distance traveled and direction.
    The formula I found online is:

    'lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ))
    'lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2))
    'd/R is the angular distance (in radians), where d is the distance travelled and R is the earth’s radius

    Any ideas where I may be going wrong? I am getting really strange numbers for output. My Longitude appears fine, but Latitude gives me a number of 0.11xxxxx. I am actually trying to make a litte console application in Visual (if anyone here does a little programming, so I included the source code as well)

    Sub Main()
    Dim latA, lonA As Double
    Dim d, θ As Integer
    Dim R As Integer = 6372.795477598 ' km

    Console.Write("enter latitude: ")
    latA = Console.ReadLine
    Console.Write("enter longitude: ")
    lonA = Console.ReadLine
    Console.Write("distance: (meters) ")
    d = Console.ReadLine 'distance in meters
    Console.Write("vector/course: ")
    θ = Console.Read 'bearing in degrees

    d = (d / R) ' convert distance to radians

    Dim latB, lonB As Double

    latB = Asin(Sin(latA) * Cos(d / R) + Cos(latA) * Sin(d / R) * Cos(θ))
    lonB = lonA + Atan2(Sin(θ) * Sin(d / R) * Cos(latA), Cos(d / R) - Sin(latA) * Sin(latB))

    Console.WriteLine("destination = " & latB & ", " & lonB)

    End Sub
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Mar 2008
    Hi Salsa17,

    I don't have a copy of handy, but I'm pretty sure the trig functions require angles in radians, not degrees. So latA, lonA, and theta must all be converted from degrees to radians before their use in trig formulas, and latB and lonB will be in radians too when computed, so you must convert them to degrees before printing, assuming you want your output in degrees.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 5
    Last Post: Oct 5th 2011, 03:01 AM
  2. finding distance and bearing of a yacht
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: Jul 25th 2011, 03:11 AM
  3. Replies: 1
    Last Post: Apr 6th 2011, 06:44 AM
  4. Replies: 6
    Last Post: Jul 23rd 2010, 08:40 AM
  5. Replies: 3
    Last Post: Feb 20th 2008, 10:17 AM

Search Tags

/mathhelpforum @mathhelpforum