Here you can find the source of distance(double x0, double y0, double z0, double x1, double y1, double z1)
public static double distance(double x0, double y0, double z0, double x1, double y1, double z1)
//package com.java2s; /**//from w w w. j a va 2 s. c o m * Copyright (c) Lambda Innovation, 2013-2016 * This file is part of LambdaLib modding library. * https://github.com/LambdaInnovation/LambdaLib * Licensed under MIT, see project root for more information. */ public class Main { public static double distance(double x0, double y0, double z0, double x1, double y1, double z1) { return Math.sqrt(distanceSq(x0, y0, z0, x1, y1, z1)); } public static double distance(double[] vec1, double[] vec2) { return Math.sqrt(distanceSq(vec1, vec2)); } public static double distanceSq(double[] vec1, double[] vec2) { if (vec1.length != vec2.length) { throw new RuntimeException("Inconsistent length"); } double ret = 0.0; for (int i = 0; i < vec1.length; ++i) { double d = vec2[i] - vec1[i]; ret += d * d; } return ret; } public static double distanceSq(double x0, double y0, double z0, double x1, double y1, double z1) { return distanceSq(new double[] { x0, y0, z0 }, new double[] { x1, y1, z1 }); } }