Java Utililty Methods Euclidean Distance

List of utility methods to do Euclidean Distance

Description

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

Method

doubleeuclideanDistance(double[] vector1, double[] vector2)
Returns Euclidean distance between the two vectors
double sum = 0;
for (int i = 0; i < vector1.length; i++) {
    sum += (vector1[i] - vector2[i]) * (vector1[i] - vector2[i]);
return Math.sqrt(sum);
doubleeuclideanDistance(float[] points, int p1, int p2, boolean isDisp, double width, double height)
euclidean Distance
float dx = points[p1] - points[p2];
float dy = points[p1 + 1] - points[p2 + 1];
if (isDisp) {
    dx *= width;
    dy *= height;
return Math.sqrt(dx * dx + dy * dy);
doubleeuclideanDistance(int i0, int j0, int i1, int j1)
euclidean Distance
return Math.sqrt(Math.pow(i0 - i1, 2d) + Math.pow(j0 - j1, 2d));
doubleeuclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ)
See link below for more information about how this works http://www.policyalmanac.org/games/aStarTutorial.htm Thanks to @Adamki11s, who's source I took inspiration from on how to do this, check out his Bukkit post here: https://bukkit.org/threads/lib-a-pathfinding-algorithm.129786/
double dx = startX - endX;
double dy = startY - endY;
double dz = startZ - endZ;
return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz));
doubleeuclideanDistanceNorm(float[] x, float[] y)
euclidean Distance Norm
double sumXY2 = 0.0;
for (int i = 0, n = x.length; i < n; i++) {
    if (Float.isNaN(x[i]) || Float.isNaN(y[i]))
        sumXY2 += 1;
    else
        sumXY2 += Math.pow(x[i] - y[i], 2);
return Math.sqrt(sumXY2) / Math.sqrt(x.length);
...
floateuclideanDistanceSq2D(float x1, float y1, float x2, float y2)
euclidean Distance Sq D
float dx = x1 - x2;
float dy = y1 - y2;
return dx * dx + dy * dy;