## Copyright (C) 2016
##
## 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 
## earth_flattening=1/298.257=0.0033528
## and earth_eccentricity=.081819221456
##
## @example
## >> f=ecc2flat(.081819221456) 
## f = 0.0033528 
## @end example
## 
## @seealso{flat2ecc}
## @end deftypefn

function f=ecc2flat(e)  
  ## starting equation   
  ## e^2=2f-f^2    
  ## -f^2+2f-e^2=0   
  ## f^2-2f+e^2=0  
  ## f=(2-√(4-(4*e^2)))/2  
  ## f=(2-√(4*(1-e^2)))/2   
  ## f=(2-2√(1-e^2))/2  
  ## f=1-√(1-e^2) or f=1+√(1-e^2)   
  ## from testing of the earth the equation f=1-√(1-e^2) should be used
  f = 1 - sqrt(1 - e ^ 2);
  endfunction 
