// Copyright (c) CNES 2008 // // This software is part of CelestLab, a CNES toolbox for Scilab // // This software is governed by the CeCILL license under French law and // abiding by the rules of distribution of free software. You can use, // modify and/ or redistribute the software under the terms of the CeCILL // license as circulated by CEA, CNRS and INRIA at the following URL // 'http://www.cecill.info'. function [E] = CL_kp_M2E(ecc,M) // Mean anomaly to eccentric anomaly (Kepler's equation) // // Calling Sequence // E = CL_kp_M2E(ecc,M) // // Description // //

Solves Kepler's equation for hyperbolic or elliptical orbits.

//

Given the eccentricity ecc and the mean anomaly // M, this function computes the eccentric anomaly // E, such that :

//

- Elliptical orbits ( ecc < 1 ) : E - ecc * sin(E) = M

//

- Hyperbolic orbits ( ecc > 1 ) : ecc * sinh(E) - E = M

//
//
// // Parameters // M: Mean anomaly [rad] (PxN or Px1) // ecc: Eccentricity (PxN or Px1) // E: Eccentric anomaly [rad] (PxN) // // Authors // CNES - DCT/SB // // Bibliography // 1) CNES - MSLIB FORTRAN 90, Volume V (mvi_kepler_hyperb) // 2) Procedures for solving Kepler's Equation - A.W. Odell and R.H Gooding - 1986 // // See also // CL_kp_E2M // // Examples // // Elliptic and hyperbolic orbit: // M = [0.1, 0.2]; // ecc = [0.3, 1.5]; // E = CL_kp_M2E(ecc,M); // // // Consistency test: // M - CL_kp_E2M(ecc,E) // => 0 // Declarations: // Code: I = find(ecc < 0); if (I <> []) CL__error("Invalid eccentricity (<0)"); end // check / resize nr = size(ecc,1); [ecc,M] = CL__checkInputs(ecc,nr,M,nr); E = %nan * ones(M); // initialization needed ! // ------------------------ // Parabolic orbit: // result is %nan // ------------------------ // ------------------------ // Ellipse // ------------------------ I = find(ecc < 1); if (I <> []) E(I) = CL__kp_M2Eell(ecc(I), M(I)); end // ------------------------ // Hyperbola // ------------------------ I = find(ecc > 1); if (I <> []) E(I) = CL__kp_M2Ehyp(ecc(I), M(I)); end endfunction