function COG_XYZi = ZeroLocalCOG( DM )

L = DM.L;
lf_H = DM.O(1,3);

%-------------------------------------------------------------------------------------
% Centro de massa obtido no CATIA: sistema de coordenadas de referencia colocado
% na extremidade do pe direito
%-------------------------------------------------------------------------------------
 COG_RL_C = [ 0.0400 0.0450 0.0463 0.0410 0.0428 0.0405 ; ...     %-- Right leg
              0.1420 0.1070 0.1020 0.1033 0.1037 0.1155 ; ...
              0.0170 0.0342 0.0945 0.1807 0.2643 0.2958 ; ...
              1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 ];

 COG_TH_C = [ 0.0959 0.0930 0.0953 0.0953 ; ...       %-- Hip section/trunk/head
              0.1184 0.1140 0.1118 0.1213 ; ...
              0.3589 0.4134 0.4948 0.5546 ; ...
              1.0000 1.0000 1.0000 1.0000 ];
     
 COG_RA_C = [ -0.01224 -0.02418 ; ...                 %-- Right arm
               0.10947  0.10120 ; ...
               0.52420  0.46700 ; ...
               1.00000  1.00000 ];
       
 COG_RL_C(3,:) = COG_RL_C(3,:)+lf_H;    %-- Altura do pe!!!
 COG_TH_C(3,:) = COG_TH_C(3,:)+lf_H;
 COG_RA_C(3,:) = COG_RA_C(3,:)+lf_H;
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas: CATIA -> XYZref
%-------------------------------------------------------------------------------------     
 T_C2R = [ 0 -1 0 0.102 ; 1 0 0 -0.055 ; 0 0 1 0 ; 0 0 0 1 ];
 COG_RL_R = T_C2R*COG_RL_C;
 COG_TH_R = T_C2R*COG_TH_C;
 COG_RA_R = T_C2R*COG_RA_C;
 
 T_C2R = [ 0 1 0 0.102 ; -1 0 0 L(8)+0.055; 0 0 1 0 ; 0 0 0 1 ];
 COG_LL_C = [1 0 0 0 ; 0 -1 0 0 ; 0 0 1 0 ; 0 0 0 1]*COG_RL_C;
 COG_LA_C = [1 0 0 0 ; 0 -1 0 0 ; 0 0 1 0 ; 0 0 0 1]*COG_RA_C;
 COG_LL_R = T_C2R*COG_LL_C;
 COG_LA_R = T_C2R*COG_LA_C;
  
 COG_R = [ COG_RL_R COG_LL_R COG_TH_R COG_RA_R COG_LA_R ];
%#####################################################################################
% PERNA DIREITA
%-------------------------------------------------------------------------------------     
% Transformaçao de coordenadas apliacada a m1: XYZref - > XYZ_0
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 1 0 0 0 ; 0 1 0 0 ; 0 0 1 0 ; 0 0 0 1];  
 COG_XYZi(:,1) = T_R2Si*COG_R(:,1);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m2: XYZref - > XYZ_1
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -L(1) ; 0 -1 0 0 ; 1 0 0 0 ; 0 0 0 1 ];  
 COG_XYZi(:,2) = T_R2Si*COG_R(:,2);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m3: XYZref - > XYZ_2
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L(1:2)) ; 1 0 0 0 ; 0 1 0 0 ; 0 0 0 1 ];  
 COG_XYZi(:,3) = T_R2Si*COG_R(:,3);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m4: XYZref - > XYZ_3
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L(1:3)) ; 1 0 0 0 ; 0 1 0 0 ; 0 0 0 1 ];  
 COG_XYZi(:,4) = T_R2Si*COG_R(:,4);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m5: XYZref - > XYZ_4
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L(1:4)) ; 1 0 0 0 ; 0 1 0 0 ; 0 0 0 1 ];  
 COG_XYZi(:,5) = T_R2Si*COG_R(:,5); 
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m6: XYZref - > XYZ_5
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L(1:5)) ; 0 -1 0 0 ; 1  0 0 0 ; 0  0 0 1 ];  
 COG_XYZi(:,6) = T_R2Si*COG_R(:,6);
%#####################################################################################
% PERNA ESQUERDA
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m6: XYZref - > XYZ_7
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 -1 0  L(8) ; 1  0 0  0 ; 0  0 1 -sum(L(1:6)) ; 0  0 0  1 ];  
 COG_XYZi(:,7) = T_R2Si*COG_R(:,7);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m5: XYZref - > XYZ_8
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 -1  0 L(8) ; 0  0 -1 sum(L(1:5)) ; 1  0  0 0 ; 0  0  0 1 ];  
 COG_XYZi(:,8) = T_R2Si*COG_R(:,8); 
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m4: XYZref - > XYZ_9
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 -1 sum(L(1:4)) ; 1  0  0 0 ; 0 -1  0 L(8) ; 0  0  0 1 ];  
 COG_XYZi(:,9) = T_R2Si*COG_R(:,9);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m3: XYZref - > XYZ_10
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 -1 sum(L(1:3)) ; 1  0  0 0 ; 0 -1  0 L(8) ; 0  0  0 1 ];  
 COG_XYZi(:,10) = T_R2Si*COG_R(:,10); 
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m2: XYZref - > XYZ_11
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 -1 sum(L(1:2)) ; 1  0  0 0 ; 0 -1  0 L(8) ; 0  0  0 1 ];  
 COG_XYZi(:,11) = T_R2Si*COG_R(:,11);
%-------------------------------------------------------------------------------------     
% Transformaçao de coordenadas apliacada a m1: XYZref - > XYZ_12
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 -1  sum(L(1:1)) ; 0  1  0 -L(8) ; 1  0  0  0 ; 0  0  0  1 ];  
 COG_XYZi(:,12) = T_R2Si*COG_R(:,12);
%#####################################################################################
% SECÇAO DA ANCA-TRONCO&CABEÇA
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m7: XYZref - > XYZ_14
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 -1 0 L(8)/2 ; 0 0 -1 sum(L(1:7)) ; 1  0 0 0 ; 0 0 0 1 ];  
 COG_XYZi(:,13) = T_R2Si*COG_R(:,13);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m8: XYZref - > XYZ_15
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 1 -sum(L([1:7 9])) ; 0 -1 0 L(8)/2 ; 1  0 0 0 ; 0  0 0 1 ];  
 COG_XYZi(:,14) = T_R2Si*COG_R(:,14);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m9: XYZref - > XYZ_17
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L([1:7 9:11])) ; 1 0 0 0 ; 0 1 0 -L(8)/2 ; 0 0 0 1 ];  
 COG_XYZi(:,15) = T_R2Si*COG_R(:,15); 
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m10: XYZref - > XYZ_18
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L([1:7 9:13])) ; 1 0 0 0 ; 0 1 0 -L(8)/2 ; 0 0 0 1 ];  
 COG_XYZi(:,16) = T_R2Si*COG_R(:,16);
%#####################################################################################
% BRAÇO DIREITO
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m11: XYZref - > XYZ_21
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 1 -sum(L([1:7 9:12])) ; -1  0 0 0 ; 0 -1 0 -L(16) ; 0  0 0 1 ];  
 COG_XYZi(:,17) = T_R2Si*COG_R(:,17);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m12: XYZref - > XYZ_22
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L([1:7 9:12])) ; 0 -1 0 -L(16)-L(17) ; 1  0 0 0 ; 0  0 0 1 ];  
 COG_XYZi(:,18) = T_R2Si*COG_R(:,18);
%#####################################################################################
% BRAÇO ESQUERDO
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m11: XYZref - > XYZ_24
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0  0 1 -sum(L([1:7 9:12])) ; 1  0 0 0 ; 0  1 0 -L(8)-L(16) ; 0  0 0 1 ];  
 COG_XYZi(:,19) = T_R2Si*COG_R(:,19);
%-------------------------------------------------------------------------------------
% Transformaçao de coordenadas apliacada a m12: XYZref - > XYZ_25
%-------------------------------------------------------------------------------------     
 T_R2Si = [ 0 0 1 -sum(L([1:7 9:12])) ; 0 -1 0 L(8)+L(16)+L(17) ; 1  0 0 0 ; 0  0 0 1 ];  
 COG_XYZi(:,20) = T_R2Si*COG_R(:,20);
%-------------------------------------------------------------------------------------     
 