x1=[1 2 2.5 3 4];
y1=[0 0 0 0 0];
h1=plot(x1,y1,'linewidth',2,'erasemode','xor');
axis equal
axis off
for g=linspace(0,1,40)*sin(pi/3);
y1(3)=g;
set(h1,'ydata',y1);
drawnow;
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% x2=x1(1);
y2=y1(1);
for k=2:length(x1);
t=linspace(x1(k-1),x1(k),4) ;
tt=[t(2),mean(t),t(3:4)];
x2=[x2,tt];
t=linspace(y1(k-1),y1(k),4);
tt=[t(2),mean(t),t(3:4)];
y2=[y2,tt];
end
A=angle((y2(4:4:end)-y2(2:4:end))*i+(x2(4:4:end)-x2(2:4:end)));
for g=linspace(0,1,40)*sin(pi/3)/3;
y2(3:4:end)=(y2(4:4:end)+y2(2:4:end))/2+imag(g*exp(i*(A+pi/2)));
x2(3:4:end)=(x2(4:4:end)+x2(2:4:end))/2+real(g*exp(i*(A+pi/2))) ;
set(h1,'ydata',y2,'xdata',x2);
drawnow;
end
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
x3=x2(1);
y3=y2(1);
for k=2:length(x2);
t=linspace(x2(k-1),x2(k),4);
tt=[t(2),mean(t),t(3:4)];
x3=[x3,tt];
t=linspace(y2(k-1),y2(k),4);
tt=[t(2),mean(t),t(3:4)];
y3=[y3,tt];
end
A=angle((y3(4:4:end)-y3(2:4:end))*i+(x3(4:4:end)-x3(2:4:end)));
for j=1:16;
g=sin(pi/3)/9;
y3(3+4*j-4)=(y3(4+4*j-4)+y3(2+4*j-4))/2+imag(g*exp(i*(A(j)+pi/2)));