for (let j = i + 1; j < sgts.length; j++) { x = (sgts[i][0]['y'] - sgts[j][0]['y']); y = (sgts[i][0]['x'] - sgts[j][0]['x']);