function [X,Y]=ll2stereo(lon,lat,e,R,clon,clat)
%-----------------------------------------------------------------------
% function [X,Y]=ll2stereo(lon,lat,e,R,clon,clat)
% 
% function to project local coordinates [lon,lat]
% into stereographic projection center at [clon,clat]
%
% INPUT: 
%   lon & lat: longitudes of points, size [Mx1], [Mx1]
%   e: eccentricity of ellipsoid, e.g., 0.081816153
%   R: equatorial radius of ellipsoid, e.g., 6378.273e3
%   [clon,clat]: center [lon,lat] of projection, e.g., [120,70];
% OUTPUT:
%   [X,Y]: x- and y- locations relative to center, [Mx1], [Mx1]
%
% ATN 11.20.06
%------------------------------------------------------------------------

% defining map projection:
mstruct=defaultm('stereo');
mstruct.origin=[clat,clon,0];
mstruct.geoid=[R,e];
mstruct.maplatlimit=[max(clat-10,-90),min(clat+10,90)];
mstruct.mapparallels=clat;
%mstruct.scalefactor=.9960922;
mstruct=defaultm(mstruct);

% Now projecting:
[X,Y]=mfwdtran(mstruct,lat,lon);

return
