xxxxxxxxxx
61
let max = 400;
let factor = .1;
let x,y;
function formula(x) {
// y = -x*x/100+50;
// y = -x;
// y = -sin(x) * 10;
// y = -x*x*x/1000 - x*x/100 + x/10 - 50;
y = -x*x*x/1000 - x*x/100 + x/10;
return y;
}
function formula2(x) {
// y = -x*x/100+50;
// y = -x;
// y = -sin(x) * 10;
// y = 1000/(-x*x*x/1000 - x*x/100 + x/10 - 50);
y = 1000/(-x*x*x/1000 - x*x/100 + x/10);
return y;
}
function setup() {
createCanvas(2*max, 2*max);
}
function draw() {
background(220);
translate(max,max);
stroke(255);
strokeWeight(2);
line(-max,0,+max,0);
line(0,-max,0,+max);
stroke(200,0,0)
noFill();
// First line
beginShape();
for (x = -max; x < +max+1; x++){
y = factor * formula(x);
curveVertex(x,y);
// y = factor * formula2(x);
// point(x,y);
}
endShape();
// Second line
beginShape();
for (x = -max; x < +max+1; x++){
y = factor * formula2(x);
curveVertex(x,y);
// y = factor * formula2(x);
// point(x,y);
}
endShape();
factor += .001
}