Java Distance Calculate distance(final double[] t1, final double[] t2)

Here you can find the source of distance(final double[] t1, final double[] t2)

Description

distance

License

Open Source License

Declaration

public static double distance(final double[] t1, final double[] t2) 

Method Source Code

//package com.java2s;
/**/*from  ww  w .  ja  v a 2s. co  m*/
 * Copyright? 2014-2016 LIST (Luxembourg Institute of Science and Technology), all right reserved.
 * Authorship : Olivier PARISOT, Yoanne DIDRY
 * Licensed under GNU General Public License version 3
 */

public class Main {
    public static double distance(final double[] t1, final double[] t2) {
        if (t1.length != t2.length)
            throw new IllegalStateException("distance() -> " + t1.length + "<>" + t2.length);
        double sum = 0d;
        for (int i = 0; i < t1.length; i += 1) {
            sum += (t1[i] - t2[i]) * (t1[i] - t2[i]);
        }
        return Math.sqrt(sum);
    }
}

Related

  1. distance(final double x1, final double y1, final double x2, final double y2)
  2. distance(final double x1, final double y1, final double x2, final double y2)
  3. distance(final double[] a, final double[] b)
  4. Distance(final double[] minCorner, final double[] maxCorner)
  5. distance(final double[] p, final double[] q)
  6. distance(final String c1, final String c2, final String c1Prev, final String c2Prev)
  7. distance(float aX, float aY, float bX, float bY)
  8. distance(float speed, float delta)
  9. distance(float value1, float value2)