generateVectors = (polyCoords) => {
const xVec = [];
const yVec = [];
const n = polyCoords.xPool.length;
let lastTop = polyCoords.minX, lastBot = polyCoords.minX;
for (let i = 1; i < n - 1; i++) {
let x = polyCoords.xPool[i];
if (Math.random() < 0.5) {
xVec.push(x - lastTop);
lastTop = x;
} else {
xVec.push(lastBot - x);
lastBot = x;
}
}
xVec.push(polyCoords.maxX - lastTop);
xVec.push(lastBot - polyCoords.maxX);
let lastLeft = polyCoords.minY, lastRight = polyCoords.minY;
for (let i = 1; i < n - 1; i++) {
let y = polyCoords.yPool[i];
if (Math.random() < 0.5) {
yVec.push(y - lastLeft);
lastLeft = y;
} else {
yVec.push(lastRight - y);
lastRight = y;
}
}
yVec.push(polyCoords.maxY - lastLeft);
yVec.push(lastRight - polyCoords.maxY);
shuffle(yVec);
const vec = [];
for (let i = 0; i < n; i++) {
vec.push([xVec[i], yVec[i]]);
}
return vec;
}