fractalkitty looking for math? fractalkitty.com

Mathober 2024

polynomial

#trig#grid#color#text#interactive#animation#math#geometry#mathober

bgColgColnGridgSpacedrawGrid

const bgCol = "#447abd";
const gCol = "#a2c2e8";
const nGrid = 20;
let gSpace;
let w;

function setup() {
  w = max(400, min(windowWidth, windowHeight) * 0.9);
  gSpace = (w / nGrid) * 0.95;
  describe(
    "a group of polynomials start in an almost hanging sack formation and wiggle back and forth on a blueprint design. Each polynomial moves different giving an almost fabric feel too it at first."
  );
  createCanvas(w, w);
  rectMode(CENTER);

  angleMode(DEGREES);
  textSize(16);
}

function draw() {
  background(bgCol);
  translate(w / 2, w / 2);
  drawGrid();
  t = frameCount / 3;
  stroke(255);
  strokeWeight(2);
  push();
  for (let j = 0; j < 30; j += 0.5) {
    for (let i = -w / 2 + gSpace; i < w / 2 - gSpace; i += 0.5) {
      let y =
        0.000000001 *
          (i * j - 1 * sin(t)) *
          (i + 2 * sin(t / 2)) *
          (3 * i - 3 * sin(t / 4)) *
          (-j * i - 1 * cos(t / 5)) +
        0.00001 * i * sin(t) * (i - w / 2) * (i + w / 2) * cos(t * j) +
        (j * gSpace) / 2 -
        6 * gSpace;
      circle(i, y, 2);
    }
  }
  pop();
  noStroke();
  fill(bgCol);
  rect(-width / 2 + gSpace / 2, 0, gSpace, height);
  rect(width / 2 - gSpace / 2, 0, gSpace, height);
  rect(0, -width / 2 + gSpace / 2, height, gSpace);
  rect(0, width / 2 - gSpace / 2, height, gSpace);

  fill(gCol);
  text("polynomial", -w / 2 + 10, w / 2 - 5);
}

function drawGrid() {
  stroke(gCol);
  strokeWeight(0.3);
  for (let i = 1; i <= nGrid; i++) {
    for (let j = 1; j <= nGrid; j++) {
      line(
        -w / 2 + gSpace * i,
        -w / 2 + gSpace,
        -w / 2 + gSpace * i,
        w / 2 - gSpace
      );
      line(
        -w / 2 + gSpace,
        -w / 2 + gSpace * i,
        w / 2 - gSpace,
        -w / 2 + gSpace * i
      );
    }
  }
  noStroke();
  fill(bgCol);
  rect(-width / 2 + gSpace / 2, 0, gSpace, height);
  rect(width / 2 - gSpace / 2, 0, gSpace, height);
  rect(0, -width / 2 + gSpace / 2, height, gSpace);
  rect(0, width / 2 - gSpace / 2, height, gSpace);
  noFill();
  stroke(gCol);
  strokeWeight(3);

  noFill();
  strokeWeight(3);
  rect(0, 0, w - 2 * gSpace);
}

function mousePressed() {
  setup();
  draw();
}
function windowResized() {
  setup();
  draw();
}