function J = TransposeJacobianCOG( q,wleg )
  
% Computes the differential inverse kinematics using the Jacobian ---------
  l0 = 47;  l1 = 140;  l2 = 146;
  m0 = 0.444;  m1 = 0.343;  m2 = 0.409;
  CM1y = 15.86; r1 = 88.52; r2 = 101.28;
  q1 = q(1);  q2 = q(2);  q3 = q(3);
  
  s1 = sin(q1); s2 = sin(q2); s3 = sin(q3);
  c1 = cos(q1); c2 = cos(q2); c3 = cos(q3);
  s23 = sin(q2+q3); c23 = cos(q2+q3);
% CPOG Jacobian matrix ----------------------------------------------------
  J(1,1) = 0;
  J(1,2) = wleg*( m1*r1*c2+m2*(l1*c2+r2*c23) );
  J(1,3) = wleg*m2*r2*c23;
  
  J(2,1) = -m1*(r1*c1*c2+CM1y*s1)-m2*(l1*c1*c2+r2*c1*c23);
  J(2,2) =  m1*r1*s1*s2+m2*(l1*s1*s2+r2*s1*s23);
  J(2,3) =  m2*r2*s1*s23;
  
  J(3,1) = -m1*(r1*s1*c2-CM1y*c1)-m2*(l1*s1*c2+r2*s1*c23);
  J(3,2) = -m1*r1*c1*s2-m2*(l1*c1*s2+r2*c1*s23);
  J(3,3) = -m2*r2*c1*s23;
% Transpose of the COG Jacobian  ------------------------------------------
  J = J';
%--------------------------------------------------------------------------  
end

