function circle_to_ellipse(F)
% Plots undeformed postions (X) of points on a unit circle
% and deformed positions (X')
% and the displacements (U) relating the undeformed and deformed positions
% for homogeneous 2-D plane strain deformation (uz = 0).
% Input argument
% F = deformation gradient matrix = [a,b;c,d]
% 
% Examples
% F = [2,0;0,0.5]; circle_to_ellipse(F)
% F = [2,1;1,2]; circle_to_ellipse(F)
% F = [1,1;0,1]; circle_to_ellipse(F)

% [x'] = [a b] [x]
% [y'] = [c d] [y]
% [X'] = [F][X]
% Malvern (1969, p. 156) and Means (1976, p. 198) call the a,b,c,d 
% coordinate transformation matrix the deformation gradient matrix (F).
% Ramsay & Huber (1983) call this the "strain" matrix (p. 71).
% [X'] = [F][X]
% Fij = dX'i/dxj
%
% U = X' - X
% ux = (ax + by) - x = (a-1)x + by = ex + fy
% uy = (cx + dy) - y = cx + (d-1)y = gx + hy
% [ux] = [e f] [x]  
% [uy]   [g h] [y]
% [U] = [Ju][X] = [F-I][X]
% Malvern (1969, p. 124) and Means (1976, p. 197) call 
% the e,f,g,h matrix the displacement gradient matrix (Ju).
% Ramsay & Huber (1983) call this the "displacement vector gradient" matrix (p. 71).
% Juij = dui/dxj

% Define initial positions [X] on unit circle
t = 0:2*pi/360:2*pi;
x = cos(t);
y = sin(t);
X = [x;y];
% Define matrix Ju (displacement gradient matrix)
Ju = F - eye(size(F));	% 2x2 matrix

% Calculate deformed positions (X') and displacements (U)
Xp = F*X;				% Xp = X' = deformed positions
xp = Xp(1,:);			% xp is the first row of Xp
yp = Xp(2,:);			% yp is the second row of Xp
U = Ju*X;				% U = displacements
ux = U(1,:);			% ux is the first row of U
uy = U(2,:);			% uy is the second row of U

% Plot the undeformed unit circle and the associated deformed ellipse
plot(x,y,'--k');      % Plots undeformed unit circle in black
hold on
plot(xp,yp,'r');	% Plots the ellipse in red

% Plot the displacement vectors at selected points
i = 1:30:361;
quiver (x(i),y(i),ux(i),uy(i),0);
hold off
axis('equal')

% Now label the plots
xlabel('x')
ylabel('y')
title(['F = [',num2str(F(1,:)),'; ',num2str(F(2,:)),']'])
end