Java Distance Calculate distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2)

Here you can find the source of distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2)

Description

distance Between

License

Open Source License

Declaration

public static double distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2) 

Method Source Code

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

public class Main {
    public static double distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2) {
        //uses Pythagrean Theorem to calculate distance
        /*//from   ww  w. j a  v a 2s  .  co m
         * A X
         *   |\
         *   | \  c - distance/hypotenuse
         *   |  \
         *   |   \
         *   |____X B
         */

        double a = xpos1 - xpos2;
        double b = ypos1 - ypos2;
        double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));

        return c;
    }
}

Related

  1. distanceBetween(double latitude1, double longitude1, double latitude2, double longitude2)
  2. distanceBetween(double lon, double lat, double otherLon, double otherLat)
  3. distanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude)
  4. distanceBetween(double x1, double y1, double x2, double y2)
  5. distanceBetween(double x1, double y1, double x2, double y2)
  6. distanceBetween2GeoPositionsInMeters(double latA, double lngA, double latB, double lngB)
  7. distanceBetween2Points(float p1[], float p2[])
  8. distanceBetween2Points(float vectorX0, float vectorY0, float vectorXP, float vectorYP)
  9. distanceBetweenPoints(double ax, double ay, double bx, double by)