Vicsek fractal from the chaos game

Mike Croucher
on 6 Oct 2021
- 1
- 64
- 3
- 0
- 196
N=10^5;
v=zeros(N,2);
a=5;
%vertices and centre of a square
c=[[-1,1];[-1,-1];[0 0];[1,1];[1,-1]];
p=[0,0];
lc=1;
for i=1:N
idx=randi(a);
s=c(idx,:);
p=(p+2*s)/3;
v(i,:)=p;
end
plot(v(:,1),v(:,2),'.',markersize=1)
xlim([-1,1])
ylim([-1,1])
axis off equal