function FunRotation(X)
% Rotate a square about a potentially irrational angle

CreateTransformations;
C = {'r','g','b','y','c','m','w','k'};
if nargin < 1;
X = [0 1 1 0; 0 0 1 1];
end

close all;
% Plot an axis
	Ax = [-10, 10; 0, 0];
	PlotSegment(Ax(:,1),Ax(:,2),'-w');
	Ax = [0 0; -10, 10];
	PlotSegment(Ax(:,1),Ax(:,2),'-w');

	Ax = 5*Ax;
X = 3*X;

WireFrame(X,'.r',[-30,30,-30,30]);
Ax = 2*[-30,30,-30,30];

%fill(X(1,:),X(2,:),C{1});
pause(1)


for i = 1:50
	%X = 1.4*sqrt(i)*log(i+2)/(i+1)*R(pi/exp(1))*X;
	% Irrational rotation
	%X = R(pi/exp(1))*X;

	% pi/4 rotation
	X = R(pi/4)*X;
	fill(X(1,:),X(2,:),C{mod(i+1,8)+1});
	%X = TranslateByVector(X,2*[cos(pi/20),sin(pi/20)]);
	c = ['-',num2str(C{mod(i+1,8)+1})];
	[X,h] = WireFrame(X,c,Ax);
	mod(i+1,8)+1
	pause(.01)
	%delete(h)
	end;



function [h,A] = PlotSegment(u,v,c);

t = 0:.0001:1;

A = (1-[t;t]).* repmat(u,size(t)) + [t;t] .* repmat(v,size(t));

   h = plot(A(1,:),A(2,:),c);


