function pointsAlongArc(anchors) {
const spacing = (arcLength(anchors) / n) * sample - epsylon;
let remaining = spacing;
let current = 0;
const out = [];
let currentAnchor = anchors[0];
let maxIters = 1000;
while (current < anchors.length - 1) {
const nextAnchor = anchors[current + 1];
const dx = nextAnchor.x - currentAnchor.x;
const dy = nextAnchor.y - currentAnchor.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist > remaining) {
const frac = remaining / dist;
const x = currentAnchor.x + frac * dx;
const y = currentAnchor.y + frac * dy;
out.push({ x: xScale.invert(x), y: yScale.invert(y) });
currentAnchor = { x, y };
remaining = spacing;
} else {
remaining = remaining - dist;
current++;
currentAnchor = anchors[current];
}
if (!maxIters--) {
console.log("Finished early!");
break;
}
}
return out;
}