mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Calculations of orbits and related quantities.
Modules | |
The Kepler Problem | |
Functions | |
template<typename units > | |
units::realT | mx::astro::orbitPeriod (typename units::realT m1, typename units::realT m2, typename units::realT a) |
Calculate the period of an orbit, given the masses and semi-major axis. More... | |
template<typename units > | |
units::realT | mx::astro::orbitSemiMaj (typename units::realT m1, typename units::realT m2, typename units::realT P) |
Calculate the semi-major axis of an orbit, given the masses and Period, using SI units. More... | |
template<typename realT > | |
realT | mx::astro::orbitMeanAnol (realT t, realT t0, realT P) |
Calculate the mean anomaly at time t, given the time of pericenter passage t0 and period P. More... | |
template<typename realT > | |
long | mx::astro::orbitElements (realT &r, realT &f, realT E, realT D, realT e, realT M, realT a, realT tol=KEPLER_TOL, long itmax=KEPLER_ITMAX) |
Calculate the separation and true anomaly for an orbit at the specified mean anomaly. More... | |
template<typename realT > | |
realT | mx::astro::orbitPhaseCosine (realT f, realT w, realT inc) |
Get the orbital phase at true anomaly f. Calculates the cos(alfa) where alfa is the orbital phase. More... | |
template<typename realT > | |
realT | mx::astro::orbitLambertPhase (realT cos_alf) |
Get the lambertian phase function at orbital phase specified as cos(alfa), where alfa is the phase angle. More... | |
template<typename units > | |
units::realT | mx::astro::orbitRV (typename units::realT m1, typename units::realT m2, typename units::realT inc, typename units::realT a, typename units::realT e, typename units::realT w, typename units::realT f) |
Calculate the radial velocity of an orbiting body inclined relative to an observer. More... | |
template<typename vectorT , typename realT > | |
int | mx::astro::orbitCartesianWork (vectorT *x, vectorT *y, vectorT *z, vectorT *r, vectorT *rProj, vectorT *f, vectorT *cos_alf, vectorT *phi, const vectorT &t, const size_t N, realT a, realT P, realT e, realT t0, realT i, realT w, realT W) |
Calculate various quantities of an orbit given the keplerian elements and a vector of times. More... | |
template<typename vectorT , typename arithT > | |
int | mx::astro::orbitCartesian2DPhi (vectorT &x, vectorT &y, vectorT &r, vectorT &rProj, vectorT &phi, const vectorT &t, const size_t N, arithT a, arithT P, arithT e, arithT t0, arithT i, arithT w, arithT W) |
Calculate the cartesian x-y position and the Lambert phase function of an orbit given Keplerian elements and a vector of times. More... | |
int mx::astro::orbitCartesian2DPhi | ( | vectorT & | x, |
vectorT & | y, | ||
vectorT & | r, | ||
vectorT & | rProj, | ||
vectorT & | phi, | ||
const vectorT & | t, | ||
const size_t | N, | ||
arithT | a, | ||
arithT | P, | ||
arithT | e, | ||
arithT | t0, | ||
arithT | i, | ||
arithT | w, | ||
arithT | W | ||
) |
Calculate the cartesian x-y position and the Lambert phase function of an orbit given Keplerian elements and a vector of times.
vectorT | a type whose elements are accessed with the [] operator. |
arithT | the type in which to perform arithmetic |
-1 | on error calculating the orbit (from orbitCartesianWork) |
0 | on success. |
[out] | x | the projected x positions of the orbit. Must be at least as long as t. |
[out] | y | the projected y positions of the orbit. Must be at least as long as t. |
[out] | r | the separation of the orbit. Must be at least as long as t. |
[out] | rProj | the projected separation of the orbit. Must be at least as long as t. |
[out] | phi | the Lambert phase function. Must be at least as long as t. |
[in] | t | the times at which to calculate the projected positions |
[in] | N | the number of points contained in N, and allocated in nx, ny, nz |
[in] | a | the semi-major axis of the orbit |
[in] | P | the orbital period |
[in] | e | the eccentricity of the orbit |
[in] | t0 | the time of pericenter passage of the orbit |
[in] | i | the inclination of the orbit |
[in] | w | the argument of pericenter of the orbit |
[in] | W | the longitude of the ascending node of the orbit. |
Definition at line 298 of file orbitUtils.hpp.
References mx::astro::orbitCartesianWork().
int mx::astro::orbitCartesianWork | ( | vectorT * | x, |
vectorT * | y, | ||
vectorT * | z, | ||
vectorT * | r, | ||
vectorT * | rProj, | ||
vectorT * | f, | ||
vectorT * | cos_alf, | ||
vectorT * | phi, | ||
const vectorT & | t, | ||
const size_t | N, | ||
realT | a, | ||
realT | P, | ||
realT | e, | ||
realT | t0, | ||
realT | i, | ||
realT | w, | ||
realT | W | ||
) |
Calculate various quantities of an orbit given the keplerian elements and a vector of times.
Only those quantities with non-null pointers are actually calculated.
The orbital parameters with dimensions, (a, P, and t0) must be in consistent units.
vectorT | a type whose elements are accessed with the [] operator. No other requirements are placed on this type, so it could be a native pointer (i.e. double *). |
realT | the type in which to perform calculations. Does not need to match the storage type of vectorT. |
-1 | on error calculating the orbit (from rf_elements) |
0 | on success. |
[out] | x | [optional] If not NULL, will be the projected x positions of the orbit. Must be at least as long as t. |
[out] | y | [optional] If not NULL, will be the projected y positions of the orbit. Must be at least as long as t. |
[out] | z | [optional] If not NULL, will be the projected z positions of the orbit. Must be at least as long as t. |
[out] | r | [optional] If not NULL, will be the separation of the orbit. Must be at least as long as t. |
[out] | rProj | [optional] If not NULL, will be the projected separation of the orbit. Must be at least as long as t. |
[out] | f | [optional] If not NULL, will be the true anomaly of the orbit. Must be at least as long as t. |
[out] | cos_alf | [optional] If not NULL, will be the phase angle of the orbit. Must be at least as long as t. |
[out] | phi | [optional] If not NULL, will be the Lambertian phase function. Must be at least as long as t. |
[in] | t | the times at which to calculate the projected positions |
[in] | N | the number of points contained in t, and allocated in nx, ny, nz. Avoids requiring a size() member (i.e. if vectorT is native pointers). |
[in] | a | the semi-major axis of the orbit. |
[in] | P | the orbital period. |
[in] | e | the eccentricity of the orbit. |
[in] | t0 | the time of pericenter passage of the orbit. |
[in] | i | the inclination of the orbit [radians]. |
[in] | w | the argument of pericenter of the orbit [radians]. |
[in] | W | the longitude of the ascending node of the orbit [radians]. |
Definition at line 205 of file orbitUtils.hpp.
References mx::astro::orbitElements(), and mx::astro::orbitMeanAnol().
Referenced by mx::astro::orbitCartesian2DPhi().
long mx::astro::orbitElements | ( | realT & | r, |
realT & | f, | ||
realT | E, | ||
realT | D, | ||
realT | e, | ||
realT | M, | ||
realT | a, | ||
realT | tol = KEPLER_TOL , |
||
long | itmax = KEPLER_ITMAX |
||
) |
Calculate the separation and true anomaly for an orbit at the specified mean anomaly.
realT | is the type used for arithmetic |
[out] | r | is the orbital separation |
[out] | f | is the true anomaly |
[out] | E | is the eccentric anomaly, provided since it is free |
[out] | D | is the error after the last iteration of the Kepler solution. |
[in] | e | is the eccentricity |
[in] | M | is the mean anomaly |
[in] | a | is the semi-major axis |
[in] | tol | is the desired tolerance |
[in] | itmax | is the maximum number of iterations |
Definition at line 81 of file orbitUtils.hpp.
References mx::astro::solve_kepler().
Referenced by mx::astro::orbitCartesianWork().
realT mx::astro::orbitLambertPhase | ( | realT | cos_alf | ) |
Get the lambertian phase function at orbital phase specified as cos(alfa), where alfa is the phase angle.
Uses cos(alfa) to save an operation after calculating orbit phase.
realT | is the type used for arithmetic |
[in] | cos_alf | the cosine of the phase angle |
Definition at line 158 of file orbitUtils.hpp.
realT mx::astro::orbitMeanAnol | ( | realT | t, |
realT | t0, | ||
realT | P | ||
) |
Calculate the mean anomaly at time t, given the time of pericenter passage t0 and period P.
Definition at line 63 of file orbitUtils.hpp.
Referenced by mx::astro::orbitCartesianWork().
units::realT mx::astro::orbitPeriod | ( | typename units::realT | m1, |
typename units::realT | m2, | ||
typename units::realT | a | ||
) |
Calculate the period of an orbit, given the masses and semi-major axis.
units | specifies the unit system and precision, see Unit Conversions. |
[in] | m1 | mass of one object. |
[in] | m2 | mass of the other object (can be 0). |
[in] | a | the semi-major axis of the orbit. |
Definition at line 28 of file orbitUtils.hpp.
realT mx::astro::orbitPhaseCosine | ( | realT | f, |
realT | w, | ||
realT | inc | ||
) |
Get the orbital phase at true anomaly f. Calculates the cos(alfa) where alfa is the orbital phase.
Only calculates cos(alfa) to save an operation when possible.
realT | is the type used for arithmetic |
[in] | f | is the true anomoaly at which to calculate alfa |
[in] | w | the argument of pericenter of the orbit |
[in] | inc | is the inclinatin of the orbit |
Definition at line 140 of file orbitUtils.hpp.
units::realT mx::astro::orbitRV | ( | typename units::realT | m1, |
typename units::realT | m2, | ||
typename units::realT | inc, | ||
typename units::realT | a, | ||
typename units::realT | e, | ||
typename units::realT | w, | ||
typename units::realT | f | ||
) |
Calculate the radial velocity of an orbiting body inclined relative to an observer.
[in] | m1 | the mass of the body for which the RV is computed |
[in] | m2 | the mass of the other body in the orbiting pair |
[in] | inc | the inclination of the orbit of m2. |
[in] | a | the semi-major axis of the orbit |
[in] | e | the eccentricity of the orbit |
[in] | w | the argument of pericenter |
[in] | f | the true anomaly at which the RV is to be calculated. |
Definition at line 170 of file orbitUtils.hpp.
units::realT mx::astro::orbitSemiMaj | ( | typename units::realT | m1, |
typename units::realT | m2, | ||
typename units::realT | P | ||
) |
Calculate the semi-major axis of an orbit, given the masses and Period, using SI units.
units | specifies the unit system and precision, see Unit Conversions. |
[in] | m1 | mass of one object. |
[in] | m2 | mass of the other object (can be 0). |
[in] | P | the period of the orbit. |
Definition at line 46 of file orbitUtils.hpp.