Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS/GIS Calculations: Algorithm to predict future position based on movement/mph?

Looking for resources or algorithm to calculate the following in a navigation app:

If my current GPS position is (0,0) and I'm heading 32 degrees at 15 miles per hour, how can I calculate what my position will be in 10 seconds?

i.e.: GPSCoordinate predictedCoord = GPSCoordinate.FromLatLong(0, 0).AddByMovement(32, 15, TimeSpan.FromSeconds(10));

Edit: Current code based on answer below:

public GPSCoordinate AddMovementMilesPerHour(double heading, double speedMph, TimeSpan duration)
{
    double x = speedMph * System.Math.Sin(heading * pi / 180) * duration.TotalSeconds / 3600;
    double y = speedMph * System.Math.Cos(heading * pi / 180) * duration.TotalSeconds / 3600;

    double newLat = this.Latitude + 180 / pi * y / earthRadius;
    double newLong = this.Longitude + 180 / pi / System.Math.Sin(this.Latitude * pi / 180) * x / earthRadius;

    return GPSCoordinate.FromLatLong(newLat, newLong);
}
like image 225
Brandon Avatar asked Feb 05 '11 20:02

Brandon


1 Answers

Here is the complete parametric answer :

variables :

  • heading : heading (i.e. backwards angle from azimuth 0°, in degrees)
  • speed : velocity (i.e. norm of the speed vector, in miles/hour)
  • lat0, lon0 : initial coordinates in degrees
  • dtime : time interval from the start position, in seconds
  • lat, lon : predicted coordinates in degrees
  • pi : the pi constant (3.14159...)
  • Rt : Earth radius in miles (6378137.0 meters which makes 3964.037911746 miles)

In an (East, North) local frame, the position after the time interval is :

x = speed * sin(heading*pi/180) * dtime / 3600;
y = speed * cos(heading*pi/180) * dtime / 3600;

(with coordinates in miles)

From there you can compute the new position in the WGS84 frame (i.e. latitude and longitude) :

lat = lat0 + 180 / pi * y / Rt;
lon = lon0 + 180 / pi / sin(lat0*pi/180) * x / Rt;

Edit : corrected the last line : *sin(phi) to /sin(phi)

like image 96
Stéphane Avatar answered Oct 13 '22 00:10

Stéphane