Created
April 22, 2017 23:16
-
-
Save mlusiak/031d81a94c3302bb6be9068c8bc29345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Flightlog.Math do | |
def greatCircle(a,b) do | |
lat1 = elem(a, 0) | |
lon1 = elem(a, 1) | |
lat2 = elem(b, 0) | |
lon2 = elem(b, 1) | |
rlat1 = :math.pi * lat1 / 180.0 | |
rlat2 = :math.pi * lat2 / 180.0 | |
theta = lon1 - lon2 | |
rtheta = :math.pi * theta / 180.0 | |
degDistance = :math.acos(:math.sin(rlat1) * :math.sin(rlat2) + | |
:math.cos(rlat1) * :math.cos(rlat2) * :math.cos(rtheta)) | |
earthRadius = 6371.0 | |
degDistance * earthRadius | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment