% circle.m
% Make some plots involving a circle.
%
alist = linspace ( 0.0, 2.0 * pi, 501 );
clist = cos ( alist );
slist = sin ( alist );
%
%  Plot 1: 
%  sine and cosine from 0 to 2pi.
%
plot ( alist, slist, 'LineWidth', 3 );
hold on
plot ( alist, clist, 'LineWidth', 3 );
plot ( [ 0.0, 2.0 * pi ], [ 0.0, 0.0 ], 'k--' );
hold off
grid on
title ( 'a, sin(a) and a, cos(a)', 'FontSize', 24 );
xlabel ( '<-- Angle -->' );
ylabel ( '<-- Y -->' );
axis equal
print ( '-djpeg', 'circle1.jpg' );

fprintf ( 'Press RETURN for another plot:\n' );
pause
%
%  Plot 2: 
%  plot sine versus cosine.
%
plot ( clist, slist, 'LineWidth', 3 );
hold on
plot ( [ -1.0, 1.0 ], [ 0.0, 0.0 ], 'k--' );
plot ( [  0.0, 0.0 ], [ -1.0, +1.0 ], 'k--' );
hold off
grid on
title ( 'x=cos(a), y=sin(a)', 'FontSize', 24 );
xlabel ( '<-- X -->' );
ylabel ( '<-- Y -->' );
axis equal
print ( '-djpeg', 'circle2.jpg' );

fprintf ( 'Press RETURN for another plot:\n' );
pause
%
%  Plot 3: 
%  Ellipse.
%
plot ( clist, 2.5 * slist, 'LineWidth', 3 );
hold on
plot ( [ -1.0, 1.0 ], [ 0.0, 0.0 ], 'k--' );
plot ( [  0.0, 0.0 ], [ -2.5, +2.5 ], 'k--' );
hold off
grid on
title ( 'x=cos(a), y=2.5 sin(a)', 'FontSize', 24 );
xlabel ( '<-- X -->' );
ylabel ( '<-- Y -->' );
axis equal
print ( '-djpeg', 'circle3.jpg' );

fprintf ( 'Press RETURN for another plot:\n' );
pause
%
%  Plot 4: 
%  Cardiod: r = 1 + cos(theta).
%
rlist = 1.0 + cos ( alist );
plot ( rlist .* clist, rlist .* slist, 'LineWidth', 3 );
hold on
plot ( [ -0.5, 2.0 ], [ 0.0, 0.0 ], 'k--' );
plot ( [  0.0, 0.0 ], [ -1.5, +1.5 ], 'k--' );
hold off
grid on
title ( 'Cardiod', 'FontSize', 24 );
xlabel ( '<-- X -->' );
ylabel ( '<-- Y -->' );
axis equal
print ( '-djpeg', 'circle4.jpg' );
fprintf ( 'Press RETURN to finish:\n' );
pause
