fractalkitty looking for math? fractalkitty.com

Mathober 2024

frustum

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

bgColgColnGridplayersgSpacefrustumsdrawGrid


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

function setup() {
  w = max(400, min(windowWidth, windowHeight) * 0.9);
  describe(" ");
  players = [];
  createCanvas(w, w);
  describe(
    "6 cones sliced into frustums rotating and dancing with rotational symmetry on a blueprint design. "
  );
  rectMode(CENTER);
  nV = 3;
  mul = [0.89, 0.92, 0.93, 0.935, 0.935, 0.94, 0.945];
  r = (w * 0.82) / 2;
  d = w;
  angleMode(DEGREES);
  textSize(16);
  gSpace = (w / nGrid) * 0.95;
}

function draw() {
  background(bgCol);
  translate(w / 2, w / 2);
  t = frameCount;
  noStroke();
  noFill();
  strokeWeight(1);
  x = 0;
  y = gSpace * 7;
  w1 = width / 4;
  d = gSpace;

  r1 = 1.8;

  for (let i = 0; i < 6; i++) {
    push();
    rotate(i * 60 + t / 5);
    x = 0;
    y = gSpace * 7;
    w1 = width / 4;
    d = gSpace;
    frustums(0, y, w1, w1 / 3);
    for (let i = 1; i < 10; i++) {
      y = y - w1 / r1 - ((gSpace * i) / 10) * sin(t);
      w1 = w1 / r1;
      frustums(
        ((i * w) / 80) * cos(t),
        y + ((i * w) / 80) * sin(t),
        w1,
        w1 / 3
      );
    }
    pop();
  }

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

function frustums(x, y, w1, h1) {
  stroke(255);
  fill(162, 194, 232, 50);
  ellipse(x, y, w1, h1);
  ellipse(x, y - w1 / r1, w1 / r1, h1 / r1);
  line(x - w1 / 2, y, x - w1 / (r1 * 2), y - w1 / r1);
  line(x + w1 / 2, y, x + w1 / (r1 * 2), y - w1 / r1);
}
function drawGrid() {
  gSpace = (w / nGrid) * 0.95;
  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
      );
    }
  }
  noFill();
  strokeWeight(3);
  rect(0, 0, w - 2 * gSpace);
}

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