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"); }