function[MG,KG]=coordinate_transform(n,L,A,theta,m,k,MG,KG);
%
MGJ=zeros(4,4);
KGJ=zeros(4,4);
%
tm=zeros(4,4);
tm(1,1)=cos(theta);
tm(2,2)=tm(1,1);
tm(3,3)=tm(1,1);
tm(4,4)=tm(1,1);
tm(1,2)=sin(theta);
tm(2,1)=-tm(1,2);
%
tm(3,4)=sin(theta);
tm(4,3)=-tm(3,4);
%
MGJ=(tm'*(m*tm))*A*L;
KGJ=(tm'*(k*tm))*A/L;
%
% add to global
%
for(i=1:4)
    for(j=1:4)
        MG(n(i),n(j))= MG(n(i),n(j)) + MGJ(i,j);
        KG(n(i),n(j))= KG(n(i),n(j)) + KGJ(i,j); 
    end
end