記録

勉強したことに関するのノート。見返して分かるようにしてます。

y=1/2x²-9x-7

float x=0;
float y=0;
float a=0.5;
float b=-9;
float c=-7;

void setup() {
  size(600, 600);
  colorMode(HSB, 360, 100, 100);
  background(0, 0, 100);
  line(0, width/2, height, width/2);
  line(width/2, 0, width/2, height);
}

void draw() {
  pushMatrix();
  translate(width/2, height/2);
  rotate(PI);
  for (float x=-300; x<300; x=x+1) {
    y=a*x*x+b*x+c;
    //strokeWeight(5);
    noStroke();
    fill(0, 0, 0);
    ellipse(x, y, 5, 5);
  }
  popMatrix();
}

中学数学を勉強しなおすことになった。グラフ考えるのめんどくさいからprocessingで書いてくれないかなぁと思って作った。y=x²はなぜか表示されない(?)2次関数限定(?)ちょっと何がどうなってこうなったのか分からないけど何かできた、というのが今回のスケッチにおける私の感想。