Files
matlab-python/ATD/CalcoloStar_Report.m

43 lines
1.6 KiB
Matlab
Executable File

%% Funzione che calcola i segmenti della stella
function SegStar = CalcoloStar_Report(X_TuL,Z_TuL,Verso,Segmenti,SegStar,dim)
X1 = X_TuL(:,1);
Z1 = Z_TuL(:,1);
X2 = X_TuL(:,1);
Z2 = Z_TuL(:,1);
X1f = X_TuL(:,end);
Z1f = Z_TuL(:,end);
X2f = X_TuL(:,end);
Z2f = Z_TuL(:,end);
for J = 1:dim
N1 = Segmenti(J,1); % Numero primo punto
N1b = Segmenti(J,2); % Numero primo punto b
C1 = isnan(Segmenti(J,2)); % cerco se la seconda colonna è un NaN
N2 = Segmenti(J,3); % Numero secondo punto
[~,chc] = size(Segmenti);
if chc == 3 % non c'è la quarta colonna
C2 = 1;
else
N2b = Segmenti(J,4); % Numero secondo punto b
C2 = isnan(Segmenti(J,4)); % cerco se la quarta colonna è un NaN
end
if C1 == 0 % uso la media fra due nodi per il punto di inizio
X1(N1,1) = (X_TuL(N1,1) + X_TuL(N1b,1))/2;
X1f(N1,end) = (X_TuL(N1,end) + X_TuL(N1b,end))/2;
Z1(N1,1) = (Z_TuL(N1,1) + Z_TuL(N1b,1))/2;
Z1f(N1,end) = (Z_TuL(N1,end) + Z_TuL(N1b,end))/2;
end
if C2 == 0 % uso la media fra due nodi per il punto di arrivo
X2(N2,1) = (X_TuL(N2,1) + X_TuL(N2b,1))/2;
X2f(N2,end) = (X_TuL(N2,end) + X_TuL(N2b,end))/2;
Z2(N2,1) = (Z_TuL(N2,1) + Z_TuL(N2b,1))/2;
Z2f(N2,end) = (Z_TuL(N2,end) + Z_TuL(N2b,end))/2;
end
if Verso(J,1) && Verso (J,2) == 1 % Calcolo Orario per entrambi i punti (standard)
S_fin(J,1) = ((X1f(N1)- X2f(N2)).^2+(Z1f(N1)-Z2f(N2)).^2).^0.5;
S_ini(J,1) = ((X1(N1)- X2(N2)).^2+(Z1(N1)-Z2(N2)).^2).^0.5;
SegStar(J,1) = S_fin(J,1) - S_ini(J,1);
end
end
end