Ver Fonte

fix A2B_matrix to work with tetrahedral data again

Fernando Pablo Lopez-Lezcano há 9 anos atrás
pai
commit
86aab2364e
1 ficheiros alterados com 5 adições e 4 exclusões
  1. 5 4
      calibration/src/A2B_matrix.m

+ 5 - 4
calibration/src/A2B_matrix.m

@@ -30,12 +30,12 @@ function [A2B pv max_err] = A2B_matrix(Y, X, v_z_factor)
   % pv is the matrix of unknowns to be estimated
   % so Y = X pv
   if (nargin < 2 )
-    X = measurement_dirs_z0(size(Y,1));
+    X = measurement_dirs_z0(Y);
   end
   X1 = [ ones(size(Y,1), 1) X ];
   pv = X1 \ Y;
   max_err = max (Y - (X1 * pv));
-  if (size(Y, 1) > 4)
+  if (size(Y, 2) > 4)
     %% overdetermined
     pv = fill_v_z( pv )';
     ipv = pinv(pv);
@@ -46,12 +46,13 @@ function [A2B pv max_err] = A2B_matrix(Y, X, v_z_factor)
   end
 end
 
-function X = measurement_dirs_z0(n)
+function X = measurement_dirs_z0(Y)
+  n = size(Y, 1);
   if (nargin < 1)
     n = 8;
   end
   x_range = 0 : 2*pi/n : 2*pi*(n-1)/n;
-  if (n > 4)
+  if (size(Y, 2) > 4)
     %% add second order horizontal components
     u_range = [(0 : 4*pi/n : 2*pi*(n-1)/n) (0 : 4*pi/n : 2*pi*(n-1)/n)];
     X = [ cos(x_range)' sin(x_range)' zeros(n,1) cos(u_range)' sin(u_range)' ];