## Copyright (C) 2018 Anonymous ## ## 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; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{ecc} =} n2ecc (@var{n}) ## This returns the eccentricity given the third flattening (n) ## ## Examples: ## ## Scalar input: ## @example ## n_earth = 0.0016792; ## ecc_earth = n2ecc ( n_earth ) ## => ecc_earth = 0.081819 ## @end example ## ## Vector input: ## @example ## n_vec = [ 0.0016792 0.033525 ]; ## ecc = n2ecc ( n_vec ) ## => ecc = ## 0.081819 0.35432 ## @end example ## ## @seealso{n2ecc} function ecc = n2ecc ( n ) if nargin < 1 print_usage ( ); end if ( ischar ( n ) ) error ('n2ecc.m: numeric input expected'); elseif ( n > 1 ) error ('n2ecc.m: n should be <= 1' ) else ecc = sqrt ( 4*n ./ ( 1 + n ) .^2 ); end %! test %! %! n_earth = 0.00167922; %! n_jupiter = 0.0335246; %! n_vec = [ n_earth n_jupiter ]; %! assert ( n2ecc ( n_earth ) , .081819221456 , 10e-12 ); %! assert ( n2ecc ( n_vec ),[0.08181922 0.3543164],10e-8) %! error n2ecc ("n") endfunction