views:

71

answers:

3

Given a starting point (origLat, origLon), ending point (destLat, destlon), and a % of trip completed. How do I calculate the current position (curLat, curLon)?

A: 

In this case, it should be really simple:

curLat = origLat + percentageOfTripCompleted*(destLat-origLat);
curLon = origLon + percentageOfTripCompleted*(destLon-origLon);

*The fact that the earth is a sphere really has no bearing on this problem.

That is not a great circle path.
Lawnmower
That is incorrect. Look at the link in @hfs's answer. Remember, great circle paths are *not* straight lines.
Jonathan
thinking about this one a little more, that is definitely true. my bad.
Technically speaking, if the distance is very short, this may be a valid approximation.
ysap
@ysap Unless you're close to the central meridian, in which case this route might take you for a longer stroll :-)
Lawnmower
+6  A: 

Aviation Formulary is a great resource which covers this question and more.

hfs
Just keep in mind that those formulas assume a spherical model. Formulas exist for ellipsoids (WGS84 and such) but they will be far more complicated. It all depends on your presicion requirements.
Lawnmower
Works well. Though as Lawnmower says it is an estimate based on sphere. If anyone can provide a link to the same algorithm for a WGS84 model I would really appreciate it.
Anthony
There are no longer simple formulas when moving to ellipsoids, but you have to use iterative approximations. Start at http://geographiclib.sourceforge.net/html/geodesic.html and see the references linked there. Maybe you can use the library directly or look at the code.
hfs
+2  A: 

MTL provides some good content on great circle computations and some working applets you can use to verify your implementation.

andand