mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
geo.hpp File Reference

Utilities for working with angles. More...

Utilities for working with angles.

Author
Jared R. Males

Definition in file geo.hpp.

#include <vector>
#include <cmath>
#include "constants.hpp"

Go to the source code of this file.

Classes

struct  mx::math::degradT< degrees, _realT >
 Type holding constants related to angle calculations in degrees. More...
 
struct  mx::math::degradT< radians, _realT >
 Type holding constants related to angle calculations in radians. More...
 

Namespaces

namespace  mx
 The mxlib c++ namespace.
 

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.