Home > manopt > manifolds > essential > privateessential > essential_distMinAngle.m

essential_distMinAngle

PURPOSE ^

SYNOPSIS ^

function [tMin,fMin,Q2Flip,output]=essential_distMinAngle(Q1,Q2,varargin)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tMin,fMin,Q2Flip,output]=essential_distMinAngle(Q1,Q2,varargin)
0002 NQ1=size(Q1,3);
0003 NQ2=size(Q2,3);
0004 
0005 if NQ1==1 && NQ2>1
0006     Q1=repmat(Q1,[1 1 NQ2]);
0007     NQ1=NQ2;
0008 end
0009 if NQ1>1 && NQ2==1
0010     Q2=repmat(Q2,[1 1 NQ1]);
0011 end
0012 
0013 if NQ1>1
0014     tMin=zeros(NQ1,1);
0015     fMin=zeros(NQ1,1);
0016     Q2Flip=zeros(6,3,NQ1);
0017     if nargout>3
0018         output=repmat(struct('tMin',[],'fMin',[],'tBreak1',[],'tBreak2',[]),NQ1,1);
0019     end
0020     for iQ=1:NQ1
0021         if nargout>3
0022             [tMin(iQ),fMin(iQ),Q2Flip(:,:,iQ),output(iQ)]=...
0023                 essential_distMinAngle(Q1(:,:,iQ),Q2(:,:,iQ),varargin{:});
0024         else
0025             [tMin(iQ),fMin(iQ),Q2Flip(:,:,iQ)]=...
0026                 essential_distMinAngle(Q1(:,:,iQ),Q2(:,:,iQ),varargin{:});
0027         end
0028     end
0029 else
0030     flagModTMin=false;
0031     flagSigned=false;
0032 
0033     %optional parameters
0034     ivarargin=1;
0035     while(ivarargin<=length(varargin))
0036         switch(lower(varargin{ivarargin}))
0037             case 'flagmodtmin'
0038                 ivarargin=ivarargin+1;
0039                 flagModTMin=varargin{ivarargin};
0040             case 'signed'
0041                 flagSigned=true;
0042             case 'flagsigned'
0043                 ivarargin=ivarargin+1;
0044                 flagSigned=varargin{ivarargin};
0045             otherwise
0046                     error(['Argument ' varargin{ivarargin} ' not valid!'])
0047         end
0048         ivarargin=ivarargin+1;
0049     end
0050 
0051     tMin=zeros(4,1);
0052     fMin=zeros(4,1);
0053     tBreak1=zeros(4,1);
0054     tBreak2=zeros(4,1);
0055     Q2Flip=zeros(6,3,4);
0056     if ~flagSigned
0057         for k=1:4
0058             [tMin(k),fMin(k),tBreak1(k),tBreak2(k),Q2Flip(:,:,k)]=...
0059                 essential_distMinAnglePair(Q1,Q2,k);
0060         end
0061     else
0062         [tMin,fMin,tBreak1,tBreak2,Q2Flip]=...
0063             essential_distMinAnglePair(Q1,Q2,1);
0064     end    
0065 
0066     if flagModTMin
0067         tMin=modAngle(tMin);
0068     end
0069 
0070     if nargout>3
0071         output.tMin=tMin;
0072         output.fMin=fMin;
0073         output.tBreak1=tBreak1;
0074         output.tBreak2=tBreak2;
0075     end
0076 
0077     if ~flagSigned
0078         [fMin,idxMin]=min(fMin);
0079         fMin=max(fMin,0);
0080         tMin=tMin(idxMin);
0081         Q2Flip=Q2Flip(:,:,idxMin);
0082         if nargout>3
0083             output.idxMin=idxMin;
0084         end
0085     end
0086 end

Generated on Mon 10-Sep-2018 11:48:06 by m2html © 2005