fractalkitty looking for math? fractalkitty.com

Mathober 2025

Wheel

#random#trig#grid#interactive#animation#math#geometry#polar#mathober

drawGrid


let t = 0;
let n = 25;

let d;

function setup() {
  createCanvas(500, 500);
  background(255);
  describe(
    "A wheel graph on staticky polar graph paper with 50 vertices that match the lines on the graph paper connected in a circle to each neighbor and then to the center. the vertices are drawn as clusters of dots and the wheel is turning counterclockwise."
  );
  rectMode(CENTER);
  strokeWeight(0.5);
  strokeCap(SQUARE);
  d = width / 25;
}

function draw() {
  background(245, 250, 255, 20);
  translate(width / 2, height / 2);
  stroke(100, 110, 120, 10);
  drawGrid();
  t -= 0.001;
  noFill();
  noStroke();
  fill(50, 60, 70, 50);
  for (let i = 0; i < 50; i++) {
    for (let j = 0; j < 10; j++) {
      h = randomGaussian(0, 0.015);
      g = randomGaussian(0, 2);
      circle(
        (g + d * 10) * cos((i * PI) / 25 + h + t),
        (g + d * 10) * sin((i * PI) / 25 + h + t),
        2
      );
    }
    push();
    stroke(50, 60, 70, 20);
    line(
      0,
      0,
      d * 10 * cos((i * PI) / 25 + t),
      d * 10 * sin((i * PI) / 25 + t)
    );
    line(
      d * 10 * cos(((i + 1) * PI) / 25 + t),
      d * 10 * sin(((i + 1) * PI) / 25 + t),
      d * 10 * cos((i * PI) / 25 + t),
      d * 10 * sin((i * PI) / 25 + t)
    );
    pop();
  }
  for (let j = 0; j < 10; j += 1) {
    h = randomGaussian(1, 2);
    g = randomGaussian(1, 2);
    circle(g, h, 2);
  }

  strokeWeight(1);
  noFill();
  stroke(100, 110, 120, 30);
  rect(0, 0, width / 1.02, width / 1.02);
  rect(0, 0, width / 1.04, width / 1.04);
}

function drawGrid() {
  for (let i = 0; i < n; i++) {
    rotate((2 * PI) / n);
    line(-width / 1.5, 0, width / 1.5, 0);
    circle(0, 0, (width / n) * 2 * i);
  }
  noStroke();
  for (let i = 0; i < 100; i++) {
    x = random(-width / 2, width / 2);
    y = random(-width / 2, width / 2);
    fill(245, 250, 255, 150);
    circle(x, y, 3);
  }
}

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