fractalkitty looking for math? fractalkitty.com

Coded Poems

eye of the needle

#random#trig#poem

whatIsChosenwhatExiststheIntuitiontheNegativeSpacetheDiameterOfSighttheExperimenttheSpaceBetweentoTreadLightlyneedleaMemorystring1

let whatIsChosen = 0;
let whatExists = 0;
let theIntuition = 0;
let theNegativeSpace;
let theDiameterOfSight;
let theExperiment;
let theSpaceBetween;
function setup() {
  theNegativeSpace = createCanvas(
    (c = max(600, min(windowWidth, windowHeight))),
    c
  );
  theDiameterOfSight = width / 2;
  theExperiment = theDiameterOfSight / 4;
  theSpaceBetween = theDiameterOfSight / 4;
  toTreadLightly();
  function toTreadLightly() {
    noFill();
    strokeWeight(0.01);
  }
  pixelDensity(20);
}
function draw() {
  translate(width / 2, height / 2);
  for (let i = 0; i < c * 2; i++) {
    needle();
  }
  theIntuition = whatIsChosen / whatExists;
  if (whatExists > 5999999) {
    noLoop();
  }
}
function needle() {
  whatExists++;
  thefirstTouchDist = random(0, width / 2);
  theFirstTouchAngle = random(0, PI * 2);
  theFirstTouchAcross = thefirstTouchDist * cos(theFirstTouchAngle);
  theFirstTouchVertical = thefirstTouchDist * sin(theFirstTouchAngle);
  theta = random(0, 2 * PI);
  theLastTouchAcross = theFirstTouchAcross + theExperiment * cos(theta);
  y2 = theFirstTouchVertical + theExperiment * sin(theta);

  cond1 =
    dist(theFirstTouchAcross, theFirstTouchVertical, 0, 0) <=
    theSpaceBetween * 2;
  cond2 = dist(theLastTouchAcross, y2, 0, 0) <= theSpaceBetween * 2;

  if ((cond1 && !cond2) || (cond2 && !cond1)) {
    whatIsChosen++;
    stroke(random(150, 255), random(220, 255), 255);
  } else {
    stroke(10);
  }
  line(theFirstTouchAcross, theFirstTouchVertical, theLastTouchAcross, y2);
}

function aMemory() {
  let string1 = str(theIntuition);
}