lib/closest_point_0d.js
function closestPoint0d(a, x, result) {
  var d = 0.0;
  for(var i=0; i<x.length; ++i) {
    result[i] = a[i];
    var t = a[i] - x[i];
    d += t * t;
  }
  return d;
}
function closestPoint0d(a, x, result) {
  var d = 0.0;
  for(var i=0; i<x.length; ++i) {
    result[i] = a[i];
    var t = a[i] - x[i];
    d += t * t;
  }
  return d;
}
function closestPoint0d ( a , x , result ) { var d = 0.0 ; for ( var i = 0 ; i < x . length ; ++ i ) { result [ i ] = a [ i ] ; var t = a [ i ] - x [ i ] ; d += t * t ; } return d ; }
Closest point to a point is trivial
Closest point to a point is trivial