Java Distance Calculate DistanceBetweenPoints(double x1, double y1, double x2, double y2)

Here you can find the source of DistanceBetweenPoints(double x1, double y1, double x2, double y2)

Description

Distance Between Points

License

BSD License

Declaration

public static double DistanceBetweenPoints(double x1, double y1,
            double x2, double y2) 

Method Source Code

//package com.java2s;
// LICENSE:       This file is distributed under the BSD license.

public class Main {
    public static double DistanceBetweenPoints(double x1, double y1,
            double x2, double y2) {
        return Math.sqrt(DistanceSquareBetweenPoints(x1, y1, x2, y2));
    }// w  w w . j av a  2s.com

    public static double DistanceSquareBetweenPoints(double x1, double y1,
            double x2, double y2) {
        double d1 = x1 - x2;
        double d2 = y1 - y2;
        double d = d1 * d1 + d2 * d2;
        if (d <= 0)
            return 0;
        else
            return d;
    }
}

Related

  1. distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2)
  2. distanceBetween2GeoPositionsInMeters(double latA, double lngA, double latB, double lngB)
  3. distanceBetween2Points(float p1[], float p2[])
  4. distanceBetween2Points(float vectorX0, float vectorY0, float vectorXP, float vectorYP)
  5. distanceBetweenPoints(double ax, double ay, double bx, double by)
  6. distanceBetweenPoints(float vx, float vy, float wx, float wy)
  7. distanceBetweenPoints(float[] xyz1, float[] xyz2)
  8. distanceByLBS(double lo1, double la1, double lo2, double la2)
  9. distanceCircle(int i0, int i1, int dir, int size)