% $URL: svn+ssh://aaron@birenboim.com/home/users/svn/Jansen/trunk/plotKlannConfigs.m $
% $Id: plotKlannConfigs.m 52 2013-05-10 15:44:11Z aaron $
%
% Load maxima.dat outputs and plot KlannLinkage configurations
function plotKlannConfigs(a)
for i=1:size(a,1)
  score = a(i,1);
  args = num2str(a(i,2:13));
  cmd = ['java -cp /home/aaron/workspace/WalkingLinkage/bin com.boim.walker.tests.DumpOrbit Klann ',args,' > orbit.dat']
  system(cmd);
  b = load('orbit.dat');
  hold off;
  plotKlannOrbit1(b);
  grid on;
  axis equal;
  xlabel(args);
  title(sprintf("%d %g",i,score));
  print(sprintf('opt%04d.png',i),'-S1280,1024');
end



function plotKlannOrbit1(a)
% assuming two sets of orbits for a pair of legs...
n = size(a,1)/2
hold off;
for i=2:2:n
   plotKlann(a(i,:),'c');
   plotKlann(a(n+i,:),'c');
end
plot(a(:,11),a(:,12),'gd');  % foot orbit
k = floor(rand()*n)+1;
%   plot(a(kr,1),a(kr,2),'bo','markersize',7); % crank location
plotKlann(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
