Skip to content
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

Haversine vs Great Circle Distance #3567

Closed
daniel-j-h opened this issue Jan 16, 2017 · 5 comments
Closed

Haversine vs Great Circle Distance #3567

daniel-j-h opened this issue Jan 16, 2017 · 5 comments

Comments

@daniel-j-h
Copy link
Member

In Coordinate calculation it seems like we provide

  • haversineDistance
  • greatCircleDistance

for measuring distance between two coordinates on a sphere (this is usually called great circle distance).

From what I can see the greatCircleDistance titled function really is a equirectangular approximation.

The only reason for using it I can come up with is speed. Are those calls really carefully sprinkled in when we need to care about the performance? Any insights here?

cc @TheMarex @oxidase

@oxidase
Copy link
Contributor

oxidase commented Jan 16, 2017

greatCircleDistance is the haversine distance equation where the haversine is approximated as x^2/4 for small x and cos(phi_1)cos(phi_2) as cos^2((phi_1+phi_2)/2) for close phi_1 and phi_2.

I think also the reason to use the approximated version is only performance, but to check how it is better some profiling is needed.

@TheMarex
Copy link
Member

The original cycle here was something like we started out with haversine everywhere since it is the most precise formula that is somewhat fast, then switched everything to great circle distance to get a performance speedup. However we realized that great circle distance is not precise enough for some things and switched them back.

I would not call it carefully sprinkled but at least picked with some care.

@daniel-j-h
Copy link
Member Author

Interesting. I'm closing this as interesting but not actionable for us at the moment.

We can profile and check in the future if needs be.

@kkdd
Copy link

kkdd commented Apr 24, 2017

The following is a good distance calculation from "5. Starting point for Newton’s method" in "Algorithms for geodesics" by Charles F. F. Karney (2013):

$ ./geodesic_inverse_approx.py 60.0 60.1 0.1
input: lat1= 60.000000  lat2= 60.100000  lam12=     0.100000
output: az1= 26.526      az2= 26.612       s12= 12456.777
error:  az1= 1.2e-05     az2= 1.2e-05      s12=   1.3e-03

python source: https://gist.github.com/c8ad6ce4a936e456d281511e2d7a2434

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants