
clear;

x=[-10:2:10];
y=[-10:2:10];

[X,Y]=meshgrid(x,y);

theta=20;
a = cosd(theta);

w = [0 a; -a 0];

[n,m]=size(X);
Urot=nan(size(X));
Vrot=nan(size(Y));

for i=1:m
    for j=1:n
        UV = w*[X(i,j);Y(i,j)];
        Urot(i,j)=UV(1);
        Vrot(i,j)=UV(2);
    end
end

figure(1)
clf;
subplot(231)
quiver(X,Y,Urot,Vrot)
title('Rotation');
axis equal
axis tight

xlim=get(gca,'xlim');
ylim=get(gca,'ylim');

e = [a 0 ;  0 -a];
Ush=nan(size(X));
Vsh=nan(size(Y));
for i=1:m
    for j=1:n
        UV = e*[X(i,j);Y(i,j)];
        Ush(i,j)=UV(1);
        Vsh(i,j)=UV(2);
    end
end

subplot(232);
quiver(X,Y,Ush,Vsh)
title('Pure Shear');
axis equal
axis([xlim ylim]);

subplot(233);
quiver(X,Y,Urot+Ush,Vrot+Vsh)
title({'Simple Shear =','Strain + Rotation'});
axis equal
axis([xlim ylim]);


%% dilatation

edelta = [a 0 ;  0 a];
Ud=nan(size(X));
Vd=nan(size(Y));
for i=1:m
    for j=1:n
        UV = edelta*[X(i,j);Y(i,j)];
        Ud(i,j)=UV(1);
        Vd(i,j)=UV(2);
    end
end

subplot(234);
quiver(X,Y,Ud,Vd)
title('Dilatation');
axis equal
axis([xlim ylim]);

euni = [a 0 ;  0 0];
Uuni=nan(size(X));
Vuni=nan(size(Y));
for i=1:m
    for j=1:n
        UV = euni*[X(i,j);Y(i,j)];
        Uuni(i,j)=UV(1);
        Vuni(i,j)=UV(2);
    end
end

subplot(235);
quiver(X,Y,Uuni,Vuni)
title('Uniaxial');
axis equal
axis([xlim ylim]);

%%  

subplot(236);

simpshear = [0 a;0 0];
Usimp=nan(size(X));
Vsimp=nan(size(Y));
for i=1:m
    for j=1:n
        UV = simpshear*[X(i,j);Y(i,j)];
        Usimp(i,j)=UV(1);
        Vsimp(i,j)=UV(2);
    end
end

quiver(X,Y,Usimp,Vsimp);
title({'Another Simple Shear'});
axis equal
axis([xlim ylim]);

orient landscape
print -dpdf StrainRotation.pdf

