tags:

views:

73

answers:

2

total nubi here and i'm trying to writ an application that trackes how far you have traveled. I can't find anything on how to do this. I can get location, speed, bearing etc. Any pointers on the best way to do this would be appreciated.

+1  A: 

Calculus would suggest a way: it's a path integral. You'll approximate it by initializing distance to zero, starting with a position at time t0, taking a time step dt, calculating a new position at time t0 + dt, and adding the distance traveled in that time to the distance. Rinse, repeat until you stop the loop.

duffymo
Howitzer vs. mouse: round 1.
MusiGenesis
I assumed that "distance traveled" meant along a particular path (e.g., "How many miles have I run when I go along this route?"). If that's the case, I think I can neglect the curvature of the earth. The rest of your description isn't much different from what I described.
duffymo
A: 

Well, you'll want to start with a formula that calculates the distance (in miles, perhaps) between any two locations. This is more complicated than simple trigonometry because of the curvature of the Earth. Here is a link for doing this calculation:

http://www.movable-type.co.uk/scripts/latlong.html

Once you have a formula for calculating the distance, getting the total distance traveled is a simple matter of recording a series of points as you're moving and then tallying all the distances between each point and the next.

MusiGenesis