Public
Edited
May 26
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cx = W / 3
Insert cell
cy = H / 2
Insert cell
dots = {
const dots = [];
const π = Math.PI;
dots.push([cx, cy, 0]);
let α = π;
let α0 = 0;
let counter = 0;
const ƒ = (t) => (a / 2 / π) * t;
const ƒƒ = (t) => {
const r = ƒ(t);
return {
x: cx + r * Math.cos(t),
y: cy + r * Math.sin(t)
};
};
let test = 0;
while (true) {
test++;
const r = ƒ(α);
const xy = ƒƒ(α);
const a1 = α;
const s = Math.cos(a1);
const c = Math.sin(a1);
const a2 = Math.atan2(c - a1 * s, s + a1 * c);
if (r < a && false) {
α += a / 100;
α0 += a / 100;
} else {
α += a / r;
α0 += a / r;
}
if (xy.x > -pad && xy.x < W + pad && xy.y > -pad && xy.y < H + pad) {
counter++;
dots.push([xy.x, xy.y, a2]);
if (dots[dots.length - 2][3] === -1) {
dots[dots.length - 1][3] = 1;
}
} else {
dots[dots.length - 1][3] = -1;
}
if (α0 > 2 * π) {
α0 = 0;
if (!counter) {
break;
}
counter = 0;
}
if (test > 1e6) {
break;
}
}
return dots;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more