Here you can find the source of distanceSQ(double[] pos1, double[] pos2)
public static double distanceSQ(double[] pos1, double[] pos2)
//package com.java2s; //License from project: Open Source License public class Main { public static double distanceSQ(double[] pos1, double[] pos2) { double distanceSQ = 0.0; for (int i = 0; i < pos1.length; i++) { distanceSQ += (pos1[i] - pos2[i]) * (pos1[i] - pos2[i]); }// ww w . jav a 2s .c o m return distanceSQ; } }