%% 
%Linear transformations of the plane.
%Illustrated by a wire-frame model for the letter N
%Lay section 2.7 Example 1-3.

%%
%
%First we read the screen size and open an apropriate figure window.  
%Please ignore these lines.

scrsz = get(0,'ScreenSize');
sz = scrsz(4)/10;

fig = figure('Position',[sz sz 8*sz 8*sz]);
%%
% Data matrix for the letter N. The columns are the xy-coordinates of the
% corners.

D = [0 .5 .5 6 6 5.5 5.5 0 0; 0 0 6.42 0 8 8 1.58 8 0]

% We plot this data
plot(D(1,:),D(2,:));
axis([-5 10 -5 10]);
pause;

%%
% We define a shear matrix

A = [1 .25; 0 1]

% and transform each column vector in D via matrix multiplication.

M = A*D

% Plot of data matrix M:

plot(M(1,:),M(2,:));
axis([-5 10 -5 10])
pause;

%%
% We shrink the width by a scaling transformation

S = [.75 0; 0 1]
B = S*A

M = B*D

% Plot of the result:

plot(M(1,:),M(2,:));
axis([-5 10 -5 10])


