When researching how to make the classic "get POI in range" problem, I found that the most used algorithms are Haversine, and if you need real accuracy, then the Vincenty formula. I went first because high accuracy was not a problem. However, it made me think of something that struck me as strange, why didn't I find Cartesean coordinate cache references in the database instead of using the haversine formula with lat / lon?
The problem here, of course, is performance. The haversine formula requires tons of cos / sin function calls, but isnโt it easier to save the projected X / Y and Z lat / lon points in the database and directly apply the dot product? This will require one call to arccos, if I'm not mistaken.
source share