• Remix
  • Share
  • New Entry

  • Mike Croucher

  • /
  • Chaos game on a square with 2 points away restriction

on 6 Oct 2021
  • 1
  • 20
  • 1
  • 0
  • 264
N=10^5;
v=zeros(N,2);
a=4;
%vertices and centre of a square
c=[[0,1];[1,1];[1,0];[0,0]];
plot(c(:,1),c(:,2),'.',markersize=20);
p=[0,0];
lc=1;
for i=1:N
idx = randi(a);
%Restriction: The next point cannot be two vertices away.
%Can only be the same point or immediate neighbours
while idx==(mod(lc+1,a)+1)
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([0,1])
ylim([0,1])
axis off
Remix Tree
Load full remix tree