27#ifndef astroDynamics_hpp
28#define astroDynamics_hpp
34#include "../math/constants.hpp"
35#include "../math/geo.hpp"
50template <
typename realT>
59 hr = ( day - (realT)Dy ) * 24.0;
60 min = ( day - (realT)Dy - ( (realT)hr ) / 24.0 ) * 60. * 24.0;
61 sec = ( day - (realT)Dy - ( (realT)hr ) / 24.0 - ( (realT)min ) / ( 60.0 * 24.0 ) ) * 3600.0 * 24.0;
71template <
typename realT>
82 double utc0, utc1, tai0, tai1, tt0, tt1, ut10, ut11;
85 rv = sofa::iauDtf2d(
"UTC", Yr, Mo, Dy, hr, min,
static_cast<double>( sec ), &utc0, &utc1 );
93 rv = sofa::iauUtctai( utc0, utc1, &tai0, &tai1 );
101 rv = sofa::iauTaitt( tai0, tai1, &tt0, &tt1 );
109 rv = sofa::iauUtcut1( utc0, utc1, -.4, &ut10, &ut11 );
116 GMST = sofa::iauGmst06( ut10, ut11, tt0, tt1 ) / (
math::two_pi<realT>() ) *
static_cast<realT
>( 24 );
129template <
typename realT>
139 hrMinSecFromDay<realT>( Dy, hr, min, sec, day );
140 return getGMST( GMST, Yr, Mo, Dy, hr, min, sec );
149template <
typename realT>
163 rv =
getGMST( GMST, Yr, Mo, Dy, hr, min, sec );
165 LMST = GMST + lon /
static_cast<realT
>( 15 );
167 LMST = fmod( LMST, 24 );
181template <
typename realT>
192 hrMinSecFromDay<realT>( Dy, hr, min, sec, day );
194 return getLMST( LMST, Yr, Mo, Dy, hr, min, sec, lon );
207template <
typename realT>
215 realT ha_rad, dec_rad, lat_rad, az_rad, el_rad;
217 ha_rad = ha *
static_cast<realT
>( 15 ) *
math::pi<realT>() /
static_cast<realT
>( 180 );
221 az_rad = atan2( sin( ha_rad ), cos( ha_rad ) * sin( lat_rad ) - tan( dec_rad ) * cos( lat_rad ) );
223 el_rad = asin( sin( lat_rad ) * sin( dec_rad ) + cos( lat_rad ) * cos( dec_rad ) * cos( ha_rad ) );
225 az = az_rad *
static_cast<realT
>( 180 ) /
math::pi<realT>() +
static_cast<realT
>( 180 );
239template <
typename realT>
247 return atan2( sinHA, cosDec * tanLat - sinDec * cosHA );
258template <
typename realT>
277template <
typename realT>
283 return parAngRad( sin( ha ), cos( ha ), sin( dec ), cos( dec ), tan( lat ) );
297template <
typename realT>
305 static_cast<void>( newflag );
int getGMST(realT &GMST, int Yr, int Mo, int Dy, int hr, int min, realT sec)
Returns Greenwich Mean Sidereal Time for a given UTC time.
int hrMinSecFromDay(int &Dy, int &hr, int &min, realT &sec, realT day)
Breaks down a decimal day into hours, minutes and decimal point seconds.
int getLMST(realT &LMST, int Yr, int Mo, int Dy, int hr, int min, realT sec, realT lon)
Returns Local Mean Sidereal Time for a given UTC time and longitude.
constexpr floatT six_fifths()
Return 6/5 in the specified precision.
realT rtod(realT q)
Convert from radians to degrees.
realT dtor(realT q)
Convert from degrees to radians.
realT parAngDeg(realT sinHA, realT cosHA, realT sinDec, realT cosDec, realT tanLat)
Calculate the Parallactic Angle from the pre-calculated trig functions. Result in degrees.
int calcAzEl(realT &az, realT &el, realT ha, realT dec, realT lat)
Calculates the Azimuth and Elevation for a given Hour-Angle, Declination, and Latitude.
realT parAngRad(realT sinHA, realT cosHA, realT sinDec, realT cosDec, realT tanLat)
Calculate the Parallactic Angle from the pre-calculated trig functions. Result in radians.
Wrapper for the sofa library headers, adding a namespace.