Java Distance Calculate distance3d(double x1, double y1, double z1, double x2, double y2, double z2)

Here you can find the source of distance3d(double x1, double y1, double z1, double x2, double y2, double z2)

Description

distanced

License

Open Source License

Declaration

public static double distance3d(double x1, double y1, double z1, double x2, double y2, double z2) 

Method Source Code

//package com.java2s;

public class Main {
    public static double distance3d(double x1, double y1, double z1, double x2, double y2, double z2) {
        double dx = Math.abs(x2 - x1);
        double dy = Math.abs(y2 - y1);
        double dz = Math.abs(z2 - z1);
        double max = Math.max(dx, dy);
        max = Math.max(max, dz);/*from  www .  jav a 2  s. c o  m*/
        if (max == 0)
            return 0;
        dx /= max;
        dy /= max;
        dz /= max;
        return max * Math.sqrt(dx * dx + dy * dy + dz * dz);
    }
}

Related

  1. distance2(float x1, float y1, float x2, float y2)
  2. distance2(int x1, int y1, int x2, int y2)
  3. distance2d(double x1, double y1, double x2, double y2)
  4. distance2D(double x1, double z1, double x2, double z2)
  5. distance2points3D(double[] p1, double[] p2)
  6. distance3Sq(double x1, double y1, double z1, double x2, double y2, double z2)
  7. distance_Sphere(double rlon1, double rlat1, double rlon2, double rlat2)
  8. distance_to_endpoint(int x1, int y1, int x2, int y2, int x, int y)
  9. distance_to_endpoint(int x1, int y1, int x2, int y2, int x, int y)