From d6213b52a20ac5d9e858d0dbccbee28d94e1a2f0 Mon Sep 17 00:00:00 2001 From: MCMF <> Date: Sat, 4 Nov 2023 16:45:03 +0100 Subject: [PATCH] Bug fix in fitQuadriTalus.m --- .../SubFunctions/FittingFun/fitQuadriTalus.m | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/STAPLE/GIBOC-core/SubFunctions/FittingFun/fitQuadriTalus.m b/STAPLE/GIBOC-core/SubFunctions/FittingFun/fitQuadriTalus.m index 3da026d..c8ff859 100644 --- a/STAPLE/GIBOC-core/SubFunctions/FittingFun/fitQuadriTalus.m +++ b/STAPLE/GIBOC-core/SubFunctions/FittingFun/fitQuadriTalus.m @@ -100,17 +100,19 @@ % Get the length of the edges of the quadrilateral edgesLength = zeros(4,1); -for i=1:4 - diff1 = Pts_proj_2D(quadriV(i+1),1)-Pts_proj_2D(quadriV(i),1); - diff2 = Pts_proj_2D(quadriV(i+1),2)-Pts_proj_2D(quadriV(i),2); - edgesLength(i) = sqrt(diff1^2+diff2^2); +for i=1:4 + dy = Pts_proj_2D(quadriV(i+1),1)-Pts_proj_2D(quadriV(i),1); + dz = Pts_proj_2D(quadriV(i+1),2)-Pts_proj_2D(quadriV(i),2); + edgesLength(i) = sqrt(dy^2+dz^2); end [~,Imax] = max(edgesLength); -% Index of the start vertex of the quadrilateral -I_V_sup = mod(Imax+2,4); -% Edge corresponding to the superior part of the bone is assumed to be the -% one opposing the largest one +% The edge corresponding to the superior part of the bone is assumed to be +% the one opposing the largest one +I_V_sup = mod(Imax+2,4); % Index of the start vertex of the superior edge +if I_V_sup == 0 + I_V_sup = 4; +end Edge_sup = quadriV(I_V_sup:I_V_sup+1); % Get the direction of the edge @@ -138,5 +140,4 @@ figure(projFig) end -end - +end \ No newline at end of file