iconEuler Examples

Random Fractals

By randomly selecting one transformatin for an iteration, is is
possible to generate nice fractals. If the transofrmation contract,
the points will have limit points at a fractal K. K is the set, which
is the union of all tranformed copies of K. 

Here is one example, generating the Sierpinsky gasket.
>function T1(x) := ([1,1]+x)/2
>function T2(x) := ([1,0]+x)/2
>function T3(x) := ([0,1]+x)/2
>function randIter (x,f,n) ...
res=zeros(n,cols(x));
res[1]=x;
irand=intrandom(1,n,length(f));
loop 2 to n;
  x=f[irand[#]](x);
  res[#]=x;
end
return res;
endfunction
>P=randIter([0,0],["T1","T2","T3"],10000)[1000:10000]';
>plot2d(P[1],P[2],points=true,style="."):

Random Fractals

Here is another example for you to play with.
>function D(alpha) := [cos(alpha),-sin(alpha);sin(alpha),cos(alpha)]
>A=([0.4,0;0,1].D(100°))'; B=([0.4,0;0,1].D(-100°))';
>function T1(x) := x*0.6+[0,0.4]
>function T2(x) := (x.A)*0.8
>function T3(x) := (x.B)*0.8
>P=randIter([0,0],["T1","T2","T3"],50000)[1000:50000]';
>plot2d(P[1],P[2],points=true,style="."):

Random Fractals

Examples Homepage