% $URL: svn+ssh://mrwhat@ssh.boim.com/home/mrwhat/svn/Walker/trunk/plotJansenConfig.m $
% $Id: plotJansenConfig.m 78 2013-05-18 23:04:45Z aaron $
%
% Load maxima.dat outputs and plot JansenLinkage configurations
function plotJansenConfig(aa,i)
if (nargin < 2), i=0; end
args = num2str(aa);
cmd = ['java -cp /home/aaron/workspace/WalkingLinkage/bin com.boim.walker.tests.DumpMetric Jansen ',args]
  [stat,cmdOut] = system(cmd);
  cmdOut
  a = load('orbit.dat');
  hold off;
  plotJansenOrbit1(a);
  grid on;
  axis equal;
  axis([-150 150 -125 75]);
  a = sprintf('%.2f',aa(1));
  for j=2:length(aa), a = [a,sprintf(' %.2f',aa(j))]; end
  xlabel(a);
  title(sprintf(['%d ',cmdOut],i));
  fNam = sprintf('opt%04d.png',i)
  print(fNam,'-S1280,1024');
end



function plotJansenOrbit1(a)
% assuming two sets of orbits for a pair of legs...
n = size(a,1)/2
hold off;
for i=1:2:2*n
   plotJansen(a(i,:),'c');
end
plot(a(:,13),a(:,14),'gd');  % foot orbit
k = floor(rand()*n)+1;
%   plot(a(kr,1),a(kr,2),'bo','markersize',7); % crank location
plotJansen(a(  k,:),'r',3);
%   plot([0,B1(1),D1(1),B2(1),D2(1)],[0,B1(2),D1(2),B2(2),D2(2)],'ko');  % fixed point locations
end
