% Unit 2 (MATLAB Course @ UAM)
% (c) Alexander Knebe

%===================
% Lissajous figures
%===================
clear all
close all
clc

% parameters
A  = 1;
B  = 1;
N  = 1000;

% Modelo A
a = 5; b = 3;

% full cycle
theta = linspace(0,2.*pi,N);

% Lissajous
x = A.*cos(a.*theta);
y = B.*sin(b.*theta);

L = [x; y];

% rotation matrix
phi = 45 * pi./180;
R   = [cos(phi), -sin(phi); sin(phi), cos(phi)];

% translation vector
T   = [linspace(2,2,N);linspace(2,2,N)];

% rotation of Lissajous
L   = R*L;
H   = L;

% translation of Lissajous
L   = L + T;

% extract x and y again
x = L(1,:);
y = L(2,:);

u = H(1,:);
v = H(2,:);

% plot
figure(11)
plot(x,y), hold on
%plot(u+2,v+2,'ro')
axis equal
