fractalkitty looking for math? fractalkitty.com

100 days of code

theodorusDance

#trig#3d#animation#math#spiral

sumThetathetapArrayXpArrayYclearA


let p = 20,sumTheta=0,n=300
let theta = []
let pArrayX=[];
let pArrayY=[];
function setup() {
  createCanvas(windowWidth, windowHeight,WEBGL);
  stroke(255);
}

function draw() {
  n=int(width/3.5)
  background(105,105,140);
  specularMaterial(205,205,255,150);
  pointLight(205, 255, 255, 0, 0, 600);
  pointLight(205, 255, 255, 0, 0, -600);
  rotateX(sin(frameCount/1000))
  rotateZ(sin(frameCount/1000))
  scale(1,-1)
  for(let i=1;i<n+1;i++){
    theta[i] = atan(1/sqrt(i));
    sumTheta = theta[i]+sumTheta;
    r = sqrt(i+1);
    x = round(r*cos(sumTheta),5);
    y=round(r*sin(sumTheta),5);
    pArrayX[i]= p*x;
    pArrayY[i]=p*y; 

  }
  for(let i=n;i>=2;i--){
    push()
    rotateY(0.5*sin(i/3-i/(3-2*sin(frameCount/2000))))
    rotateY(0.5*sin(i/3-i/(3-2*sin(frameCount/2000))))
    triangle(0,0,pArrayX[i],pArrayY[i],pArrayX[i-1],pArrayY[i-1]);
    pop()
  }
  clearA()
}
function clearA(){
  sumTheta=0
  theta = []
  pArrayX=[];
  pArrayY=[];
}