mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
kepler.hpp File Reference

Declarations for the utilities related to the Kepler problem. More...

Declarations for the utilities related to the Kepler problem.

Author
Jared R. Males

Definition in file kepler.hpp.

Go to the source code of this file.

Namespaces

 mx
 The mxlib c++ namespace.
 

Functions

template<typename realT >
long mx::astro::hyperbolic_kepler (realT &E, realT &err, realT e, realT M, realT tol, long itmax)
 Solve the hyperbolic kepler equation (for e> 1). More...
 
template<typename realT >
realT mx::astro::kepler_danby_1 (realT e, realT M, realT Ei)
 Calculate the next iteration of Danby's quartic Newton-Raphson method. More...
 
template<typename realT >
long mx::astro::solve_kepler_danby (realT &E, realT &D, realT e, realT M, realT tol, long itmax)
 Solve Kepler's equation using Danby's quartic Newton-Raphson method. More...
 
template<typename realT >
long mx::astro::solve_kepler (realT &E, realT &D, realT e, realT M, realT tol=KEPLER_TOL, long itmax=KEPLER_ITMAX)
 Solve Kepler's equation for any e. Uses solve_kepler_danby if e < 1.0, hyperbolic_kepler otherwise. More...
 
template<typename arithT >
arithT mx::astro::kepler_danby_diff_1 (arithT EC, arithT ES, arithT dM, arithT dEi)
 Calculate the next iteration of Danby's quartic Newton-Raphson method (difference form). More...
 
template<typename arithT >
long mx::astro::solve_keplerdiff_danby (arithT *dE, arithT *D, arithT e, arithT EC, arithT ES, arithT dM, arithT tol, long itmax)
 Solve Kepler's equation in difference form using Danby's quartic Newton-Raphson method. More...
 
template<typename arithT >
int mx::astro::get_W_1pt_z0 (arithT &W, arithT x, arithT y, arithT r, arithT f, arithT w)
 Calculate the inclination and the longitude of the ascending node given a point on the orbit projected onto the plane of the sky, the argument of pericenter, the current true radius, and the current true anomaly. More...
 

Function Documentation

◆ get_W_1pt_z0()

template<typename arithT >
int mx::astro::get_W_1pt_z0 ( arithT &  W,
arithT  x,
arithT  y,
arithT  r,
arithT  f,
arithT  w 
)

Calculate the inclination and the longitude of the ascending node given a point on the orbit projected onto the plane of the sky, the argument of pericenter, the current true radius, and the current true anomaly.

Solutions are not always possible. You must check the return value to know if the results are valid.

Parameters
i[output] the inclination (there will be 2)
W[output] the longitude of the ascending node (there will be 2)
x[input] the x coordinate of the projection onto the reference plane
y[input] the y coordinate of the projection onto the reference plane
rho[input] the projected separation (yes this is redundant to x and y, but it is passed independently for efficiency)
r[input] the physical (3D) separation
f[input] the true anomaly
w[input] the argument of pericenter
Return values
0on success
-1if no solution is possible due to ...
-2if no solution is possible due to z = 0
-3if no solution is possible due to ... Calculate the longitude of the ascending node given a point on the orbit projected onto the plane of the sky, the argument of pericenter, the current radius, and the current true anomaly. Used for the z = 0, i != 0/PI case. i.e. sin(w+f) = 0, cos(w+f) = +/- 1. w must be either -f or PI - f.
Parameters
W[output] the longitude of the ascending node.
x[input] the x coordinate of the starting point
y[input] the y coordinate of the starting point
r[input] the current 3D separation from the star
f[input] the current true anomaly
w[input] the argument of pericenter
Return values
0on success
-1if the conditions aren't met by w an df

Definition at line 288 of file kepler.hpp.

References mx::astro::get_W_1pt_z0().

Referenced by mx::astro::get_W_1pt_z0().

◆ kepler_danby_diff_1()

template<typename arithT >
arithT mx::astro::kepler_danby_diff_1 ( arithT  EC,
arithT  ES,
arithT  dM,
arithT  dEi 
)

Calculate the next iteration of Danby's quartic Newton-Raphson method (difference form).

Definition at line 191 of file kepler.hpp.

References mx::astro::kepler_danby_diff_1().

Referenced by mx::astro::kepler_danby_diff_1(), and mx::astro::solve_keplerdiff_danby().

◆ solve_keplerdiff_danby()

template<typename arithT >
long mx::astro::solve_keplerdiff_danby ( arithT *  dE,
arithT *  D,
arithT  e,
arithT  EC,
arithT  ES,
arithT  dM,
arithT  tol,
long  itmax 
)

Solve Kepler's equation in difference form using Danby's quartic Newton-Raphson method.

Parameters
dE[output] is the eccentric anomaly
D[output] is the error after the last iteration
e[input] is the eccentricity
EC[input]
ES[input]
dM[input]
tol[input] is the desired tolerance
itmax[input] is the maximum number of iterations
Return values
-1on exceeding itmax, otherwise reurns the number of iterations.

Definition at line 225 of file kepler.hpp.

References mx::astro::kepler_danby_diff_1(), mx::math::func::sign(), and mx::astro::solve_keplerdiff_danby().

Referenced by mx::astro::solve_keplerdiff_danby().