|Having the coordinates from Android Sensor and try to calculate the distance in Excel according to:
dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c (where R is the radius of the Earth)
Enter my two Locations in the calculator (link above) shows me the right result, it is about 6m.
When I calculate it by Excel I get 20Km instead of 6 meters
I'm strongly assuming that I mix up rad vs. degree but I do not find where I'm wrong.
Excel trigonometric functions expect everything in rad so I adjust lon1, lon2, lat1, lat2 first into rad...
Where I could be wrong, any idea?
Thank you in advance.
N.B: I'm also not sure whether it is ok to use the sensor decimal values directly for trigonometric function, maybe this is the key Point.
c allways Shows me something very near PI, e.g. 3.14159145
modified 19-Jan-21 21:04pm.