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

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

Description

distance

License

BSD License

Parameter

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

Declaration

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

Method Source Code

//package com.java2s;
/**//from w w  w.j a  va  2s  .c o m
 * <p>
 * Useful math functions. :)
 * </p>
 * <p>
 * <span class="BSDLicense"> This software is distributed under the <a
 * href="http://hci.stanford.edu/research/copyright.txt">BSD License</a>. </span>
 * </p>
 * 
 * @author <a href="http://graphics.stanford.edu/~ronyeh">Ron B Yeh</a> (ronyeh(AT)cs.stanford.edu)
 */

public class Main {
    /**
     * @param x1
     * @param y1
     * @param x2
     * @param y2
     * @return
     */
    public static double distance(double x1, double y1, double x2, double y2) {
        return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    }
}

Related

  1. distance(double x, double y, double xx, double yy)
  2. distance(double x0, double y0, double x1, double y1)
  3. distance(double x0, double y0, double z0, double x1, double y1, double z1)
  4. distance(double x1, double y1, double x2, double y2)
  5. distance(double x1, double y1, double x2, double y2)
  6. distance(double x1, double y1, double z1, double x2, double y2, double z2)
  7. distance(double xOrigin, double yOrigin, double xDestination, double yDestination)
  8. distance(double[] a, double[] b)
  9. distance(double[] a, double[] b)