function Lissajous(omega, N)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function Lissajous(omega, N)
% ....................................................... Rosales, Nov. 2000.
%
% Plots Lissajous figure x = sin(t), y = sin(omega*t), for
%
% 0 <= t <= 2*pi*N.  N is optional (default N = 5)
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin < 2; N = 5; end
if nargin == 0; omega = sqrt(2); end
%
% --- Set up figure window.
%
SSz = get(0, 'ScreenSize');
SWt = SSz(3);% ---------- Screen Width
SHt = SSz(4);% ---------- Screen Height
Sml = min(SWt, SHt);% --- Screen minimum length.
Fwh = 0.65;  % ---------- Fig. Width = Height; as fraction of SmL.
POS = [0.02*SWt, 0.94*SHt-Fwh*Sml, Fwh*Sml, Fwh*Sml];
figure;
set(gcf, 'Name',        ' Lissajous figures.', ...
         'NumberTitle', 'off', ...
         'Position',    POS)
whitebg('w')
%
% --- Set-up axes and labels.
%
Ticks = -1:0.2:1;
TLabl = {'-1', '', '-0.6', '', '-0.2', '', '0.2', '', '0.6', '', '1'};
set(gca, 'FontUnits',  'points', ...
         'FontWeight', 'demi', ...
         'FontSize',    16, ...
         'LineWidth',   2, ...
         'Position',    [0.14 0.12 0.75 0.75], ...
         'Box',         'on', ...
         'Xtick',       Ticks, ...
         'XTickLabel',  TLabl, ...
         'Ytick',       Ticks, ...
         'YTickLabel',  TLabl)
axis square
grid on
hold on
axis([-1.1 1.1 -1.1 1.1])
%
xlabel('{\bf x}',  'FontSize', 22)
ylabel('{\bf y }', 'FontSize', 22, 'Rotation', 0)
title(['{\bf \omega = ', num2str(omega, '%20.14e'), '}'], 'FontSize', 16)
%
text(-1.10, 1.32, ...
     '{\bf Lissajous figure: x(t) = sin t, y(t) = sin \omega t.}', ...
     'FontUnits', 'Normalized', 'FontSize', 0.05)
%
MaxF = max(1, abs(omega));
t = 2*pi*N*(0:1:50*N*MaxF)/(40*N*MaxF);
x = sin(t);
y = sin(omega*t);
plot(x, y, '-b', 'LineWidth', 2)
%
% --- Dot at origin.
%
r1 = 0.020;
r2 = 0.020;
ellipseSZans(0.0,  0.0, r1, r2, 'k', 20, 0)
%
hold off
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ellipseSZans(x, y, r1, r2, color, N, phi)
% @#@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% function ellipseSZans(x, y, r1, r2, color, N, phi)
% ....................................................... Rosales, Oct. 1999.
% ____________________________________________________________________________
% Places a (filled with color) ellipse of radii r1 and r2, centered at (x, y),
% in the current figure. The input variables are:
% -- (x, y) ....... center of ellipse.
% -- r1 ........... horizontal radius of ellipse.
% -- r2 ........... vertical radius of ellipse.
% -- color ........ string variable with the color (e.g.: color='r').
% -- N ............ number of points used to draw ellipse boundary.
% -- phi .......... phase, to allow rotation of polygon when N is small.
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
xx = x + r1*cos(phi+2*pi*(0:N)/N);
yy = y + r2*sin(phi+2*pi*(0:N)/N);
fill(xx, yy, color);
plot(xx, yy, '-', 'Color', color, 'LineWidth', 1)
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%% EOF
