11.57 Sample ‘flame2d

Function flame2d generate points for flame fractals in 2d case.

MGL code:

list A [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]
new B 2 3 A.ny '0.3'
put B 3 0 0 -1
put B 3 0 1 -1
put B 3 0 2 -1
flame2d fx fy A B 1000000
subplot 1 1 0 '<_':title 'Flame2d sample'
ranges fx fy:box:axis
plot fx fy 'r#o ';size 0.05

C++ code:

void smgl_flame2d(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");
}
Sample flame2d