Insert all the points in a set
for ( var i = 0 ; i < n ; i ++ ) pts . add ( points [ i ] . toString ( ) ) ; for ( var i = 0 ; i < n ; i ++ ) for ( var j = i + 1 ; j < n ; j ++ ) { var x = points [ i ] [ 0 ] + points [ j ] [ 0 ] ; var y = points [ i ] [ 1 ] + points [ j ] [ 1 ] ;