ummmimrob
ummmimrob

Reputation: 13

how to track distance

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.

Upvotes: 1

Views: 1016

Answers (2)

MusiGenesis
MusiGenesis

Reputation: 75296

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.

Upvotes: 0

duffymo
duffymo

Reputation: 308733

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.

Upvotes: 2

Related Questions