function A = LinAce3dof_COG( q,dq,ddq,L,R )

global CM0x CM1y 

%-- Constants and definitions ---------------------------------------------
  l0 = L(1);  l1 = L(2);  l2 = L(3);
  r0 = R(1);  r1 = R(2);  r2 = R(3);
  
    q1 = q(1);     q2 = q(2);     q3 = q(3);
   dq1 = dq(1);   dq2 = dq(2);   dq3 = dq(3);
  ddq1 = ddq(1); ddq2 = ddq(2); ddq3 = ddq(3);
  
  s1 = sin(q1); s2 = sin(q2); 
  c1 = cos(q1); c2 = cos(q2); 
  s23 = sin(q2+q3); c23 = cos(q2+q3);
%-- Linear acceleration vector --------------------------------------------  
 A(1,1) = 0;
 A(1,2) = 0;
 A(1,3) = 0;
 
 A(2,1) = r1*c2*ddq2-r1*s2*dq2^2;
 A(2,2) = -(r1*c1*c2+CM1y*s1)*ddq1+(r1*s1*s2)*ddq2+(r1*s1*c2-CM1y*c1)*dq1^2+...
           (2*r1*c1*s2)*dq1*dq2+(r1*s1*c2)*dq2^2;
 A(2,3) = (-r1*s1*c2+CM1y*s1)*ddq1-(r1*c1*s2)*ddq2-(r1*c1*c2+CM1y*s1)*dq1^2+...
           (2*r1*s1*s2)*dq1*dq2-(r1*c1*c2)*dq2^2;
       
 A(3,1) = (l1*c2+r2*c23)*ddq2+(r2*c23)*ddq3-l1*s2*dq2^2-r2*s23*(dq2+dq3)^2;
 A(3,2) = -(l1*c1*c2+r2*c1*c23)*ddq1+(l1*s1*s2+r2*s1*s23)*ddq2+(r2*s1*s23)*ddq3+...
           (l1*s1*c2+r2*s1*c23)*dq1^2+(2*l1*c1*s2)*dq1*dq2+(l1*s1*c2)*dq2^2+...
           2*r2*c1*s23*dq1*(dq2+dq3)+r2*s1*c23*(dq2+dq3)^2;
 A(3,3) = -(l1*s1*c2+r2*s1*c23)*ddq1-(l1*c1*s2+r2*c1*s23)*ddq2-(r2*c1*s23)*ddq3-...
           (l1*c1*c2+r2*c1*c23)*dq1^2+(2*l1*s1*s2)*dq1*dq2-(l1*c1*c2)*dq2^2+...
           2*r2*s1*s23*dq1*(dq2+dq3)-r2*c1*c23*(dq2+dq3)^2;
%-----------------------------------------------------------------------end
end
