%dimensione stanza
dim_stanza_x=10000;
dim_stanza_y=10000;

%Ricostruisco i punti con 8 telecamere, con minimi quadrati pesati e
%mantenendo i raggi

T1P=[a{1}' b{1}' c{1}' num_pixel_centri{1}' x_f_as(1)*ones(length(a{1}),1) y_f_as(1)*ones(length(a{1}),1)];
T2P=[a{2}' b{2}' c{2}' num_pixel_centri{2}' x_f_as(2)*ones(length(a{2}),1) y_f_as(2)*ones(length(a{2}),1)];
T3P=[a{3}' b{3}' c{3}' num_pixel_centri{3}' x_f_as(3)*ones(length(a{3}),1) y_f_as(3)*ones(length(a{3}),1)];
T4P=[a{4}' b{4}' c{4}' num_pixel_centri{4}' x_f_as(4)*ones(length(a{4}),1) y_f_as(4)*ones(length(a{4}),1)];
T5P=[a{5}' b{5}' c{5}' num_pixel_centri{5}' x_f_as(5)*ones(length(a{5}),1) y_f_as(5)*ones(length(a{5}),1)];
T6P=[a{6}' b{6}' c{6}' num_pixel_centri{6}' x_f_as(6)*ones(length(a{6}),1) y_f_as(6)*ones(length(a{6}),1)];
T7P=[a{7}' b{7}' c{7}' num_pixel_centri{7}' x_f_as(7)*ones(length(a{7}),1) y_f_as(7)*ones(length(a{7}),1)];
T8P=[a{8}' b{8}' c{8}' num_pixel_centri{8}' x_f_as(8)*ones(length(a{8}),1) y_f_as(8)*ones(length(a{8}),1)];

%%Inizilizzo

R11Pa3=cell(1,2);
R21Pa3=cell(1,2);
R31Pa3=cell(1,2);
R41Pa3=cell(1,2);

%Inizializzo i punti ricostruiti

tmpP11a3=cell(1,4);
tmpP11a3{1}=[-1 -1 -1];
tmpP11a3{2}=[1 1 1 1 1 1];
tmpP11a3{3}=[1 1 1 1 1 1];
tmpP11a3{4}=[1 1 1 1 1 1];


P11Pa3=cell(1,2);
P11Pa3{1}=tmpP11a3;
P11Pa3{2}=tmpP11a3;

%Associo le telecamere ricordando che al primo passo nn vi sono
%ricostruzioni

R11Pa3{1}=T1P;
R11Pa3{2}=T2P;
R21Pa3{1}=T3P;
R21Pa3{2}=T4P;
R31Pa3{1}=T5P;
R31Pa3{2}=T6P;
R41Pa3{1}=T7P;
R41Pa3{2}=T8P;

set(S.tP1R1,'string','-----','visible','on')
set(S.tP1R2,'string','-----','visible','on')
set(S.tP1R3,'string','-----','visible','on')
set(S.tP1R4,'string','-----','visible','on')

%secondo passo dell'albero
tic
[R12Pa3 P12Pa3]=associa3_pes(R11Pa3, R21Pa3, P11Pa3, P11Pa3,epsilon,dim_stanza_x,dim_stanza_y,d_max);
t1=toc;
set(S.tP2R2,'string',t1,'visible','on')
tic
[R22Pa3 P22Pa3]=associa3_pes(R31Pa3, R41Pa3, P11Pa3, P11Pa3,epsilon,dim_stanza_x,dim_stanza_y,d_max);
t2=toc;
set(S.tP2R2,'string',t2,'visible','on')
%terzo passo dell'albero
tic
[R14Pa3 P14Pa3]=associa3_pes(R12Pa3, R22Pa3, P12Pa3, P22Pa3,epsilon,dim_stanza_x,dim_stanza_y,d_max);
t3=toc;
set(S.tP3R1,'string',t3,'visible','on')
tmpo=t3+max([t1 t2]);
set(S.Ttot,'string',tmpo,'visible','on')