function phyllotaxis(
n,
{ radius = 1, center: [cx, cy] = [0, 0], thetaOffset = 0 } = {}
) {
const lim = 5;
const nodetoKeep = []
thetaOffset;
const length = typeof n === "number" ? n : n.length;
const goldenRatio = (1 + Math.sqrt(5)) / 2;
const theta = (2 * Math.PI) / goldenRatio;
const nodes = Array(length)
.fill(undefined)
.map((_, i) => {
const scaledTheta = theta * i;
const scaledRadius = radius * Math.sqrt(scaledTheta + thetaOffset);
const x = Math.cos(scaledTheta) * scaledRadius + cx;
const y = Math.sin(scaledTheta) * scaledRadius + cy;
return { x, y };
});
for (let i = 0; i < nodes.length; ++i) {
}
return typeof n === "number"
? nodes
: n.map((datum, i) => ({ datum, ...nodes[i] }));
}