## Copyright (C) 2017
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn  {Function File} {@var{flat} =} flat2ecc (@var{ecc}) 
##
## This will return the flattening given an eccentricity 
##
## @example
## >> e_earth = .081819221456;
## >> f_earth = ecc2flat ( e_earth ) 
## f_earth = 0.0033528 
## @end example
##
## Also can do a vector
## @example
## >> e = 0:.01:.05;
## >> f = ecc2flat ( e )
##f =
##
##           0  5.0001e-05  0.00020002   0.0004501  0.00080032   0.0012508
##
## @end example
## 
## @seealso{flat2ecc}
## @end deftypefn

function f = ecc2flat( e )  
  if nargin < 1
    print_usage ();
  endif
  if ( ischar ( e ) )
      error ('Cannot be a string');
  else
    f = 1 - sqrt ( 1 - e.^ 2 );
  endif
endfunction 

%! test
%!
%! e = .081819221456;
%! e_vec = 0:.01:
%! assert( ecc2flat ( e ), 0.00335281317793612, 10^-12 );
%! assert ( ecc2flat( e ), [ 0 , 5e-5 , 2e-4 , 4.501e-4 , 8.0032e-4 , 0.00125078 ] , 10^-6)