function [U,V]=get_uXvY(ui,vi,loni,lati,proj_ctr,hemis);
%------------------------------------------------------------------------------
% function [U,V]=get_uXvY(ui,vi,loni,lati,proj_ctr,hemis)
%
% input:
%  [ui,vi]: velocity in NS/EW coord, size (primed, ny*nx,1)
%  [loni,lati]: locations of [ui,vi], size (primed, ny*nx,1)
%  proj_ctr: center longitude for llssmi1, [-180,180]
%  hemis: 1 = north, -1 = south
%
%  ATN 013107
%------------------------------------------------------------------------------

conversion=6378.273e3*pi/180;

% check size:
[nx,ny]=size(ui);
if(nx==1|ny==1);
  [X,Y]=llssmi1(loni,lati,proj_ctr,hemis);

  le=sqrt(ui.^2+vi.^2);theta=90-atan2(vi,ui).*180/pi;
  ptB=get_latlon(theta,le./conversion,[loni,lati,zeros(size(loni))]);
  [XB,YB]=llssmi1(ptB(:,1),ptB(:,2),proj_ctr,hemis);
  U=XB-X;
  V=YB-Y;
else;
  error('need ui/vi/loni,lati in primed size [ny*nx,1]');
end;
return
