Java Distance Calculate distancePointToPoint(final double x1, final double y1, final double x2, final double y2)

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

Description

The distance between 2 points in the same plane.

License

Open Source License

Parameter

Parameter Description
x1 x coordinate of P1
y1 y coordinate of P1
x2 x coordinate of P2
y2 y coordinate of P2

Return

distance

Declaration

public static double distancePointToPoint(final double x1, final double y1, final double x2, final double y2) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w  ww.j  av  a2 s . c  om
     * The distance between 2 points in the same plane. 
     * @param x1 x coordinate of P1
     * @param y1 y coordinate of P1
     * @param x2 x coordinate of P2
     * @param y2 y coordinate of P2
     * @return distance
     */
    public static double distancePointToPoint(final double x1, final double y1, final double x2, final double y2) {
        return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }
}

Related

  1. distanceMat(double[][] m1, double[][] m2)
  2. distanceMeter(double prevLat, double prevLon, double currentLat, double currentLon)
  3. distanceNd(double[] p1, double[] p2, double[] scratchSpace)
  4. distancePointToLine(final double x0, final double y0, final double x1, final double y1, final double xp, final double yp)
  5. distancePointToPlane(final double x0, final double y0, final double z0, final double[] normal, final double xp, final double yp, final double zp)
  6. distancePointToPoint(float x1, float y1, float x2, float y2)
  7. distances(double[][] arr, int[][] partners)
  8. distanceSq(double[] p1, double[] p2, double[] weights)
  9. distanceSQ(double[] pos1, double[] pos2)