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

Adds Haversine formula class #39

Open
wants to merge 1 commit into
base: master
from

Conversation

@corazzi
Copy link

corazzi commented Oct 22, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? n/a
Fixed tickets n/a but applicable to #1
License MIT

The Haversine formula is used to determine the distance between two points on a sphere (e.g., the Earth).

Simply pass a pair of to/from arrays containing the latitude and longitude of the points and you can calculate the distance in meters, miles, and kilometres.

You can, of course, extend this to use the radius of a different sphere, such as another planet or an arbitrary spherical model.

Here's a usage example, determining the distance from Land's End to John O'Groats as the crow flies:

Haversine::make([50.0657, 5.7132], [58.6373, 3.0689])->meters(); // 968205.89737109

Haversine::make([50.0657, 5.7132], [58.6373, 3.0689])->kilometers(); // 968.20589737109

Haversine::make([50.0657, 5.7132], [58.6373, 3.0689])->miles(); // 601.61525278069
@corazzi corazzi force-pushed the corazzi:feature/haversine branch from 2271e60 to 605d8bd Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.