% generate reverse sequence of time-varying reference frame

more off

load parameters_pairwisem_5_3 % generates P

% find extrema of boundinboxextrama
ML=[];  NL=[];  MH=[];  NH=[];
for k=170:4:290
  P=pintegrate(p,k);
  [Ml,Nl,Mh,Nh] = boundingboxextrema(P(169:291,:)); % consider only region of P used
  ML = [ML;Ml];
  MH = [MH;Mh];
  NL = [NL;Nl];
  NH = [NH;Nh];
end%for
% compute extrema
Ml = min(ML);
Mh = max(MH);
Nl = min(NL);
Nh = max(NH);


% generate composite sequences with evolving ref. frame
for k=290:-4:170;  % this creates about 480 pixels high canvas
  P=pintegrate(p,k);
  %..., -1.3751, -0.188212, 1.70842, 1.3108);',k))% border
  %..., -3, -0.5, 5, 2.0);',k))% border
  eval(sprintf('cementcolor(P,290,170,-4,''movingref%03d'', Ml, Nl, Mh, Nh, %d);',k,k))%  border (boxed) on the ref. frame each time
  eval(sprintf('!temp_dattopnm_hp movingref%03d > movingref%03d.ppm',k,k))
  eval(sprintf('!rm movingref%03d/data',k))        % less risk than rm -r
  eval(sprintf('!rm movingref%03d/descriptor',k))
  eval(sprintf('!rmdir movingref%03d',k))
end%for

% pintegrate(p,290) gives -2.58983, -0.420925, 1,       1.67829
% pintegrate(p,170) gives  0,       -0.258038, 4.54889, 1.80523

