Here you can find the source of distanceSq(double[] vec1, double[] vec2)
public static double distanceSq(double[] vec1, double[] vec2)
//package com.java2s; /**// w ww . java 2 s . co 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 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 }); } }