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

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

Description

distanced

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;

public class Main {
    public static double distance2d(double x1, double y1, double x2, double y2) {
        double dx = Math.abs(x2 - x1);
        double dy = Math.abs(y2 - y1);
        double max = Math.max(dx, dy);
        if (max == 0)
            return 0;
        dx /= max;/*from  ww  w .  j  a va 2s  . c o m*/
        dy /= max;
        return max * Math.sqrt(dx * dx + dy * dy);
    }
}

Related

  1. distance(String coord1, String coord2, char unit)
  2. distance(String seq1, String seq2)
  3. distance2(float x, float y, float x1, float y1)
  4. distance2(float x1, float y1, float x2, float y2)
  5. distance2(int x1, int y1, int x2, int y2)
  6. distance2D(double x1, double z1, double x2, double z2)
  7. distance2points3D(double[] p1, double[] p2)
  8. distance3d(double x1, double y1, double z1, double x2, double y2, double z2)
  9. distance3Sq(double x1, double y1, double z1, double x2, double y2, double z2)