%-------------------------------------------------------------------------------
% Script: BuildStrideMotion
% Objectivo: determinar as coordenadas Cartesianas ao longo de 1 ciclo completo
%-------------------------------------------------------------------------------

%-------------------------------------------------------------------------------
%-- Completar ciclo de locomoçao repetindo fases -------------------------------
%-------------------------------------------------------------------------------
 DIM_P = size(P_x,1);
 for r=1:size(SYM_motion,1),
 for k=1:DIM_P,
     
     %__ Componentes XX -----------------------------------------------------
      P_x(k,:,SYM_motion(r,2)) = P_x(k,:,SYM_motion(r,1))+Sl;
     %__ Componentes YY -----------------------------------------------------        
      P_y(k,:,SYM_motion(r,2)) = -P_y(k,:,SYM_motion(r,1))+L(8);
     %__ Componentes ZZ -----------------------------------------------------
      P_z(k,:,SYM_motion(r,2)) = P_z(k,:,SYM_motion(r,1));

 end 
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas dos cilindros --------------------------------------------------
%-------------------------------------------------------------------------------
 DIM_C = size(C_x1,2);
 for r=1:size(SYM_motion,1),
 for k=1:DIM_C,
     
     C_x1(:,k,SYM_motion(r,2),:) =  C_x1(:,DIM_C-k+1,SYM_motion(r,1),:)+Sl;
     C_x2(:,k,SYM_motion(r,2),:) =  C_x2(:,DIM_C-k+1,SYM_motion(r,1),:)+Sl;
     C_y1(:,k,SYM_motion(r,2),:) = -C_y1(:,DIM_C-k+1,SYM_motion(r,1),:)+L(8);
     C_y2(:,k,SYM_motion(r,2),:) = -C_y2(:,DIM_C-k+1,SYM_motion(r,1),:)+L(8);
     C_z1(:,k,SYM_motion(r,2),:) =  C_z1(:,DIM_C-k+1,SYM_motion(r,1),:);
     C_z2(:,k,SYM_motion(r,2),:) =  C_z2(:,DIM_C-k+1,SYM_motion(r,1),:);

 end
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas do pe livre ----------------------------------------------------
%-------------------------------------------------------------------------------
 for r=1:size(SYM_motion,1),
 
     F_x(:,:,SYM_motion(r,2),:) =  F_x(:,:,SYM_motion(r,1),:)+Sl;
     F_y(:,:,SYM_motion(r,2),:) = -F_y(:,:,SYM_motion(r,1),:)+L(8);
     F_z(:,:,SYM_motion(r,2),:) =  F_z(:,:,SYM_motion(r,1),:);
 
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas da secçao da anca ----------------------------------------------
%-------------------------------------------------------------------------------
 for r=1:size(SYM_motion,1),
 
     H_x(:,:,SYM_motion(r,2),:) =  H_x(:,:,SYM_motion(r,1),:)+Sl;
     H_y(:,:,SYM_motion(r,2),:) = -H_y(:,:,SYM_motion(r,1),:)+L(8);
     H_z(:,:,SYM_motion(r,2),:) =  H_z(:,:,SYM_motion(r,1),:);
 
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas da secçao do tronco --------------------------------------------
%-------------------------------------------------------------------------------
 for r=1:size(SYM_motion,1),
 
     W_x(:,:,SYM_motion(r,2),:) =  W_x(:,:,SYM_motion(r,1),:)+Sl;
     W_y(:,:,SYM_motion(r,2),:) = -W_y(:,:,SYM_motion(r,1),:)+L(8);
     W_z(:,:,SYM_motion(r,2),:) =  W_z(:,:,SYM_motion(r,1),:);
 
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas do exoesqueleto ------------------------------------------------
%-------------------------------------------------------------------------------
 for r=1:size(SYM_motion,1),
 
     E_x(:,:,SYM_motion(r,2),:) =  E_x(:,:,SYM_motion(r,1),:)+Sl;
     E_y(:,:,SYM_motion(r,2),:) = -E_y(:,:,SYM_motion(r,1),:)+L(8);
     E_z(:,:,SYM_motion(r,2),:) =  E_z(:,:,SYM_motion(r,1),:);
 
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas do rasto -------------------------------------------------------
%-------------------------------------------------------------------------------
 for r=1:size(SYM_motion,1),
 
     Rasto_x(:,:,SYM_motion(r,2)) =  Rasto_x(:,:,SYM_motion(r,1))+Sl;
     Rasto_y(:,:,SYM_motion(r,2)) = -Rasto_y(:,:,SYM_motion(r,1))+L(8); 
     Rasto_z(:,:,SYM_motion(r,2)) =  Rasto_z(:,:,SYM_motion(r,1)); 
 
 end
%----------------------------------------------------------------------------END

%-------------------------------------------------------------------------------
%-- Coordenadas do centro de massa ---------------------------------------------
%-------------------------------------------------------------------------------
 for r=1:size(SYM_motion,1),
     
     COG(1,:,SYM_motion(r,2)) =  COG(1,:,SYM_motion(r,1))+Sl;
     COG(2,:,SYM_motion(r,2)) = -COG(2,:,SYM_motion(r,1))+L(8); 
     COG(3,:,SYM_motion(r,2)) =  COG(3,:,SYM_motion(r,1)); 
 
 end
%----------------------------------------------------------------------------END