Created
March 28, 2011 13:27
-
-
Save mstefanko/890446 to your computer and use it in GitHub Desktop.
Distence calculation between two GPS points
This file contains hidden or 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
private double gps2m(float lat_a, float lng_a, float lat_b, float lng_b) { | |
float pk = (float) (180/3.14169); | |
float a1 = lat_a / pk; | |
float a2 = lng_a / pk; | |
float b1 = lat_b / pk; | |
float b2 = lng_b / pk; | |
float t1 = FloatMath.cos(a1)*FloatMath.cos(a2)*FloatMath.cos(b1)*FloatMath.cos(b2); | |
float t2 = FloatMath.cos(a1)*FloatMath.sin(a2)*FloatMath.cos(b1)*FloatMath.sin(b2); | |
float t3 = FloatMath.sin(a1)*FloatMath.sin(b1); | |
double tt = Math.acos(t1 + t2 + t3); | |
return 6366000*tt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment