xxxxxxxxxx
39
let points = [];
let t = 0;
const numPoints = 100;
let deltaT;
let oldPos = 0;
const W = 1000;
const H = 1000;
function setup() {
// deltaT = (3 - sqrt(5)) * PI;
deltaT = 0.01;
createCanvas(W , H);
for (let ni = 0; ni < numPoints; ni++) {
points.push(createVector(random(0, width),random(0, height)));
}
background(220);
}
function draw() {
if (t < 100000) {
for (zi = 0; zi < 200; zi++) {
const theta = (cos(t) + 1) / 2;
let pos = createVector(0, 0);
for (let ni = 0; ni < numPoints; ni++) {
let tmp = points[ni].copy();
tmp.mult(binomialCoefficient(
numPoints - 1, ni) * pow(theta, ni) * pow((1 - theta),
numPoints - 1 - ni));
pos.add(tmp);
}
if (oldPos != 0) {
stroke(0, 1);
line(oldPos.x, oldPos.y, pos.x, pos.y);
}
t += deltaT;
oldPos = pos;
}
}
}