CG
今日からコンピュータグラフィックスの集中講義。1限から4限まで出たのはかなり久しぶりだ(ぉ
座標変換やらポリゴンやらの話でかなり面白い。同じ系統でも誰かさんの何とかっていう授業よりよっぽど分かりやすいなぁ。
明日はプログラミング演習。動く物が作れればクレイグ・レイノルズのBirdoidを作ってみたい。
あとフラクタルとか。
フラクタルとは違うけどだいぶ前に作ったセルオートマトンのプログラム。多分このパラメータでシェルピンスキーのギャスケットを生成するはず。
>>|
import java.io.*;
public class Main {
static final int SIZE = 250;
public static String cell = new String[SIZE][SIZE];
public static void main(String[] args){
PrintWriter pw = null;
try {
pw = new PrintWriter
(new BufferedWriter(new FileWriter("out.txt")));
} catch (IOException e) {
System.exit(1);
}
initialize();
for(int x=1;x
cell[0][i] = " ";
else
cell[0][i] = "x";
}
}
static void rule(int x, int y){
String str;
if( x<=0 || x>=SIZE-1 ){
cell[x][y] = " ";
return;
}
if( y<=0 || y>=SIZE-1 ){
cell[x][y] = " ";
return;
}
str = cell[x-1][y-1] + cell[x-1][y] + cell[x-1][y+1];
int value = getValue(str);
switch(value){
case 111:
cell[x][y] = " ";
break;
case 112:
cell[x][y] = "x";
break;
case 121:
cell[x][y] = " ";
break;
case 122:
cell[x][y] = " ";
break;
case 211:
cell[x][y] = "x";
break;
case 212:
cell[x][y] = " ";
break;
case 221:
cell[x][y] = "x";
break;
case 222:
cell[x][y] = "x";
break;
}
return;
}
static int getValue(String str){
if(str.equals(" ") == true){
return 111;
}
if(str.equals(" x") == true){
return 112;
}
if(str.equals(" x ") == true){
return 121;
}
if(str.equals(" xx") == true){
return 122;
}
if(str.equals("x ") == true){
return 211;
}
if(str.equals("x x") == true){
return 212;
}
if(str.equals("xx ") == true){
return 221;
}
if(str.equals("xxx") == true){
return 222;
}
return 0;
}
}
<< |