% solves for the 2x2 rotation matrix R and 2x1 translation
% vector T given 2*n matrices Y and X of corresponding
% points (n>1) ideally satisfying Y = R*X + T
function [R,T] = solvepose2(X,Y)

  % solve for position
  Ymean = mean(Y')';
  Xmean = mean(X')';
  K = (Y - Ymean*ones(2,1)')*(X - Xmean*ones(2,1)')';
  [V,D,U] = svd(K);
  D = eye(2,2);
  D(2,2) = det(V*U');
  R = V*D*U';
  T = Ymean - R*Xmean;
