I need to calculate distance between two coordinates (lon,lat) on embedded system which doesn’t have floating point type (only integers available, so no trigonometric functions and no floating point operations like sqrt).
The points are very close to each other so accuracy is not an issue.
So I can not use Haversine formula. I also can not use this simple algorithm based on Pythagoras’ theorem and equirectangular projection:
x = Δlon * cos(lat)
y = Δlat
d = R * √(x² + y²)
Because I don’t have cos and sqrt functions. Maybe I could implement them somehow, but this algorithm have to be fast (embedded system).
My best bet is Pythagoras’ theorem but how to get from degrees to meters without trigonometric functions (and without sqrt)?
Traditionally mariners would use Traverse Tables for this sort of computation — see Chapter 24 of the American Practical Navigator. Which suggests that if
trigandsqrtare out of the equation you might implement a lookup table — trading space for complexity. Depending on your precise needs you may only need a partial traverse table for the latitudes you are interested in.