% Plot murray polygon % Based on Jack Cole's original S-Algol program % http://alb.host.cs.st-andrews.ac.uk/cole/code.html clf % Radices for polygon rx=[3 3 3]; ry=[3 3 3]; % Set up radices, state and rectangle size x_rad = length(rx); y_rad = length(ry); max_rad = max(x_rad, y_rad); complexity = 2 * max_rad; digits = zeros(complexity + 1,1); radices = ones(complexity + 1,1); parities = ones(complexity + 1,1); k=1; for i = 1:2:(2 * x_rad) radices( i ) = rx(k); k=k+1; end k=1; for i = 2:2:(2 * y_rad) radices( i ) = ry(k); k=k+1; end no_pts = number_pts( radices,1,1 ) -1 nx = number_pts( radices,1,2 ) ny = number_pts( radices,2,2 ) width = max(nx,ny); x1 = 0; y1 = 0; x2 = 0; y2 = 0; % Drawing variables mx=0; % Maximum extent my=0; im=zeros(nx,ny); % For drawing color picture coords=[x1 y1]; % Save states as coordinate array for ii = 1:no_pts [digits,i] = increment( digits,radices,1 ) ; parities = change_parities( parities,i ) ; inc = parities( i + 1 )*2-1; if rem(i,2) == 1 x2 = x2 + inc; else y2 = y2 + inc; end % Display %plot([x1 x2],[y1 y2],'LineWidth',2); hold on; drawnow % plot([x1 x2],[y1 y2],'Color',.5+.5*[cos(3*ii/no_pts) cos(3*ii/no_pts+1) cos(3*ii/no_pts+2)]); hold on im(x2+1,y2+1)=ii; coords=[coords; x2 y2]; if rem(i,2) == 1 x1 = x2; else y1 = y2; end mx=max(mx,x1); my=max(my,y1); end clf plot(coords(:,1),coords(:,2),'-','LineWidth',2); axis([-1 mx+1 -1 my+1]); axis equal axis off