function tls(alpha,beta);

% alpha   = 1;
% beta    = 1;

close all;

A       = [alpha;0];
b       = [0;beta];

bA      = [b,A];
[U,s,V] = svd(bA);

for phi = [0.01:0.02:pi,pi],

  aux     = 1.5*max(alpha,beta);

  Q       = [cos(phi),sin(phi);-sin(phi),cos(phi)];
  gE      = - bA*V*Q(:,2)*Q(:,2)'*V';
  bA_new  = bA + gE; 

  plot(...
    bA(:,2),      bA(:,1),      'ko', ...
    bA_new(:,2),  bA_new(:,1),  'k*', ...
    [bA(1,2),bA_new(1,2)],  [bA(1,1),bA_new(1,1)],  'b:', ...
    [bA(2,2),bA_new(2,2)],  [bA(2,1),bA_new(2,1)],  'b:', ...
    [-aux,aux],[0,0],'k-',  [0,0],[-aux,aux],       'k-', ...  % sin([0:0.1:2*pi+0.1]),  cos([0:0.1:2*pi+0.1]),  'k-', ...
    0,0,'ks');
  hold on;
    
  k         = sum(bA_new(:,1)./bA_new(:,2))/2;
  if isinf(k),
    plot([0,0],[-aux,aux],'r-');
  else,
    plot([-aux,aux],k*[-aux,aux],'r-');
  end;
  hold off;
  
  axis([-aux,aux,-aux,aux]);
  axis square;
  axis off;
  
  title(sprintf('TLS: ||[g,E]||_F = %6.4f, ||x||_2 = %6.4f',norm(gE,'fro'),abs(k)));
    
  legend(...
    'original data', ...
    'corrected data' ...
  )
  
  % print('-dbitmap',sprintf('tls_%4.2f.bmp%',phi));
  
  if phi == 0.01,
    pause;
  end;
  
  pause(0.1);

end;

