Package gaiasky.util.elements
Class KeplerSolver
java.lang.Object
gaiasky.util.elements.KeplerSolver
Solve the elliptical
Kepler Equation
by bisections and Newton method with Taylor-expanded trigonometric functions.
It is designed for a general equation of the form
But this implementation deals only with the case
The method to solve the Kepler equation is given in two versions: The second version is faster, but it is assumed that the mean anomaly is between 0 and 2π.
Methods to compute the true anomaly from the eccentric anomaly and the eccentricity are also available in two versions.
This class is immutable.
The algorithm is taken fromT. Fukushima, 1996, Astron. J, 112, 2858.
It is designed for a general equation of the form
D - eX sin D + eY cos D = L,witheX2 + eY2 ≤ 1
But this implementation deals only with the case
eY = 0
and is optimized for that case.The method to solve the Kepler equation is given in two versions: The second version is faster, but it is assumed that the mean anomaly is between 0 and 2π.
Methods to compute the true anomaly from the eccentric anomaly and the eccentricity are also available in two versions.
Re-coded from Fortran and C.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor with default values for tolerance (1e-16) and maximum number of iterations (50).KeplerSolver(double errMax, int iterMax) -
Method Summary
Modifier and TypeMethodDescriptionfinal doubleeccAnom(double mA, double ecc) Solve Kepler Equation (see reference above).final doubleeccAnomConstrained(double mA, double ecc) Solve Kepler Equation by bisections and Newton method with Taylor expanded trigonometric functions.static final doubleerror(double eA, double mA, double ecc) Compute the absolute error of Kepler equation given the mean and eccentric anomalies and the eccentricity.static final doublemeanAnom(double eA, double ecc) Compute mean anomaly (applying Kepler Equation).static final doublemeanAnomConstrained(double eA, double ecc) Compute mean anomaly (applying Kepler Equation).
-
Constructor Details
-
KeplerSolver
public KeplerSolver(double errMax, int iterMax) - Parameters:
errMax- Error tolerance.iterMax- Maximum number of iterations.
-
KeplerSolver
public KeplerSolver()Constructor with default values for tolerance (1e-16) and maximum number of iterations (50).
-
-
Method Details
-
eccAnom
public final double eccAnom(double mA, double ecc) Solve Kepler Equation (see reference above). This method callseccAnomConstrainedto perform the actual resolution.- Parameters:
mA- Mean anomaly.ecc- Eccentricity.- Returns:
- the eccentric anomaly.
- Throws:
IllegalArgumentException- ifeccis not in the interval [0, 1).
-
eccAnomConstrained
public final double eccAnomConstrained(double mA, double ecc) Solve Kepler Equation by bisections and Newton method with Taylor expanded trigonometric functions. Note that, for performance, no consistency checks are performed on the input.- Parameters:
mA- Mean anomaly, assumed to be between 0 and 2pi.ecc- Eccentricity, assumed to be between 0 and 1.- Returns:
- the eccentric anomaly in the range of 0 through 2pi.
- Throws:
IllegalStateException- if the root could not be found within the specified accuracy in less than the number of iterations.
-
error
public static final double error(double eA, double mA, double ecc) Compute the absolute error of Kepler equation given the mean and eccentric anomalies and the eccentricity.- Parameters:
eA- eccentric anomaly.mA- mean anomaly.ecc- eccentricity.- Returns:
- the error.
-
meanAnomConstrained
public static final double meanAnomConstrained(double eA, double ecc) Compute mean anomaly (applying Kepler Equation). Note that, in this version, no consistency checks are performed on the input.- Parameters:
eA- Eccentric anomaly.ecc- Eccentricity.- Returns:
- the mean anomaly.
-
meanAnom
public static final double meanAnom(double eA, double ecc) Compute mean anomaly (applying Kepler Equation).- Parameters:
eA- Eccentric anomaly.ecc- Eccentricity.- Returns:
- the mean anomaly.
- Throws:
IllegalArgumentException- ifeccis not in the interval [0, 1).
-