fractalkitty looking for math? fractalkitty.com

100 days of code

trefoil_Day23

#trig#3d#interactive#animation#math#parametric

let cnt = 1,p=20
function setup() {
  createCanvas(400, 400,WEBGL);
  angleMode(DEGREES);
  fill(100,150,200);
  noStroke();
}

function draw() {
  background(0)
  ambientLight(60, 60, 60);
  rotateX(frameCount/10)
  rotateY(frameCount/10)
  rotateZ(frameCount/10)
  pointLight(255, 255, 255, 100,100, 100);
  ambientMaterial(100,100,250);
  orbitControl();
  for(let t = 0;t<360;t++){
    x= p*(sin(t) + 2*sin(2*t));
    y = p*(cos(t)- cos(2*t))
    z = -p*sin(3*t)
    push()
      translate(x,y,z)
      sphere(5)
    pop()
}
  t = frameCount;
  x= p*(sin(t) + 2*sin(2*t));
  y = p*(cos(t)- cos(2*t))
  z = -p*sin(3*t)
  ambientMaterial(200,100,100);
  push()
    translate(x,y,z)
    sphere(12)
  pop()
  p = p+0.5*sin(frameCount/2)
}