List of utility methods to do Distance Calculate
double | distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2) distance Between double a = xpos1 - xpos2; double b = ypos1 - ypos2; double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)); return c; |
double | distanceBetween2GeoPositionsInMeters(double latA, double lngA, double latB, double lngB) Calculate the distance in meters between two geographical coordinates. double earthRadius = 6371; double dLat = Math.toRadians(latB - latA); double dLng = Math.toRadians(lngB - lngA); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return (int) (earthRadius * c * 1000); |
float | distanceBetween2Points(float p1[], float p2[]) Calc distance between 2 points in space return (float) (Math.sqrt((p1[0] - p2[0]) * (p1[0] - p2[0]) + (p1[1] - p2[1]) * (p1[1] - p2[1]) + (p1[2] - p2[2]) * (p1[2] - p2[2]))); |
float | distanceBetween2Points(float vectorX0, float vectorY0, float vectorXP, float vectorYP) distance Between Points float x = Math.abs(vectorXP - vectorX0); float y = Math.abs(vectorYP - vectorY0); return (float) Math.sqrt((x * x) + (y * y)); |
double | distanceBetweenPoints(double ax, double ay, double bx, double by) distance Between Points return Math.sqrt(Math.pow((float) (bx - ax), 2) + Math.pow((float) (by - ay), 2)); |
double | DistanceBetweenPoints(double x1, double y1, double x2, double y2) Distance Between Points return Math.sqrt(DistanceSquareBetweenPoints(x1, y1, x2, y2));
|
float | distanceBetweenPoints(float vx, float vy, float wx, float wy) _more_ return square(vx - wx) + square(vy - wy);
|
float | distanceBetweenPoints(float[] xyz1, float[] xyz2) distance Between Points float dx = xyz1[0] - xyz2[0]; float dy = xyz1[1] - xyz2[1]; float dz = xyz1[2] - xyz2[2]; return (float) Math.sqrt(dx * dx + dy * dy + dz * dz); |
double | distanceByLBS(double lo1, double la1, double lo2, double la2) distance By LBS double radLat1 = la1 * Math.PI / 180; double radLat2 = la2 * Math.PI / 180; double a = radLat1 - radLat2; double b = lo1 * Math.PI / 180 - lo2 * Math.PI / 180; double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); s = s * 6378137.0; s = Math.round(s * 10000) / 10000; ... |
int | distanceCircle(int i0, int i1, int dir, int size) dist = (dir > 0 ) i1-i0 ? int distance = (dir > 0) ? i1 - i0 : i0 - i1; if (distance < 0) distance = size + distance; return distance; |