Functions for basic geometry and working with earth coordinate systems
|
template<typename realT > |
realT | mx::math::dtor (realT q) |
| Convert from degrees to radians. More...
|
|
template<typename realT > |
realT | mx::math::rtod (realT q) |
| Convert from radians to degrees. More...
|
|
template<class angleT > |
angleT::realT | mx::math::angleMod (typename angleT::realT q) |
| Calculate the angle modulo full-circle, normalizing to a positive value. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
template<typename realT > |
void | mx::math::rotatePoint (realT &x0, realT &y0, realT angle) |
| Rotate a point about the origin. More...
|
|
◆ angleDiff()
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.
Calculates \( dq = q2- q1 \), but accounts for crossing 0/360. This implies that \( dq \le 180 \).
- Returns
- the difference of q2 and q1
- Template Parameters
-
degrad | controls whether this is in degrees (0, default) or radians (1) |
realT | is the type in which to do arithmetic |
- Test:
- Verify compilation and calculations of math::angleDiff [test doc]
- Parameters
-
[in] | q1 | angle to subtract from q2, in degrees. |
[in] | q2 | angle to subtract q1 from, in degrees. |
Definition at line 191 of file geo.hpp.
◆ angleMean()
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.
Calculates the mean by decomposing into vectors and averaging the components. This accounts for crossing 0/360.
- Returns
- the mean angle
- Template Parameters
-
angleT | is the angle type, either radians<realT> or degrees<realT>. angleT::realT is the type in which to do arithmetic. |
- Parameters
-
[in] | q | vector of angles to average. |
Definition at line 227 of file geo.hpp.
◆ angleMod()
template<class angleT >
angleT::realT mx::math::angleMod |
( |
typename angleT::realT |
q | ) |
|
Calculate the angle modulo full-circle, normalizing to a positive value.
The output will be betweeen 0 and 360 (or 0 and 2pi).
- Returns
- the value of q normalized to 0 <= q < 360[2pi]
- Template Parameters
-
degrad | controls whether this is in degrees (0, default) or radians (1) |
realT | is the type in which to do arithmetic |
- Parameters
-
Definition at line 163 of file geo.hpp.
◆ continueAngles()
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.
The vector is modified so it is continuous.
- Template Parameters
-
degrad | controls whether angles are degrees (false) or radians (true) |
realT | is the type in which to do arithmetic |
- Parameters
-
[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 257 of file geo.hpp.
◆ dtor()
template<typename realT >
realT mx::math::dtor |
( |
realT |
q | ) |
|
◆ rotatePoint()
template<typename realT >
void mx::math::rotatePoint |
( |
realT & |
x0, |
|
|
realT & |
y0, |
|
|
realT |
angle |
|
) |
| |
Rotate a point about the origin.
The rotation is counter-clockwise for positive angles.
- Template Parameters
-
realT | a real floating point type |
- Parameters
-
| 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 304 of file geo.hpp.
◆ rtod()
template<typename realT >
realT mx::math::rtod |
( |
realT |
q | ) |
|