Home > General-Functions > SUGR > E-Matrix > sugr_select_bR_from_E_UV_uv.m

sugr_select_bR_from_E_UV_uv

PURPOSE ^

% Select bR from E

SYNOPSIS ^

function [be,Re] = sugr_select_bR_from_E_UV_uv(U,V,u,v)

DESCRIPTION ^

% Select bR from E
 select one of the four cases;

 similar to Alg. 20, but from (U,V) instead from E

 [b,R,zwe] = sugr_select_bR_from_E(U0,V0,xl,xr);

 U0, V0    = svd(E), with positive determinants enforced
 xl,xr     = Nx3 matrices for corresponding points

 Wolfgang Förstner 9/2011
 wfoerstn@uni-bonn.de

 See also sugr_E_Matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Select bR from E
0002 % select one of the four cases;
0003 %
0004 % similar to Alg. 20, but from (U,V) instead from E
0005 %
0006 % [b,R,zwe] = sugr_select_bR_from_E(U0,V0,xl,xr);
0007 %
0008 % U0, V0    = svd(E), with positive determinants enforced
0009 % xl,xr     = Nx3 matrices for corresponding points
0010 %
0011 % Wolfgang Förstner 9/2011
0012 % wfoerstn@uni-bonn.de
0013 %
0014 % See also sugr_E_Matrix
0015 
0016 function [be,Re] = sugr_select_bR_from_E_UV_uv(U,V,u,v)
0017 
0018 % auxiliary matrices
0019 W  = [0,1,0;-1,0,0;0,0,1];
0020 u3 = U(:,3);
0021 
0022 % number of corresponding directions
0023 N = size(u,1);
0024 
0025 % initialize
0026 solution = 0;
0027 
0028 be       = [1,0,0]';
0029 Re       = eye(3);
0030 
0031 % determine alternatives (PCV p. 583, Alg. 20)
0032 for t=0:3
0033     switch t
0034 %         case 0
0035 %             R  = V*W*U';     % R'=U*W*V' (HZ) -> R = V*W'*U'
0036 %             b  = u3;
0037 %         case 1
0038 %             R   = V*W*U';
0039 %             b  = -u3;
0040 %         case 2
0041 %             R   = V*W'*U';
0042 %             b  = u3;
0043 %         case 3
0044 %             R   = V*W'*U';
0045 %             b  = -u3;
0046     case 0
0047         R  = V*W'*U';     % R'=U*W*V' (HZ) -> R = V*W'*U'
0048         b  = u3;
0049     case 1
0050         R   = V*W'*U';   
0051         b  = -u3;
0052     case 2
0053         R   = V*W*U';
0054         b  = u3;
0055     case 3
0056         R   = V*W*U';
0057         b  = -u3;
0058     end   
0059     S = calc_S(b);
0060 %% check for positiveness (not yet included: check for direction || basis )
0061     % m-vectors: 3 x N Matrix, PCV (13.165)
0062     Nm = -S*S*u(:,1:3)';   
0063     % m x (u x R'v) - vectors, 3 x M-matrix, part of denom., PCV (13.164)
0064     Mm = (calc_S( Nm(1:3,:)) * cross(u(:,1:3)', R'*v(:,1:3)'))';
0065     %
0066     ssn = sign((ones(N,1) * b' .* Mm) * [1 1 1]');
0067     srn = ssn.* sign(((R'*v(:,1:3)')' .* Nm(1:3,:)')*[1 1 1]'); 
0068     if mean(srn) > 0 && mean(ssn) > 0 
0069         solution = 1;
0070         be       = calc_v_from_S(S);
0071         Re       = R;
0072     end
0073 end
0074 if solution == 0
0075     be = zeros(3,1);
0076 end

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005