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

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

Description

dist

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double dist(double x1, double y1, double z1, double x2, double y2, double z2) {
        return sqrt(distSq(x1, y1, z1, x2, y2, z2));
    }//from  w w  w  . jav a2  s  . c o  m

    public static double sqrt(double d) {
        if (d == 0D)
            return 0D;
        else if (d == 1D)
            return 1D;
        else
            return Math.sqrt(d);
    }

    public static double distSq(double x1, double y1, double z1, double x2, double y2, double z2) {
        return (sq(x2 - x1) + sq(y2 - y1) + sq(z2 - z1));
    }

    public static double sq(double f) {
        return f * f;
    }

    public static double sq(double f, int i) {
        if (i == 2)
            return sq(f);
        double f1 = 1D;
        for (int j = 0; j < i; j++)
            f1 *= f;
        return f1;
    }
}

Related

  1. computeDistanceInMiles(Double lat1, Double lon1, Double lat2, Double lon2)
  2. computeDistanceMap(int[][] image)
  3. computeDistanceSqr(double t, double b1, double b2, double b3, double b4, double b5, double b6)
  4. computeDistanceUsingRadians(double lat1Radians, double lng1Radians, double lat2Radians, double lng2Radians)
  5. dist(double lat1, double long1, double lat2, double long2)
  6. dist(final double x0, final double y0, final double x1, final double y1)
  7. dist(float x1, float y1, float x2, float y2)
  8. dist(float x1, float y1, float x2, float y2)
  9. dist(float x1, float y1, float x2, float y2)