|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Functions for basic geometry and working with earth coordinate systems
Macros | |
| #define | semilatrect(a, e) ( e == 0.0 ? a : ( e == 1.0 ? 2. * a : ( e < 1. ? a * ( 1 - e * e ) : a * ( e * e - 1 ) ) ) ) |
| Calculate the semi-latus rectum of a conic section | |
| #define | focus(a, e) ( e == 0.0 ? 1e34 : ( e == 1.0 ? 2. * a : ( e < 1. ? a * ( 1 - e * e ) / e : a * ( e * e - 1 ) / e ) ) ) |
| Calculate the focal parameter of a conic section | |
| #define | semimaj(p, e) ( e == 1.0 ? 1e34 : ( e < 1 ? p * e / ( 1 - e * e ) : p * e / ( e * e - 1 ) ) ) |
| #define | eccent(a, p) |
Functions | |
| template<typename realT > | |
| realT | mx::math::dtor (realT q) |
| Convert from degrees to radians. | |
| template<typename realT > | |
| realT | mx::math::rtod (realT q) |
| Convert from radians to degrees. | |
| template<class angleT > | |
| angleT::realT | mx::math::angleMod (typename angleT::realT q) |
| Calculate the angle modulo full-circle, normalizing to a positive value. | |
| template<class angleT > | |
| angleT::realT | mx::math::angleDiff (typename angleT::realT q1, typename angleT::realT q2) |
| Calculate the difference between two angles, correctly across 0/360. | |
| template<class angleT > | |
| angleT::realT | mx::math::angleMean (const std::vector< typename angleT::realT > &q) |
| Calculate the mean of a set of angles, correctly across 0/360. | |
| template<int degrad = 0, typename realT > | |
| int | mx::math::continueAngles (std::vector< realT > &angles, realT threshold=0.75) |
| Make a vector of angles continuous, fixing the 0/360 crossing. | |
| template<typename realT > | |
| void | mx::math::rotatePoint (realT &x0, realT &y0, realT angle) |
| Rotate a point about the origin. | |
| #define eccent | ( | a, | |
| p | |||
| ) |
Calculate the eccentricity of a conic section given the semi-major axis and the focal parameter
| #define focus | ( | a, | |
| e | |||
| ) | ( e == 0.0 ? 1e34 : ( e == 1.0 ? 2. * a : ( e < 1. ? a * ( 1 - e * e ) / e : a * ( e * e - 1 ) / e ) ) ) |
Calculate the focal parameter of a conic section
| #define semilatrect | ( | a, | |
| e | |||
| ) | ( e == 0.0 ? a : ( e == 1.0 ? 2. * a : ( e < 1. ? a * ( 1 - e * e ) : a * ( e * e - 1 ) ) ) ) |
Calculate the semi-latus rectum of a conic section
| #define semimaj | ( | p, | |
| e | |||
| ) | ( e == 1.0 ? 1e34 : ( e < 1 ? p * e / ( 1 - e * e ) : p * e / ( e * e - 1 ) ) ) |
Calculate the semi-major axis of a conic section, given the focal parameter and the eccentricity
| angleT::realT mx::math::angleDiff | ( | typename angleT::realT | q1, |
| typename angleT::realT | q2 | ||
| ) |
Calculate the difference between two angles, correctly across 0/360.
Calculates \( dq = q2- q1 \), but accounts for crossing 0/360. This implies that \( dq \le 180 \).
| angleT | controls whether this is in degrees (0, default) or radians (1) |
| realT | is the type in which to do arithmetic |
| [in] | q1 | angle to subtract from q2. |
| [in] | q2 | angle to subtract q1 from. |
Definition at line 197 of file geo.hpp.
References mx::math::six_fifths().
| angleT::realT mx::math::angleMean | ( | const std::vector< typename angleT::realT > & | q | ) |
Calculate the mean of a set of angles, correctly across 0/360.
Calculates the mean by decomposing into vectors and averaging the components. This accounts for crossing 0/360.
| angleT | is the angle type, either radians<realT> or degrees<realT>. angleT::realT is the type in which to do arithmetic. |
| [in] | q | vector of angles to average. |
Definition at line 232 of file geo.hpp.
References mx::math::six_fifths().
Calculate the angle modulo full-circle, normalizing to a positive value.
The output will be betweeen 0 and 360 (or 0 and 2pi).
| degrad | controls whether this is in degrees (0, default) or radians (1) |
| realT | is the type in which to do arithmetic |
| [in] | q | the angle |
Definition at line 169 of file geo.hpp.
References mx::math::six_fifths().
| int mx::math::continueAngles | ( | std::vector< realT > & | angles, |
| realT | threshold = 0.75 |
||
| ) |
Make a vector of angles continuous, fixing the 0/360 crossing.
The vector is modified so it is continuous.
| degrad | controls whether angles are degrees (false) or radians (true) |
| realT | is the type in which to do arithmetic |
| [in] | angles | the vector of angles |
| [in] | threshold | [optional] the fraction of a full circle at which to consider a difference in angle discontinuous. |
Definition at line 261 of file geo.hpp.
References mx::math::six_fifths().
| realT mx::math::dtor | ( | realT | q | ) |
Convert from degrees to radians.
| q | is the angle to convert |
Definition at line 138 of file geo.hpp.
References mx::math::six_fifths().
Referenced by mx::improc::azBoxKernel< _arrayT, _kernW >::azBoxKernel(), mx::sigproc::makeModifiedFourierMode(), mx::astro::parAngDeg(), and SCENARIO().
Rotate a point about the origin.
The rotation is counter-clockwise for positive angles.
| realT | a real floating point type |
| x0 | [in.out] the x-coordinate of the point to rotate. On exit contains the rotated value. | |
| y0 | [in.out] the y-coordinate of the point to rotate. On exit contains the rotated value. | |
| [in] | angle | the angle by which to rotate [radians] |
Definition at line 316 of file geo.hpp.
References mx::math::six_fifths().
| realT mx::math::rtod | ( | realT | q | ) |
Convert from radians to degrees.
| q | is the angle to convert |
Definition at line 153 of file geo.hpp.
References mx::math::six_fifths().
Referenced by mx::improc::imCenterRadon< transformT >::center(), mx::improc::maskWedge(), mx::astro::parAngDeg(), and mx::astro::parAngDeg().