[Swlug] Re Re Re Maths calculations

Rhys Sage rhys_sage at yahoo.com
Sat Jul 23 18:26:14 UTC 2022


I had several goes at making the Vincenty formula work before finally giving up and using a Vincenty library (I detest libraries as it makes programs harder to shift between machines).

The end result... The distance between the Tower of London and the Arc De Triomphe...

Haversine distance in miles  211.2667
Distance in Miles using flat earth calculation  222.5085
Vincenty miles  206.9727

If Nigel Farage were to send an air strike at the Arc de Triomphe then the flat Earth calculation would doubtless spoil the day for residents of blocks of flats. If he were to use the Haversine distance then he'd upset the French business community. If he used the Vincenty formula then he'd actually hit the Arc de Triomphe and probably thus ruffle a few French feathers and cause them to reduce police presence at the French border.

Haversine is perfectly fine for calculating directions as the fact the world is a bit testicle shaped rather than round is fully catered for.

The code for the Vincenty distance....

from vincenty import vincenty
TowerOfLondon = (51.5081, 0.0759)
ArcDeTriomph = (48.873756, 2.294946)
print("Vincenty miles ", vincenty(TowerOfLondon, ArcDeTriomph , miles=True))

That's pretty darned simple!

Rhys Sage



More information about the Swlug mailing list