

%       Script Mfile   images  
disp('Transformation  T(u,v) = ( u^2-v^2, 2uv) ')
f1 = inline('u.^2 - v.^2', 'u', 'v');
g1 = inline('2*u.*v', 'u', 'v');

u = linspace( 0, 1, 51); v =u;
for i = 0:5  
   plot([0 1], [i/5, i/5], 'b')
   hold on
   plot([i/5,i/5], [0 1],'r')
end
plot([-2.5 2.5], [0 0], '--k')
plot([0,0], [-1, 3], '--k')
text(2, .1, '\fontsize{14}u')
text(.1, 2, '\fontsize{14}v')
axis ([-2.5 2.5 -1 3])
hold off

 pause
figure
for i = 0:5
   plot(f1(u,i/5), g1(u,i/5),'b')
   hold on
   plot(f1(i/5,v), g1(i/5,v), 'r')
end 
plot([-2.5 2.5], [0 0], '--k')
plot([0 0], [-1 3], '--k')
text(2, .1, '\fontsize{14}x')
text(.1, 2, '\fontsize{14}y')
axis([-2.5, 2.5, -1 3])

hold off
pause
close

disp(' ')
disp('Transformation  T(u,v) = ( (2u+v)/(v+1), v - u/2) ')
f2 = inline('(2*u+ v)./(v+1)', 'u', 'v');
g2 = inline(' v-.5*u', 'u', 'v');
figure
for i = 0:5
    plot(f2(u, i/5), g2(u,i/5), 'b')
    hold on
    plot(f2(i/5, v), g2(i/5, v), 'r')
end
plot([-2.5 2.5], [0 0], '--k')
plot([0 0], [-1 3], '--k')
axis([-2.5 2.5 -1 3])
text(2, .1, '\fontsize{14}x')
text(.1,2, '\fontsize{14}y')


hold off
    
hold on
pause
close all
% image using polar coordinates
disp(' ')
disp(' Polar coordinates  ')
r = linspace(1,2, 51);
th = linspace( 0, pi, 51);

for i = 0:6
    plot([1,2], [ i*pi/6, i*pi/6], 'b')
    hold on
    plot([1+i/6,1+i/6], [0, pi], 'r')
end
axis([-1,4, -.5 , 3.5])
plot([-1,4], [0,0],'--k')
plot([0,0],[-.5,3.5], '--k')
text(3,.1, '\fontsize{14}r')
text(.1, 2.5, '\fontsize{14}\theta')
hold off

f3 = inline('r.*cos(th)', 'r', 'th');
g3 = inline('r.*sin(th)', 'r', 'th');

figure
for i = 0:6
    plot(f3(r, pi*i/6), g3(r,pi*i/6) )
    hold on
    plot(f3(1+i/6, th),g3(1+i/6,th), 'r')
end
axis([-2.5 2.5 -1 3])
plot([-2.5, 2.5], [0,0], '--k')
plot([0,0], [-1 3], '--k')
text(2.2, .1, '\fontsize{14}x')
text(.1,2.2, '\fontsize{14}y')
hold off
pause
close all

% polar coordinates - cardioid
disp(' ')
disp(' Polar coordinates and the cardioid ,   r = 1+cos(theta) ')

clear r th
r = linspace( 0, 4, 101);
th = linspace( -pi, pi, 101);
TH = linspace(-pi, pi, 21);
R = linspace( 0, 4, 21);
for i = 1:21
    plot([0,4], [TH(i), TH(i)], 'b')
    hold on
    plot([R(i),R(i)], [-pi, pi], 'r')
end
plot(1+cos(th), th, 'k')
plot( [0,4], [0,0], '--k')
plot([0,0], [-4,4], '--k')
text(3, .1, '\fontsize{14} r')
text( .1, 3.2, '\fontsize{14}\theta')
axis([-1 4 -4,4])

figure
for i = 1:21
    plot(r*cos(TH(i)), r*sin(TH(i)), 'b')
    hold on
    plot(R(i)*cos(th), R(i)*sin(th), 'r')
end
hold on
plot((1+cos(th)).*cos(th), (1+cos(th)).*sin(th), 'k')
text(2.8, .1, '\fontsize{14}x')
text(.1, 2, '\fontsize{14}y')
axis([-3,3, -2.4, 2.4])
hold off
pause
close all
