I need help writing the following method:
def get_new_location(current_location, target_location, distance_travelled):
...
...
return new_location
where all locations are (lat,long)
I realize that there are different models for the earth (WGS-84, GRS-80, ...) which take into account the fact that the earth is an ellipsoid. For my purposes, this level of precision is not necessary, assuming a perfect sphere is good enough.
UPDATE
I'm fine tuning my question taking into account some of the responses.
benjismith
argues that my question cannot be answered because there is more than one shortest path between points on the globe. He has a lot of backing in the form of votes, so I guess there's something I don't understand, because I disagree.
The midpoint between any two locations on a sphere is a circular arc.
I concede that this is true when two points are at complete opposites. By this I mean that both points, while remaining on the surface of the sphere, could not be any further away from each other. In this case there are infinite number of equidistant paths joining both points. This, however, is an edge case, not the rule. In all other cases, the vast majority of cases, there is a single shortest path.
To illustrate: if you were to hold a string which passed through two points, and pulled it tight, would there not be only one possible path on which the string would settle (except the edge case already discussed)?
Now, prior to asking the question, obtaining the distance between two points and the heading was not a problem.
I guess what I should have asked is if the following is valid:
def get_new_location(current_location, target_location, percent_traveled):
new_location.lon = (1-percent_traveled)*current_location.lon+percent_traveled*target_location.lon
new_location.lat = (1-percent_traveled)*current_location.lat+percent_traveled*target_location.lat
return new_location
If I were to follow this path, would I be following the great-circle, the rhumb line, ... or would I be completely off? (I know these terms now because of Drew Hall's answer.)