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

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

Description

Calculates distance between the two points (x1,y1) and (x2,y2)

License

Open Source License

Parameter

Parameter Description
x1 a parameter
y1 a parameter
x2 a parameter
y2 a parameter

Declaration

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

Method Source Code

//package com.java2s;
/**/*w  w w  .j  ava2  s. c  o m*/
 *    Copyright (C) 2009, 2010 
 *    State of California,
 *    Department of Water Resources.
 *    This file is part of DSM2 Grid Map
 *    The DSM2 Grid Map is free software: 
 *    you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    DSM2 Grid Map is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details. [http://www.gnu.org/licenses]
 *    
 *    @author Nicky Sandhu
 *    
 */

public class Main {
    /**
     * Calculates distance between the two points (x1,y1) and (x2,y2)
     * 
     * @param x1
     * @param y1
     * @param x2
     * @param y2
     * @return
     */
    public static double distanceBetween(double x1, double y1, double x2, double y2) {
        double delx = x2 - x1;
        double dely = y2 - y1;
        return Math.sqrt(delx * delx + dely * dely);
    }
}

Related

  1. distanceBase(double[] coord1, double[] coord2, int order)
  2. distanceBetween(double latitude1, double longitude1, double latitude2, double longitude2)
  3. distanceBetween(double lon, double lat, double otherLon, double otherLat)
  4. distanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude)
  5. distanceBetween(double x1, double y1, double x2, double y2)
  6. distanceBetween(double xpos1, double ypos1, double xpos2, double ypos2)
  7. distanceBetween2GeoPositionsInMeters(double latA, double lngA, double latB, double lngB)
  8. distanceBetween2Points(float p1[], float p2[])
  9. distanceBetween2Points(float vectorX0, float vectorY0, float vectorXP, float vectorYP)