fractalkitty looking for math? fractalkitty.com

Genuary 2024

point line plane

#random#trig#3d#interactive#animation#polar#genuary


function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);
  a = random(0, width / 3);
  b = random(0, height / 3);
  c = random(width / 20, width / 10);
  d = random(width / 6, width / 4);
  e = random(width / 6, width / 4);
  f = random(width / 6, width / 4);
  g = random(0, 360);
  h = random(0, 360);
  i = random(0, 360);
  nRot = int(max(3, randomGaussian(20, 10)));
  angleMode(DEGREES);
  r1 = random(150, 255);
  b1 = random(150, 255);
  g1 = random(150, 255);
}

function draw() {
  background(r1 - 150, g1 - 150, b1 - 150);

  emissiveMaterial(r1 - 100, g1 - 100, b1 - 100);
  sphere(max(3000, 2 * max(width, height)), 24, 12);
  pointLight(255, 255, 255, 600, 600, 600);
  ambientLight(20);
  specularMaterial(r1, g1, b1);
  noStroke();
  orbitControl();

  t = frameCount;
  rotateX(15 * sin(t / 2));
  rotateY(15 * sin(t / 2));
  rotateZ(15 * sin(t / 2));
  for (let r = 0; r < nRot; r++) {
    push();

    rotateZ((r * 360) / nRot);
    translate(-c + b * cos(t / 4), -c + a * sin(t / 3), -c + d * cos(t / 5));
    rotateY(g + t / 4);
    rotateX(t / 2);
    plane(e, f);
    pop();
    push();

    rotateZ((r * 360) / nRot);
    translate(-d - a * cos(t / 4), -d + b * sin(t / 3), -d + f * sin(t / 5));
    rotateZ(g + t / 4);
    rotateY(-t / 4);
    cylinder(2, int(d), 12, 12);
    pop();

    push();

    rotateZ((r * 360) / nRot + t / 10);
    translate(-c + d * cos(t / 4), -i + b * sin(t / 3), -a + i * sin(t / 5));
    rotateZ(g + t / 4);
    rotateY(-t / 4);
    sphere(5, 20, 20);
    pop();
  }

}

function keyPressed() {
  frameCount = 0;
  setup();
  draw();
}