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

sugr_generate_true_2D_point_pairs_E_matrix

PURPOSE ^

% Generate true 2D point pairs from Relative Orientation,

SYNOPSIS ^

function [PP,X] = sugr_generate_true_2D_point_pairs_E_matrix(b,R,N,br,Z0)

DESCRIPTION ^

% Generate true 2D point pairs from Relative Orientation,
 i.e., for given b, R generate N point pairs

 PP = sugr_generate_true_2D_point_pairs_E_matrix(b,R,N,boolean_r,Z0);

 b        = 3 x 1 vector 
 R        = 3x3 matrix R
 N         = number of points (in square/cube [-1,1]^2  / 3
 boolean_r = boolean: points should sit random
                else: points sit in a square +- random (N should be square)
 Z0        = Z-shift of points from origin

 PP = point pairs
      PP.h = N x 6 matrix of pairs of homogeneous point coordinates
      PP.Crr = N x 4 x 4 sith 4 x 4 reduced CovM of point pairs
      PP.type = 8 * ones(N,1)
 X  = true 3D coordinates

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

 See also sugr_E_Matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Generate true 2D point pairs from Relative Orientation,
0002 % i.e., for given b, R generate N point pairs
0003 %
0004 % PP = sugr_generate_true_2D_point_pairs_E_matrix(b,R,N,boolean_r,Z0);
0005 %
0006 % b        = 3 x 1 vector
0007 % R        = 3x3 matrix R
0008 % N         = number of points (in square/cube [-1,1]^2  / 3
0009 % boolean_r = boolean: points should sit random
0010 %                else: points sit in a square +- random (N should be square)
0011 % Z0        = Z-shift of points from origin
0012 %
0013 % PP = point pairs
0014 %      PP.h = N x 6 matrix of pairs of homogeneous point coordinates
0015 %      PP.Crr = N x 4 x 4 sith 4 x 4 reduced CovM of point pairs
0016 %      PP.type = 8 * ones(N,1)
0017 % X  = true 3D coordinates
0018 %
0019 % Wolfgang Förstner 09/2011
0020 % wfoerstn@uni-bonn.de
0021 %
0022 % See also sugr_E_Matrix
0023 
0024 function [PP,X] = sugr_generate_true_2D_point_pairs_E_matrix(b,R,N,br,Z0)
0025 
0026 K   = eye(3);
0027 P1  = K *     [eye(3),zeros(3,1)];
0028 P2  = K * R * [eye(3),-b];
0029 % random points in unit square shifted by Z0
0030 X = zeros(N,4);
0031 if br
0032     for n = 1:N
0033         %random points
0034         X(n,:)   = [rand(3,1)*2-1+[0,0,Z0]';1];
0035         % true image coordinates
0036         xs  = P1 * X(n,:)';
0037         xss = P2 * X(n,:)';
0038         xs  =xs/norm(xs);
0039         xss =xss/norm(xss);
0040         % struct of true point pairs
0041         PP.h(n,:)     = [xs',xss'];
0042         PP.Crr(n,:,:) = zeros(4);
0043         PP.type(n)    = 8;
0044     end
0045     cov(X);
0046 else
0047     M = ceil(sqrt(N));
0048     n = 0;
0049     for m = 1:M
0050         for k=1:M
0051            n = n+1;
0052            if n <= N
0053                X(n,:) = [-(M-1)/2+2*(m-1)/(M-1);...
0054                     -(M-1)/2+2*(k-1)/(M-1);...
0055                     Z0+rand(1)-0.5;...
0056                     1];
0057                % true image coordinates
0058                 xs  = P1 * X(n,:)';
0059                 xss = P2 * X(n,:)';
0060                 xs  = xs/norm(xs);
0061                 xss = xss/norm(xss);
0062                 % struct of true point pairs
0063                 PP.h(n,:)     = [xs',xss'];
0064                 PP.Crr(n,:,:) = zeros(4);
0065                 PP.type(n)    = 8;
0066            end
0067         end
0068     end
0069 end
0070 
0071 figure
0072 hold on
0073 plot3(X(:,1),X(:,2),X(:,3),'.r')
0074 plot3(0,0,0,'ob')
0075 plot3(b(1),b(2),b(3),'xb')

Generated on Mon 08-Jan-2018 17:21:49 by m2html © 2005