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

doublesquareDist31TileMetric(int x1, int y1, int x2, int y2)
square Dist Tile Metric
double dy = convert31YToMeters(y1, y2);
double dx = convert31XToMeters(x1, x2);
return dx * dx + dy * dy;
doublesquareDistance(double pointAX, double pointAY, double pointBX, double pointBY)
Returns the square distance between two points.
return (pointAX - pointBX) * (pointAX - pointBX) + (pointAY - pointBY) * (pointAY - pointBY);
doublesquareDistance(double x1, double y1, double x2, double y2)
Computes the distance between two points squared.
double xDiff = x1 - x2;
double yDiff = y1 - y2;
return xDiff * xDiff + yDiff * yDiff;
doublesquaredistance(double[] v1, double[] v2)
returns distance between two points
double dx = v1[0] - v2[0];
double dy = v1[1] - v2[1];
double dz = v1[2] - v2[2];
return (dx * dx + dy * dy + dz * dz);
doublesquareDistance(final double[] a, final double[] b)
get the squared length of (a - b).
assert rows(a) == rows(b);
final int rows = rows(a);
double squ_len = 0.0;
for (int i = 0; i < rows; ++i)
    squ_len += (a[i] - b[i]) * (a[i] - b[i]);
return squ_len;
floatsquareLength(final float x1, final float y1, final float z1, final float x2, final float y2, final float z2)
square Length
final float dx = x1 - x2;
final float dy = y1 - y2;
final float dz = z1 - z2;
return dx * dx + dy * dy + dz * dz;
floatsquareSegmentDistance(float[] p, int a, int b, int c)
square distance from a point a to a segment b,c
float x = p[b];
float y = p[b + 1];
float dx = p[c] - x;
float dy = p[c + 1] - y;
if (dx != 0 || dy != 0) {
    float t = ((p[a] - x) * dx + (p[a + 1] - y) * dy) / (dx * dx + dy * dy);
    if (t > 1) {
        x = p[c];
...