How close? What direction?
In order to calculate the distance between two points, we'll need to use some spherical geometry calculations. The problem we will have to overcome is that our charts and maps are flat. But the actual planet is very close to being spherical. While the spherical geometry may be a bit advanced, the programming is pretty simple. It will show us several features of the Python math
library.
The distance between two latitude and longitude points on a sphere is defined as follows:
This formula determines the cosine between the two positions; the angle with that cosine is multiplied by the radius of the earth, R, to get the distance ...
Get Python for Secret Agents now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.