1 distance: function (p1, p2) { 2 var result = Math.sqrt(Math.pow(Math.abs(p1.x - p2.x), 2) + Math.pow(Math.abs(p1.y - p2.y), 2)); 3 return result; 4 }