% demo for change of variables, MATH 2210-3
% author: Fernando Guevara Vasquez

% Kelvin transform

% grid in the u,v plane
r = linspace(0.1,1,10);
t = linspace(0,2*pi,20);
[rr,tt] = meshgrid(r,t);
uu = rr.*cos(tt);
vv = rr.*sin(tt);

% transformation
Gx = inline('u./(u.^2+v.^2)','u','v');
Gy = inline('v./(u.^2+v.^2)','u','v');
figure(1); clf
title('uv (preimage) plane');
surf(uu,vv,ones(size(vv)));
xlabel('u'); ylabel('v');
axis equal; view(2);

figure(2); clf
title('xy (image) plane');
surf(Gx(uu,vv),Gy(uu,vv),ones(size(uu)));
xlabel('x'); ylabel('y');
axis equal; view(2);
