Moved the haversine code to a subdirectory

This commit is contained in:
2023-02-25 23:03:18 +00:00
parent 1a050d28e2
commit 3523e12a5d
9 changed files with 18 additions and 26 deletions

View File

@@ -0,0 +1,14 @@
from math import radians, sin, cos, sqrt, asin
def haversine_of_degrees(x0, y0, x1, y1, radius):
dy = radians(y1 - y0)
dx = radians(x1 - x0)
y0 = radians(y0)
y1 = radians(y1)
root_term = (sin(dy / 2) ** 2) + cos(y0) * cos(y1) * (sin(dx / 2) ** 2)
result = 2 * radius * asin(sqrt(root_term))
return result