|
Cedar Rapids, Iowa | I learned something this week related to measuring distance between two latitude/longitude points, and I thought I should share. There are some fellow programmers on here that may find this useful.
When I started working with GPS data, I needed a formula to calculate the distance between two points. I found a well-published formula called the 'great circle formula'. It's a lot of trigonometry. What I didn't realize is that this formula assumes the earth is a perfectly round sphere, which it isn't. The earth is a bit fatter at the equator than it is from pole-to-pole.
There is a better method called 'Vincenty's formula'. It is more complicated, a lot more code, but also more accurate. From what I've read, it takes about 2x the computing power, but since we're now working with processors that are in the GHz range, we don't care about the extra processor load.
The difference between these two formulas is somewhere around 0.1%. The way I found out about this was someone was using code I wrote to check a professional surveyor and found a difference of about 2 feet on a half mile. When investigating why there was a difference, this showed up.
The great circle formula is 9 lines of code. Vincenty's is 32 lines and contains a Do/While loop that could run up to 100 times. I genuinely have no idea how a mathematician figured out this stuff.
https://en.wikipedia.org/wiki/Vincenty%27s_formulae | |
|