Java Distance Calculate distance(double u, double v, double pu, double pv)

Here you can find the source of distance(double u, double v, double pu, double pv)

Description

Returns the distance from point u,v to point pu,pv

License

Open Source License

Parameter

Parameter Description
u u coordinate of point u,v
v v coordinate of point u,v
pu pu coordinate of point pu,pv
pv pv coordinate of point pu,pv

Return

The distance from one point to the other using Pythagoras

Declaration

public static double distance(double u, double v, double pu, double pv) 

Method Source Code

//package com.java2s;
/*//from w  ww  .  j ava  2  s .c  om
 * Texture Generator Library by Andy Gibson
 *
 * This software is distributed under the terms of the FSF Lesser
 * Gnu Public License. It is provided as-is, without any express
 * or implied warranty, or guarantee of any kind.
 *
 */

public class Main {
    /**
     * Returns the distance from point u,v to point pu,pv
     * 
     * @param u
     *            u coordinate of point u,v
     * @param v
     *            v coordinate of point u,v
     * @param pu
     *            pu coordinate of point pu,pv
     * @param pv
     *            pv coordinate of point pu,pv
     * @return The distance from one point to the other using Pythagoras
     */
    public static double distance(double u, double v, double pu, double pv) {

        double du = pu - u;
        double dv = pv - v;
        dv = dv * dv;
        du = du * du;

        return Math.sqrt(dv + du);
    }
}

Related

  1. distance(double lat1, double lon1, double lat2, double lon2)
  2. distance(double latA, double logA, double latB, double logB)
  3. distance(double latDegrees1, double lonDegrees1, double latDegrees2, double lonDegrees2)
  4. distance(double latitude1, double longitude1, double latitude2, double longitude2)
  5. distance(double lon1, double lat1, double lon2, double lat2)
  6. distance(double w1, double h1, double w2, double h2, int type)
  7. distance(double x, double y, double xx, double yy)
  8. distance(double x0, double y0, double x1, double y1)
  9. distance(double x0, double y0, double z0, double x1, double y1, double z1)