- /
-
Chaos game
on 4 Oct 2021
- 4
- 283
- 15
- 0
- 197
N=10^5;
v=zeros(N,2);
a=3;
t=linspace(0,2*pi,a+1);
c=[cos(t);sin(t)]';
p=[0,0];
lc=1;
for i=1:N
idx=randi(a);
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