Java Distance Calculate distanceSQ(double[] pos1, double[] pos2)

Here you can find the source of distanceSQ(double[] pos1, double[] pos2)

Description

distance SQ

License

Open Source License

Declaration

public static double distanceSQ(double[] pos1, double[] pos2) 

Method Source Code

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

public class Main {
    public static double distanceSQ(double[] pos1, double[] pos2) {
        double distanceSQ = 0.0;

        for (int i = 0; i < pos1.length; i++) {
            distanceSQ += (pos1[i] - pos2[i]) * (pos1[i] - pos2[i]);
        }//  ww  w  .  jav  a  2s .c o  m

        return distanceSQ;
    }
}

Related

  1. distancePointToPlane(final double x0, final double y0, final double z0, final double[] normal, final double xp, final double yp, final double zp)
  2. distancePointToPoint(final double x1, final double y1, final double x2, final double y2)
  3. distancePointToPoint(float x1, float y1, float x2, float y2)
  4. distances(double[][] arr, int[][] partners)
  5. distanceSq(double[] p1, double[] p2, double[] weights)
  6. distanceSq(double[] vec1, double[] vec2)
  7. distanceSq(float x0, float y0, float x1, float y1)
  8. distanceSq(int x0, int y0, int x1, int y1)
  9. distanceSqr(final float[] a, final float[] b)