fractalkitty looking for math? fractalkitty.com

Coded Poems

mathober day-6: Weak

#trig#image#3d#interactive#animation#poem#mathober

img1img2lines


let img1, img2;

function preload() {
  img1 = loadImage("/assets/snark_1.jpg");
  img2 = loadImage("/assets/ball-nebula.jpg");
}

function setup() {
  createCanvas(600, 600, WEBGL);
}

function draw() {
  t = frameCount / 300;
  background(0);
  texture(img2);
  noStroke();
  push();
  rotateX(90);
  rotateY(t);
  rotateZ(t);
  torus(1000, 1000, 24);
  pop();
  texture(img2);
  orbitControl();
  rotateX(PI * 2 * sin(t));
  rotateZ((PI / 4) * sin(t));
  rotateZ((PI / 4) * sin(t));
  for (let i = 0; i < pts.length; i++) {
    push();
    pts[i][2] = 100 * sin(i * t);
    translate(pts[i][0], pts[i][1], pts[i][2]);
    noStroke();
    sphere(10, 24, 24);
    pop();
  }
  for (let i = 0; i < lines.length; i++) {
    fill(25);
    stroke(25);
    line(
      pts[lines[i][0]][0],
      pts[lines[i][0]][1],
      pts[lines[i][0]][2],
      pts[lines[i][1]][0],
      pts[lines[i][1]][1],
      pts[lines[i][1]][2]
    );
  }
  noFill();
}

let pts = [
  [0, 0, 0],
  [100, -50, 0],
  [-100, -50, 0],
  [10, 100, 0],
  [-150, -20, 0],
  [-150, -80, 0],
  [-155, -50, 0],
  [-200, -10, 0],
  [-120, 20, 0],
  [-190, 40, 0],
  [-80, 130, 0],
  [0, 160, 0],
  [-10, 90, 0],
  [-80, -110, 0],
  [80, -110, 0],
  [150, -20, 0],
  [150, -80, 0],
  [155, -50, 0],
  [200, -10, 0],
  [120, 20, 0],
  [190, 40, 0],
  [80, 130, 0]
];

let lines = [
  [0, 1],
  [0, 2],
  [0, 3],
  [2, 4],
  [2, 5],
  [4, 6],
  [5, 7],
  [4, 8],
  [7, 8],
  [7, 9],
  [6, 9],
  [9, 10],
  [10, 3],
  [10, 11],
  [11, 12],
  [12, 8],
  [13, 5],
  [13, 6],
  [14, 13],
  [14, 16],
  [14, 17],
  [1, 16],
  [1, 15],
  [15, 17],
  [16, 18],
  [18, 19],
  [18, 20],
  [15, 19],
  [17, 20],
  [19, 12],
  [20, 21],
  [21, 11],
  [21, 3]
];