%Napocita vsechna mozna dvojcatova a A-M rozhranni
clear I A B pn n a R N2 rho delta eta lambda T i j k m b Q F;

varianty

I=eye(3);

%Varianty
for A=1:6
 for B=1:6
  if A ~= B
   % R*Ua - Ub = a*n'
   pn=P(A, B);
   %Typ I
   n{A, B, 1} = p{pn};
   a{A, B, 1}=2*(inv(U{B})*p{pn}/norm(inv(U{B})*p{pn})^2 - U{B}*p{pn});
   R{A, B, 1}=(a{A, B, 1}*n{A, B, 1}' + U{B})*Qa{pn}'*inv(U{B})*Qa{pn};
   %Typ II
   N2=p{pn}-U{B}^2*p{pn}/norm(U{B}*p{pn})^2;
   rho=norm(N2);
   n{A, B, 2}=N2/rho;
   a{A, B, 2}=2*rho*U{B}*p{pn};
   R{A, B, 2}=(a{A, B, 2}*n{A, B, 2}' + U{B})*Qa{pn}'*inv(U{B})*Qa{pn};
   % Q(lambda*R*Ua - (1-lambda)*Ub) - I = Q(Ub + lambda*a*n') - I = b*m'
   % F = Q(lambda*R*Ua - (1-lambda)*Ub) = Q(Ub + lambda*a*n') = Q*T
   for i=1:2
    delta=a{A, B, i}'*U{B}*inv(U{B}^2 - I)*n{A, B, i};
    eta=trace(U{B}^2) - det(U{B}^2)-2+norm(a{A, B, i})^2 / (2*delta);
    if (delta <= -2) && (eta >= 0)
     lambda{A,B,i,1}=(1-sqrt(1+2/delta))/2;
     T{A,B,i,1}=U{B} + lambda{A,B,i,1}*a{A, B, i}*n{A, B, i}';
     lambda{A,B,i,2}=1-lambda{A,B,i,1};
     T{A,B,i,2}=U{B} + lambda{A,B,i,2}*a{A, B, i}*n{A, B, i}';
     for j=1:2
      for k=1:2
       [m{A,B,i,j,k} b{A,B,i,j,k} Q{A,B,i,j,k} F{A,B,i,j,k}]=mbQF(T{A,B,i,j}, k);
end; end; end; end; end; end; end

clear I A B pn N2 rho delta eta i j k;