toeplitz = function (points) {
const test = testSquare(points);
let min = 0;
let solution;
for (let i = 0; i < points.length; i++) {
for (let j = 0; j < i; j++) {
const a = points[i];
const b = points[j];
const dist2 = (a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2;
if (dist2 <= min) continue;
const m = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
const n = [(b[1] - a[1]) / 2, (a[0] - b[0]) / 2];
const c = [m[0] - n[0], m[1] - n[1]];
const d = [m[0] + n[0], m[1] + n[1]];
const t = test(a, c, b, d);
if (t) {
min = dist2;
solution = t;
}
}
}
return solution;
}