Java Utililty Methods Distance Calculate

List of utility methods to do Distance Calculate

Description

The list of methods to do Distance Calculate are organized into topic(s).

Method

doubledistance(double u, double v, double pu, double pv)
Returns the distance from point u,v to point pu,pv
double du = pu - u;
double dv = pv - v;
dv = dv * dv;
du = du * du;
return Math.sqrt(dv + du);
doubledistance(double w1, double h1, double w2, double h2, int type)
Determina a distancia entre dois pixels
if (type == 1) {
    return Math.sqrt(Math.pow(w1 - w2, 2) + Math.pow(h1 - h2, 2));
} else if (type == 2) {
    return Math.abs(w1 - w2) + Math.abs(h1 - h2);
} else {
    return Math.max(Math.abs(w1 - w2), Math.abs(h1 - h2));
doubledistance(double x, double y, double xx, double yy)
Calculate the Pythagorean distance from (x, y) to (xx, yy)
double dx = xx - x;
double dy = yy - y;
return Math.sqrt(dx * dx + dy * dy);
doubledistance(double x0, double y0, double x1, double y1)
distance
return Math.sqrt(distanceSquared(x0, y0, x1, y1));
doubledistance(double x0, double y0, double z0, double x1, double y1, double z1)
distance
return Math.sqrt(distanceSq(x0, y0, z0, x1, y1, z1));
doubledistance(double x1, double y1, double x2, double y2)
distance
double lat1 = Math.PI / 180.0 * x1;
double lat2 = Math.PI / 180.0 * x2;
double dLng = Math.PI / 180.0 * (y2 - y1);
double R = 3958.760;
return Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(dLng)) * R;
doubledistance(double x1, double y1, double x2, double y2)
distance
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
doubledistance(double x1, double y1, double x2, double y2)
distance
return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
doubledistance(double x1, double y1, double z1, double x2, double y2, double z2)
distance
return Math.pow(Math.pow((x2 - x1), 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2), 0.5);
doubledistance(double xOrigin, double yOrigin, double xDestination, double yDestination)
distance
double offsetX = xDestination - xOrigin;
double offsetY = yDestination - yOrigin;
return Math.sqrt(offsetX * offsetX + offsetY * offsetY);