fractalkitty looking for math? fractalkitty.com

100 days of code

cassini_Day19

#random#trig#animation#math

cassini

function setup() {
  createCanvas(600, 600);
  angleMode(DEGREES);
  fill(0);
  strokeWeight(0.2)
}


function draw() {
  background(255,255,255,20);
  translate(width/2,width/2);
  t = frameCount/2
  a = 150*cos(t)+100*tan(t)
  b = 20*sin(t)*cos(t) -50*tan(t)
  for(let i=0;i<100;i++){
    noStroke()
    fill(55,205,205,5)
    circle(random(-width/2,width/2),random(-width/2,width/2),50)
  }
    stroke(0)
    noFill()
    cassini(600)
    cassini((200))
    noStroke()
    fill(0,0,0,5)
    cassini(100)
    fill(25,255,255,5)
    cassini(50)
    push()
  rotate(90)
  stroke(0)
    noFill()
    cassini(600)
    cassini((200))
    noStroke()
    fill(0,0,0,5)
    cassini(100)
    fill(25,255,255,5)
    cassini(50)
    pop()
    
  
}

function cassini(n){
  for(t=0;t<360;t++){
  C = a*a*cos(2*t)+sqrt(pow(b,4)-a*a*sin(2*t)*sin(2*t))
  x= cos(t)*sqrt(C)
  y = sin(t)*sqrt(C)
  circle(x,y,n);
  C = a*a*cos(2*t)-sqrt(pow(b,4)-a*a*sin(2*t)*sin(2*t))
  x= cos(t)*sqrt(C)
  y = sin(t)*sqrt(C)
  circle(x,y,n);
  }
}