borderRays = {
function toUnit(v1) {
const [x, y] = v1;
const length = Math.sqrt(x * x + y * y);
return [x/length, y/length];
}
function getUnitNormal(v1, v2) {
const dx = v2[0] - v1[0];
const dy = v2[1] - v1[1];
const norm = [dy, -dx];
return toUnit(norm);
}
const hullSegments = [];
const hullCoords = kyrgyzstan.geometry.coordinates[0];
for (let i = 0; i < hullCoords.length-1; i++) {
const [coord, nextCoord] = [hullCoords[i], hullCoords[i+1]];
hullSegments.push({
coords: [coord, nextCoord],
normal: getUnitNormal(coord, nextCoord)
});
}
const hullSegmentPairs = [];
for (let i = 0; i < hullSegments.length; i++) {
const j = (i == hullSegments.length) ? 0 : i+1;
const [segment, nextSegment] = [hullSegments[i], hullSegments[j]];
hullSegmentPairs.push({
segments: [segment, nextSegment]
});
}
return hullSegmentPairs
}