% script file to create a plot showing a barrier slice
%   for the collision avoidance example
%   (so swap x and y, scale by 5)
%
% Ian Mitchell 7/17/02

slices = [ -150; -90 ] * pi / 180;
beta = 1;

figure
v = zeros(length(slices), 4);

for i = 1 : length(slices)

  subplot(length(slices),1,i)
  [ xp xm xc sp sm ] = barrier(slices(i), beta);
  xp = 5 * xp(:, [2, 1]);
  xm = 5 * xm(:, [2, 1]);
  xc = 5 * xc(:, [2, 1]);
  sp.crossover = 5 * sp.crossover([ 2 1 ]);
  lh = plot(sp.crossover(1), sp.crossover(2), 'b*', ...
            xp(:,1), xp(:,2), 'b-', xm(:,1), xm(:,2), 'b-', ...
            xc(:,1), xc(:,2), 'b:', -xc(:,1), -xc(:,2), 'b:');
  lh = lh( [ 1, 2, 4 ]);
  axis equal;
  v(i,:) = axis;

end

v = max(v, [], 1);
v = v + 0.1 * sign(v);

for i = 1 : length(slices)
  subplot(length(slices), 1, i);

  xlabel('x_r');
  ylabel('y_r');
  title([ 'Slice at \psi_r = ' num2str(slices(i) * 180 / pi + 360) '^\circ' ]);
  axis(v);
  %grid on;
end

legend(lh, { 'crossover point', 'barrier', 'capture circle' });
