-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "rad" and "deg" to Units #31
Comments
Hi, my math is far in my memory, but if |
To rephrase what I said : the input might be in rad or deg, but the output is actually a distance, If I look at the scikit learn implementation of haversine that you referenced in #30 their output is also in kilometers: scikitlearn: >>> from sklearn.metrics.pairwise import haversine_distances
>>> from math import radians
>>> bsas = [-34.83333, -58.5166646]
>>> paris = [49.0083899664, 2.53844117956]
>>> bsas_in_radians = [radians(_) for _ in bsas]
>>> paris_in_radians = [radians(_) for _ in paris]
>>> result = haversine_distances([bsas_in_radians, paris_in_radians])
>>> result * 6371000/1000 # multiply by Earth radius to get kilometers
array([[ 0. , 11099.54035582],
[11099.54035582, 0. ]]) haversine: >>> bsas = (-34.83333, -58.5166646)
>>> paris = (49.0083899664, 2.53844117956)
>>> haversine(bsas, paris)
11099.555687157774 |
An angle in radians is simply the distance on the unit-sphere. So to get the result in rad, you simply don't multiply with the earth radius. The dependence between angle and distance in linear (that is why the circumference of a circle is r * 2pi (where 2pi is a 360 deg angle)) Edit: |
Fixed by #40 |
It would be nice to have the possibility to also return the distance in radians or degrees.
The text was updated successfully, but these errors were encountered: