Previous: Dots sample, Up: 3D samples [Contents][Index]
Commands ifs2d and ifs3d generate points for fractals using iterated function system in 2d and 3d cases correspondingly. The sample codes are:
int sample(mglGraph *gr) { mglData A; A.SetList(35, 0.33,0.,0.,0.33,0.,0.,0.2, 0.33,0.,0.,0.33,0.67,0.,0.2, 0.33,0.,0.,0.33,0.33,0.33,0.2, 0.33,0.,0.,0.33,0.,0.67,0.2, 0.33,0.,0.,0.33,0.67,0.67,0.2); A.Rearrange(7); mglData f(mglIFS2d(A,100000)); gr->SubPlot(1,1,0,"<_"); gr->Title("IFS 2d sample"); gr->SetRanges(f.SubData(0), f.SubData(1)); gr->Axis(); gr->Plot(f.SubData(0), f.SubData(1),"r#o ","size 0.05"); }
int sample(mglGraph *gr) { mglData A; A.SetList(52, 0.,0.,0.,0.,.18,0.,0.,0.,0.,0.,0.,0.,.01, .85,0.,0.,0.,.85,.1,0.,-0.1,0.85,0.,1.6,0.,.85, .2,-.2,0.,.2,.2,0.,0.,0.,0.3,0.,0.8,0.,.07, -.2,.2,0.,.2,.2,0.,0.,0.,0.3,0.,0.8,0.,.07); A.Rearrange(13); mglData f(mglIFS3d(A,100000)); gr->Title("IFS 3d sample"); gr->SetRanges(f.SubData(0), f.SubData(1), f.SubData(2)); gr->Rotate(50,60); gr->Axis(); gr->Box(); gr->Dots(f.SubData(0), f.SubData(1), f.SubData(2),"G#o","size 0.05"); }
Command flame2d generate points for flame fractals in 2d case. The sample codes are:
int sample(mglGraph *gr) { mglData A, B(2,3,5); A.SetList(35, 0.33,0.,0.,0.33,0.,0.,0.2, 0.33,0.,0.,0.33,0.67,0.,0.2, 0.33,0.,0.,0.33,0.33,0.33,0.2, 0.33,0.,0.,0.33,0.,0.67,0.2, 0.33,0.,0.,0.33,0.67,0.67,0.2); A.Rearrange(7); for(long i=0;i<2*3*5;i++) B.a[i] = 0.3; for(long i=0;i<5;i++) B.a[2*3*i] = B.a[2*3*i+1*2] = B.a[2*3*i+2*2] = 3; mglData f(mglFlame2d(A,B,1000000)); gr->SubPlot(1,1,0,"<_"); if(big!=3) gr->Title("Flame2d sample"); gr->SetRanges(f.SubData(0), f.SubData(1)); gr->Axis(); gr->Box(); gr->Plot(f.SubData(0), f.SubData(1),"r#o ","size 0.05"); }
Previous: Dots sample, Up: 3D samples [Contents][Index]