• Remix
  • Share
  • New Entry

  • Mike Croucher

  • /
  • Chaos game on a square with restriction (bugfix)

on 6 Oct 2021
  • 1
  • 26
  • 2
  • 0
  • 222
N=10^5;
v=zeros(N,2);
a=4;
%vertices of a square
c=[[-1,1];[-1,-1];[1,1];[1,-1]];
p=[0,0];
lc=1;
for i=1:N
idx=randi(a);
while lc==idx % If this point is same as previous point, choose again
idx=randi(a);
end
lc=idx;
s=c(idx,:);
p=(p+s)/2;
v(i,:)=p;
end
plot(v(:,1),v(:,2),'.',markersize=1)
xlim([-1,1])
ylim([-1,1])
axis off equal
Remix Tree
Load full remix tree