Java Distance Calculate distanceSq(double[] p1, double[] p2, double[] weights)

Here you can find the source of distanceSq(double[] p1, double[] p2, double[] weights)

Description

distance Sq

License

Open Source License

Declaration

public static double distanceSq(double[] p1, double[] p2,
            double[] weights) 

Method Source Code

//package com.java2s;

public class Main {
    public static double distanceSq(double[] p1, double[] p2,
            double[] weights) {

        double sum = 0;
        for (int x = 0; x < p1.length; x++) {
            double z = (p1[x] - p2[x]) * weights[x];
            sum += z * z;//from  ww w .  j  a  va 2s  . c  om
        }

        return sum;
    }
}

Related

  1. distancePointToLine(final double x0, final double y0, final double x1, final double y1, final double xp, final double yp)
  2. distancePointToPlane(final double x0, final double y0, final double z0, final double[] normal, final double xp, final double yp, final double zp)
  3. distancePointToPoint(final double x1, final double y1, final double x2, final double y2)
  4. distancePointToPoint(float x1, float y1, float x2, float y2)
  5. distances(double[][] arr, int[][] partners)
  6. distanceSQ(double[] pos1, double[] pos2)
  7. distanceSq(double[] vec1, double[] vec2)
  8. distanceSq(float x0, float y0, float x1, float y1)
  9. distanceSq(int x0, int y0, int x1, int y1)