Moved the haversine code to a subdirectory
This commit is contained in:
14
haversine/python/haversine_algorithm.py
Normal file
14
haversine/python/haversine_algorithm.py
Normal 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
|
||||
Reference in New Issue
Block a user