fractalkitty looking for math? fractalkitty.com

Mathober 2025

octagonal heptagonal

#random#trig#grid#animation#math#geometry#number-theory#mathober

deltoctagonalheptagonaldrawGrid

let n = 25;
let delt = 1.5;
function setup() {
  createCanvas(500, 500);
  background(255);
  describe(
    "A octagons and heptagons drawn with points on the octagonal and heptagonal numbers. Because they are drawn so close, it looks like a light grey octagon with two lines connecting vertex 1 and 7 to the center with an inner darker heptagon connecting 1 and 6 via lines in the same way. It is on radial graph paper that has a staticky feel."
  );
  rectMode(CENTER);
  strokeWeight(0.5);
}

function draw() {
  background(245, 250, 255, 20);
  translate(width / 2, height / 2);
  stroke(100, 110, 120, 10);
  drawGrid();
  for (let j = 1; j < 1000; j++) {
    octagonal(j);
    heptagonal(j);
  }

  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 octagonal(n) {
  push();
  stroke(50, 60, 70);
  noFill();
  strokeWeight(0.01);
  r = (delt * n) / 8;
  beginShape();
  for (let i = 0; i < 8; i++) {
    x = r * cos((i * PI) / 4);
    y = r * sin((i * PI) / 4);
    vertex(x, y);
    if (
      (n % 2 === 1 && i === 1) ||
      (n % 2 === 0 && i === 3) ||
      (i === 2 && n === 1)
    ) {
      push();
      fill(90, 100, 110);
      circle(x, y, 2);
      pop();
    }
  }
  endShape(CLOSE);
  pop();
}

function heptagonal(n) {
  push();
  stroke(50, 60, 70);
  noFill();
  strokeWeight(0.01);
  r = (delt * n) / 7;
  beginShape();
  for (let i = 0; i < 7; i++) {
    x = r * cos((i * PI) / 3.5);
    y = r * sin((i * PI) / 3.5);
    vertex(x, y);
    if (
      (n % 2 === 1 && i === 1) ||
      (n % 2 === 0 && i === 3) ||
      (i === 2 && n === 1)
    ) {
      push();
      fill(90, 100, 110);
      circle(x, y, 2);
      pop();
    }
  }
  endShape(CLOSE);
  pop();
}
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 < 500; i++) {
    x = random(-width / 2, width / 2);
    y = random(-width / 2, width / 2);
    fill(245, 250, 255, 50);
    circle(x, y, 2);
  }
}