1

I have a current position: Latitude and Longitude values in degrees (Point A), and the same for the final position (Point B). I need to calculate the course (also in degrees) between the two points and than with given speed (in km/s) and timespan (in seconds) to calculate the new position.

Example (Pseudo code):

PointA.Lat = x.xxxx;
PointA.Lng = x.xxxx;
PointB.Lat = x.xxxx;
PointB.Lng = x.xxxx;
Speed = 3;
TimeSpan = 0.1;
Course = GetCourse(PointA, PointB);

NewPoint = CalculatePoint(PointA, Course, Speed, TimeSpan);

I thought of using the GeoCoordinate class, but I'm not sure how ad I have to implement myself all the calculations. (I don't have a GPS - this is only a simulation and those are fake points).

Can someone help me with the math or with some package that can do it free and can easly be intagrated to my code?

BTW I'm using C#.

Thanks.

yossi
  • 37
  • 6
  • Maybe there is 'C#' specific library for this, but from a math point of view are you familiar with spherical coordinates? The `Lat`/`Lng` angles are coordinates in this geometry. – John Alexiou Apr 29 '12 at 12:59

1 Answers1

0

I'd have made this a comment but I don't have the required rep.

What you're looking for is a geodesy library that gives you the “geodetic inverse” and “geodetic direct” calculations. I don't know of any myself, but try searching for “c# geodesy library”

The former gives the bearing and distance between two geographical coordinates, the latter gives a new coordinate at a given bearing and distance from the first.

So for your problem:

  1. Use the inverse to get the bearing between PointA and PointB
  2. Calculate a destination distance from the time and speed,
  3. Plug the bearing and distance into the direct to get the desired destination NewCoord.

Coding these calculations from 1st principles will be quite substantial and require the parameters of (presumably) the WGS84 ellipsoid. This, however, is the starting point.

Hope this helps.

Raz Luvaton
  • 3,166
  • 4
  • 21
  • 36
acraig5075
  • 10,588
  • 3
  • 31
  • 50