Java Distance Calculate distance(float[] values1, float[] values2)

Here you can find the source of distance(float[] values1, float[] values2)

Description

distance

License

Open Source License

Declaration

public static double distance(float[] values1, float[] values2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double distance(float[] values1, float[] values2) {
        if (values1 != null && values2 != null) {
            if (values1.length == values2.length) {
                float sum = 0;
                for (int i = 0; i < values1.length; i++) {
                    sum += (values2[i] - values1[i]) * (values2[i] - values1[i]);
                }//  w w  w.j  a  v  a  2s.  com

                return Math.sqrt(sum);
            }
        }

        return -1;
    }
}

Related

  1. distance(float x1, float x2, float y1, float y2)
  2. distance(float x1, float y1, float x2, float y2)
  3. distance(float x1, float y1, float x2, float y2)
  4. distance(float x1, float y1, float x2, float y2)
  5. distance(float[] p1, float[] p2)
  6. distance(int ax, int ay, int bx, int by)
  7. distance(int first, int second)
  8. distance(int fx, int fy, int sx, int sy)
  9. distance(int one, int two)