1234567891011121314 |
- from math import pi, asin, cos, sin, sqrt, fmod
- def spherical_distance(a, b):
- coef = pi / 180
- radlat1 = a[1] * coef
- radlat2 = b[1] * coef
- radlng1 = a[0] * coef
- radlng2 = b[0] * coef
- a = sin((radlat1 - radlat2)/2)**2
- b = cos(radlat1) * cos(radlat2) * sin((radlng1 - radlng2)/2) ** 2
- return asin(sqrt(a+b))
- def ang_distance(a, b):
- return (sin(a) - sin(b))**2 + (cos(a) - cos(b))**2
|