xxxxxxxxxx
43
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;
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);
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)
for (x = -max; x < +max+1; x++){
y = factor * formula(x);
point(x,y);
y = factor * formula2(x);
point(x,y);
}
factor += .1
}