public static double distanceSquared ( double [ ] pointA , double [ ] pointB , int offsetB ) { assert ( pointA . length == pointB . length + offsetB ) ; double distance = 0.0 ; for ( int i = 0 ; i < pointA . length ; i ++ ) { double d = pointA [ i ] - pointB [ i + offsetB ] ; distance += d * d ; } return distance ; }
Calculates the squared Euclidean distance of two points . Starts at dimension offset + 1 of pointB .