Reputation: 12943
The purpose is to calculate the distance travelled. For this I calculate an euclidean distance
with velocity, acceleration and time. I get this data from GPS. Here's my calculation:
private float getDistanceTraveled(float vend, float vstart, long timeDifference){
float distance = 0;
if(vend == 0 && vstart == 0)
return distance;
if(vend - vstart == 0)
distance = vend * timeDifference;
else
distance = (vend * vend - vstart * vstart)
/ ((2 * (vend - vstart) / timeDifference);
return distance;
}
What is the usual way to convert this distance to a shortest distance over earth surface?
I did it with simple circle calculations, where my given distance is the chord c
and the radius r
is the earth radius.
double distance = 2 * r * Math.asin(c / (2 * r));
I'm not 100% sure, if this is the correct way to calculate the euclidean distance and convert it. Have I take something else into account?
I'm familiar with the Haversine Formula
, but I can't use the coordinates in this approach.
Upvotes: 0
Views: 1233
Reputation: 28767
Use this formula to proove that you dont need the distance to greater circle conversion.
b = 2 * r * arcsin(s / 2r)
where r is the earth radius in meter and s is your straight-line-of-sight distance in meter
b is then the chord length, the length on a circle with earth radius. Compare b with s, and you will se that it probably does not make sense to distinguish between that values for your application.
see also http://de.wikipedia.org/wiki/Kreissegment
only the german link provides the formula at "Bogenlänge"
Upvotes: 0
Reputation: 28767
What you are measuring is the number of meters the person/vehicle travelled.
Thats fine.
You have the correct meters, there is no need to convert it to greater circle distance, nor makes this sense.
This makes only sense for distances over 10-100 km from one coordinate to the neaxt measure:
(There may be special situations where you want this, e.g when an aeroplane flights straight (by beans of 3d-straight for 100km, then falls down on earth, and then you want to know what the greater circle distance is.)
So you have the correct meters, if you need more (e.g coordinates for position prediction in a specific direction) , then this would be another question.
Upvotes: 1