เร็วๆ นี้ผมลองทำเพิ่มอีกดูๆ ไปแล้วเหมือนใบมันผอมไปหน่อยครับ
ใครเคยทำแล้วใบมันผอมๆ บ้างไหมครับ ?
http://en.wikipedia.org/wiki/Barnsley_fernint main()
{ double a,b,c,d,e,f,x=0,y=0,p;
int i,n=100000;
long seed = 1;
for(i=0;i<n;i++){
p = ran2(&seed);
if(p<0.01){ //f1
a = b = c = e = f = 0;
d = 0.16;
}
else if((0.01<=p)&&(p<=0.08)){ //f3
a = 0.2; b = -0.26; c = 0.23;
d = 0.22; e = 0 ; f = 1.6;
}
else if((0.08<=p)&&(p<=0.15)){ //f4
a = -0.15; b = 0.28; c = 0.26;
d = 0.24; e = 0 ; f = 0.44;
}
else if(0.15<p){ //f2
a = 0.85; b = 0.04; c = -0.04;
d = 0.85; e = 0 ; f = 1.6;
}
x = a*x + b*y + e;
y = c*x + d*y + f;
printf("%f\t%f\n",x,y);
}
return 0;
}