%% Square Waveform Targets

%% Square Wave Functions
%
% Max dims of the parts is 406 mmW x 355mm L x 406mm H

close all; clear

x = 0:.1:310;

% Sinusoid
y = @(x,lambda,A) -A*cos(2*pi./lambda * x);

% Chirp
k = @(lam0,lam1,x) (1/lam1-1/lam0)/(x(end)-x(1)); %freq rate change
f = @(lam0,lam1,x) (1/lam0) + k(lam0,lam1,x)*x./2;
fmchirp = @(lam0,lam1,x,A) A * cos(2*pi*f(lam0,lam1,x).*x);

%% Row 1: Period of 150-mm (amplitude 30-mm)
%
lambda = 150;
A = 30;
figure(1); 
plot(x,A*sign(y(x,lambda,A)),'LineWidth',1);
axis square equal;
title(['Row 1 Square: ' num2str(lambda) '-mm \lambda | Amp ' num2str(A) '-mm']);
%%
axis off;
title '';
saveas(gcf,'squareRow1.svg');

%% Row 2: Period of 75-mm (amplitude 15-mm)
% 
lambda = 75;
A = 15;
figure(2); 
plot(x,A*sign(y(x,lambda,A)),'LineWidth',1);
axis square equal;
title(['Row 2 Square: ' num2str(lambda) '-mm \lambda | Amp ' num2str(A) '-mm']);
axis square equal;
%%
axis off;
title '';
saveas(gcf,'squareRow2.svg');

%% Row 3: Period of 60-mm to 30-mm (amplitude 10-mm)
%
lambda0 = 60;
lambda1 = 30;
A = 10;
figure(3)
plot(x, -A*sign(fmchirp(lambda0,lambda1,x,A)),'LineWidth',1);
title(['Row 3 Square: \lambda=' num2str(lambda0) '-mm to ' num2str(lambda1) '-mm | Amp ' num2str(A) '-mm']);
axis square equal;
%%
axis off;
title '';
saveas(gcf,'squareRow3.svg');

%% Row 4: Period of 30-mm to 5-mm (amplitude 5-mm)
% 
lambda0 = 30;
lambda1 = 5;
A = 5;
figure(4);
plot(x, -A*sign(fmchirp(lambda0,lambda1,x,A)),'LineWidth',1);
title(['Row 4 Square: \lambda=' num2str(lambda0) '-mm to ' num2str(lambda1) ' mm | Amp ' num2str(A) '-mm']);
axis square equal;
%%
axis off;
title '';
saveas(gcf,'squareRow4.svg');

