% hallgainloci.m
% Adds the loci of constant gain of the complementary sensitivity 
% function to a Nyquist plot
%   kja 071212
%Gain curves

aminit;

figure(1); clf; subplot(221);

% Create patch vectors
M=1.1;cx1=-M^2/(M^2-1);r1=M/(M^2-1);
X1=[cx1];Y1=[-5.5];
for ff=-pi/2:pi/200:pi/2;    
    X1=[X1 cx1+r1*cos(ff)];Y1=[Y1 r1*sin(ff)];
end
X1=[X1 cx1];Y1=[Y1 5.5];
M=1/M;cx2=-M^2/(M^2-1);r2=-M/(M^2-1);
X2=[cx2];Y2=[5.5];
for ff=pi/2:pi/200:3*pi/2;
    X2=[X2 cx2+r2*cos(ff)];Y2=[Y2 r2*sin(ff)];
end
X=[X1 X2 cx2];Y=[Y1 Y2 -5.5];
%X=[X1 X2 X1(1)];Y=[Y1 Y2 Y1(1)];
patch(X, Y,[0.9 0.9 0.9], 'EdgeColor', 'none');
hold on;

% Redraw parts of the axis that get wiped out by the path
plot([-6 5], [5.5 5.5], 'k-', 'LineWidth', AM_tick_linewidth);
plot([-6 5], [-5.5 -5.5], 'k-', 'LineWidth', AM_tick_linewidth);

MMt=[1.1 1.2 1.3 1.5 2 5];
s='b-';
for ii=1:6,
  M=MMt(ii);
  cx=M^2/(M^2-1);cy=0;r=M/(M^2-1);
  circplot(-cx,cy,r,s);hold on;
  M=1/M;
  cx=-M^2/(M^2-1);cy=0;r=M/(M^2-1);
  circplot(cx,cy,r,s);hold on;
end
%Phase curves
PP=pi*[10 20 40 60 80]/180;s=':';
for jj=1:5,
  fi=PP(jj);
  cx=-0.5;cy=0.5/tan(fi);r=0.5/sin(fi);
  circplot(cx,cy,r,s);
  circplot(cx,-cy,r,s);
end  

% Center line
xxx=-6:0.1:6;one=ones(size(xxx));
pl=plot(-0.5*one,xxx,'b--', 'Linewidth', AM_data_linewidth);
% Shape plot 
line([-6 5], [0 0]);
line([0 0],[-5.5 5.5]);
yx=(cx2-cx1)/2;
amaxis([-6 5 -5.5 5.5]);
axis square; box on;
xlabel('x');ylabel('y');
set(gca,'Ytick',[-4 -2 0 2 4]);

amprint('hall-loci.eps');

