function [uE,vN]=rotate_uv2uEvN_llc(u,v,AngleCS,AngleSN,nfx,nfy)
%-------------------
%[uE,vN]=rotate_uv2uEvN_llc(u,v,AngleCS,AngleSN,nfx,nfy)
%input:
%  [u,v]        : original compact format
%  Angle[CS,SN] : Angle[CS,SN], in compact format
%  [nx,ny,nz]   : size of [u,v]
%output:
%  [uE,vN]      : compact format size [nx ny nz]
%-------------------

%get nz:
sz=size(u);if(length(sz)==2);sz=[sz 1];end;
nz=sz(3);
nx=nfx(3);
ny=nfy(1)+nfy(2)+nfx(3)+nfx(4)+nfx(5);
%centering
[uc,vc]=centering_llcuv(u,v,nfx,nfy);

%put from faces into compact, overwriting [u,v]
if(sum(size(uc{2}))>0);
  u=cat(2,uc{1},uc{2},uc{3},reshape(uc{4},nfy(4),nfx(4),nz),reshape(uc{5},nfy(5),nfx(5),nz));
  v=cat(2,vc{1},vc{2},vc{3},reshape(vc{4},nfy(4),nfx(4),nz),reshape(vc{5},nfy(5),nfx(5),nz));
else;
  u=cat(2,uc{1},uc{3},reshape(uc{4},nfy(4),nfx(4),nz),reshape(uc{5},nfy(5),nfx(5),nz));
  v=cat(2,vc{1},vc{3},reshape(vc{4},nfy(4),nfx(4),nz),reshape(vc{5},nfy(5),nfx(5),nz));
end;

%rotate
u=reshape(u,nx*ny,nz);
v=reshape(v,nx*ny,nz);
for k=1:nz
  uE(:,k)=AngleCS(:).*u(:,k)-AngleSN(:).*v(:,k);
  vN(:,k)=AngleSN(:).*u(:,k)+AngleCS(:).*v(:,k);
end;

uE=reshape(uE,nx,ny,nz);
vN=reshape(vN,nx,ny,nz);

return

