List of utility methods to do Distance Calculate
double | distance(double[] a, double[] b) Calculates the distance between two points represented by (n-dimensional) vectors. double dist = 0; for (int i = 0; i < a.length; i++) { double d = a[i] - b[i]; dist += d * d; return Math.sqrt(dist); |
double | distance(double[] a, double[] b) Measure distance between a and b return Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1] - b[1], 2));
|
double | distance(double[] p1, double[] p2) distance int nd = p1.length; double out = 0.0; for (int d = 0; d < nd; d++) { out += (p1[d] - p2[d]) * (p1[d] - p2[d]); return Math.sqrt(out); |
double | distance(double[] p1, double[] p2) distance double sum = 0; for (int i = 0; i < p1.length; i++) { sum += Math.pow(p1[i] - p2[i], 2); return Math.sqrt(sum); |
double | distance(double[] x, int p, int q, int dim) computes the euclidean distance of two dim-dimensional points double sum = 0.0; for (int i = 0; i < dim; ++i) { sum += Math.pow(x[p * dim + i] - x[q * dim + i], 2); return Math.sqrt(sum); |
int | distance(final Class> child, final Class> parent) Gets derivation distance of an object Possible values are: - -1 = child !instanceof parent - 0 = child is the same class as the parent one - greater than 0 = child is the nth of the parent Copied from https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/reflect/InheritanceUtils.java if (child == null || parent == null) { return -1; if (child.equals(parent)) { return 0; final Class<?> cParent = child.getSuperclass(); int d = parent.equals(cParent) ? 1 : 0; ... |
double | distance(final double x, final double y) Returns the Euclidean distance between the origin and the point (x, y). return Math.sqrt(x * x + y * y);
|
double | distance(final double x1, final double y1, final double x2, final double y2) Calculate the distance between two coordinates. final double dx = x2 - x1; final double dy = y2 - y1; final double distance = Math.sqrt(dx * dx + dy * dy); return distance; |
Double | distance(final double x1, final double y1, final double x2, final double y2) distance final double dx = Math.max(x1, x2) - Math.min(x1, x2); final double dy = Math.max(y1, y2) - Math.min(y1, y2); return Math.sqrt(dx * dx + dy * dy); |
double | distance(final double[] a, final double[] b) get the length of (a - b). return Math.sqrt(squareDistance(a, b));
|