fractalkitty looking for math? fractalkitty.com

early works

lensAnimate

#trig#animation#math#light

firstlightBeamplotP

let x=0,
    y=0,
    a=100,
    first = 0;
function setup() {
  createCanvas(400, 400);
  background(0);
  stroke(255);
  plotP(0);
  angleMode(DEGREES)
}
function draw() {
  translate(width/3,width/2);
  yCount = (frameCount-800)*2;
  strokeWeight(0.1);
  stroke(255*sin(frameCount/10),255-frameCount/30,255*cos(frameCount/100))
  lightBeam(yCount);
  if (frameCount >1600){
      fill(255);
      frameCount = 0
      background(0);
      strokeWeight(2);
      plotP();
      }
  
}

function lightBeam(yCount){
    msX = 400;
    msY = yCount;
    m = (msY)/(msX-a);//slope
    a1 = m*m;
    b1 = -(2*a*m*m+4*a);
    c1 = a*a*m*m;
    tmp = (b1*b1-4*a1*c1)
    x1 = (-b1-sqrt(tmp))/(2*a1);
    y1 = sqrt(4*a*x1);
    if(msY<0){
      line(msX,msY,x1,y1);
      line(x1,y1,width,y1)
    }
    if(msY>=0){
      line(msX,msY,x1,-y1);
      line(x1,-y1,width,-y1)
    }
}

function plotP(first){
  if (first ===0){
   translate(width/3,width/2); 
  }
  for (i=-100;i<100;i=i+1){
    t=i/90;
    y=2*a*t;
    x=a*t*t;//y = 2asqrt(xa)
    circle(x,y,2);
    circle(a,0,10);
    line(-a,-width/2,-a,width/2)
  first = 1;
  }
}