0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 close all
0018 clearvars
0019
0020 addpath(genpath('../../General-Functions'))
0021
0022 disp('--------------------------------------------')
0023 disp('Check direct estimation of plane from points')
0024 disp('--------------------------------------------')
0025
0026
0027 N_samples = 10000;
0028 disp(['Number of samples : ', num2str(N_samples)])
0029
0030
0031 sigma_x = 1e-3;
0032 disp(['MInimal standard deviation of points : ', num2str(sigma_x)])
0033
0034
0035 pointSpacing = 0.1;
0036 disp(['Point spacing in [-1,+1]x[-0.5,+0.5] : ', num2str(pointSpacing)])
0037 numPoints = length(-1:pointSpacing:1)*length(-0.5:pointSpacing:0.5);
0038 disp(['Number of points : ', num2str(numPoints)])
0039
0040
0041
0042 init_rand = 0;
0043 init_rand_seed(init_rand);
0044
0045
0046
0047
0048 iniPlane = [0, 0, 1, -1]';
0049
0050
0051
0052
0053 SIGMA = sigma_x * randi(10, [1, numPoints]);
0054
0055 w = 1./SIGMA.^2;
0056
0057
0058 alpha = 0.001;
0059
0060
0061 [m1, m2] = meshgrid(-1:pointSpacing:1, -0.5:pointSpacing:0.5);
0062 numPoints = numel(m1(:));
0063 iniPoints = [m1(:), m2(:), ones(numPoints,1)]';
0064
0065
0066 randRot = pi/4 * (rand(1,3) - 0.5);
0067 randR = calc_Rot_r([randRot(1), randRot(2), randRot(3)]);
0068 randT = 20 * (rand(3,1) - 0.5);
0069
0070
0071 plane_nd = [randR, randT; 0 0 0 1]' * iniPlane;
0072 plane_nd = plane_nd * sign(-plane_nd(4));
0073
0074
0075 Omega_s = zeros(1,N_samples);
0076 d_prime_s = zeros(1,N_samples);
0077 normal_XY_s = zeros(2,N_samples);
0078 var_q_s = zeros(1,N_samples);
0079 var_phi_s = zeros(1,N_samples);
0080 var_psi_s = zeros(1,N_samples);
0081 d_primes_s = zeros(1,N_samples);
0082
0083 start = cputime;
0084 for n_samples = 1:N_samples
0085
0086 points = randR'*(iniPoints - repmat(randT, 1, numPoints)) + ...
0087 repmat(SIGMA, 3, 1) .* randn(3, numPoints);
0088
0089
0090 [Xo, Q, var_q, var_phi, var_psi, est_sigma_0_2] = ...
0091 sugr_direct_fit_plane_centroid_form_to_points(points, SIGMA.^2);
0092
0093 Omega_s(n_samples) = est_sigma_0_2 * (numPoints-3);
0094 d_primes_s(n_samples) = -plane_nd(4) - plane_nd(1:3)' * Xo;
0095 normal_XY_s(:,n_samples) = Q(:,1:2)' * plane_nd(1:3);
0096 var_q_s(n_samples) = var_q;
0097 var_phi_s(n_samples) = var_phi;
0098 var_psi_s(n_samples) = var_psi;
0099
0100 end
0101 disp(['CPU time for ', num2str(N_samples),' samples : ',num2str(cputime-start)]);
0102
0103 Red = numPoints-3;
0104
0105
0106
0107
0108 est_par = [d_primes_s;normal_XY_s];
0109
0110 CovM_true = diag([var_q,var_phi,var_psi]);
0111
0112 check_estimation_result(Red,zeros(3,1),CovM_true,Omega_s/Red,est_par',1-alpha,' algebraic plane fit');
0113
0114
0115
0116
0117
0118