座標変換クイズ2

0 comments
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
float angle = 0.0;
float A;  //振幅
float w;  //角周波数
float p;  //初期位相
float t;  //経過時間
 
float rad = (TWO_PI/30.0)/60;
 
void setup() {
  size(400, 400);
  rectMode(CENTER);  //4角形の基準点を中心に変更
  noFill();
 
  A = 100.0;    //振幅を設定
  w = 1.0;    //角周波数を設定
  p = 0.0;    //初期位相を設定
  t = 0.0;    //経過時間を初期化
}
 
void draw() {
  background(255);
 
  for (int i = 0; i < 360; i += 30) {
    pushMatrix();
    translate(width/2, height/2);
    rotate(radians(angle + i));
 
    stroke(200);
    /*
  for (int x = 0; x <= 400; x += 20) {
     line(x, 0, x, 400);  //縦の線を描画
     }
     for (int y = 0; y <= 400; y += 20) {
     line(0, y, 400, y);  //横の線を描画
     }
     */
 
    float d = A*sin(w*t + p) + 100;
    stroke(0);
    rect(d, 0, 40, 40);  //4角形を描画
 
    t += rad;    //時間を進める
    if (t > TWO_PI) t = 0.0;
 
    popMatrix();
 
    angle += 0.1;
    if (angle >= 360.0) angle = 0.0;
  }
}
Posted by noguchi   @   23 6月 2017 0 comments

0 Comments

Sorry, comments are closed.

Stroom designed by Credit Cards In conjunction with Web Hosting Reseller , Dream Interpretation Guide , Best Website Hosting.