Created
January 16, 2022 08:03
-
-
Save Umair444/e97f22540336f198af7ab71aacd2bbfb 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
function d = greatCircleDistance(lat1, lon1, lat2, lon2) | |
R = 6371.1e3; % Mean Earth Radius | |
p1 = lat1*(pi/180); | |
p2 = lat2*(pi/180); | |
p = (lat2-lat1)*(pi/180); | |
l = (lon2-lon1)*(pi/180); | |
a = sin(p/2)*sin(p/2)+cos(p1)*cos(p2)*sin(l/2)*sin(l/2); | |
c = 2*atan2(sqrt(a), sqrt(1-a)); | |
d = R*c; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment