Here you can find the source of dist(double x1, double y1, double z1, double x2, double y2, double z2)
public static double dist(double x1, double y1, double z1, double x2, double y2, double z2)
//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; } }