Sun position
Sun position algorithm
astron.h
Go to the documentation of this file.
1 #ifndef ASTRON_H
2 #define ASTRON_H
3 /*============================================================================*/
4 /*!\file
5  * \brief astron.h - assorted definitions useful for astronomy
6  *
7  * \author David Hoadley
8  *
9  * \details
10  * Some astronomical constants, and angle conversions that are used in
11  * astronomical software.
12  *
13  *==============================================================================
14  */
15 #include "general.h" /* For PI, degToRad(), radToDeg() etc., C standard*/
16 #include "vectors3d.h"
17 
18 
19 /*
20  * Global #defines and typedefs
21  */
22 /* Useful astronomical constants */
23 #define MJD_B1900 15019.81352 /*!< MJD of Besselian std epoch B1900.0 */
24 #define MJD_B1950 33281.92346 /*!< MJD of Besselian std epoch B1950.0 */
25 #define MJD_J2000 51544.5 /*!< MJD of Fundamental Epoch J2000.0 */
26 #define TROP_CENT 36524.2198781 /*!< Length of Tropical Century in days */
27 #define JUL_CENT 36525.0 /*!< Length of Julian Century in days */
28 
29 #define ARCSEC2RAD (PI / 648000.0) /*!< arcseconds to radians */
30 #define RAD2ARCSEC (648000.0 / PI) /*!< radians to arcseconds */
31 #define SEC2RAD (PI / 43200.0) /*!< seconds(time) to radians */
32 #define RAD2SEC (43200.0 / PI) /*!< radians to seconds(time) */
33 #define HRS2RAD (PI / 12.0) /*!< hours to radians */
34 #define RAD2HRS (12.0 / PI) /*!< radians to hours */
35 
36 /*
37  * Functions
38  */
39 /* Convert angle from one unit to another */
40 #ifdef PREDEF_STANDARD_C_1999
41 /* Compiler supports inline functions */
42 /*! Returns \a angle_as converted from arcseconds to radians */
43 static inline double arcsecToRad(double angle_as) {
44  return angle_as * ARCSEC2RAD; }
45 /*! Returns \a angle_rad converted from radians to arcseconds */
46 static inline double radToArcsec(double angle_rad) {
47  return angle_rad * RAD2ARCSEC; }
48 
49 /*! Returns \a angle_s converted from seconds to radians */
50 static inline double secToRad(double angle_s) { return angle_s * SEC2RAD; }
51 /*! Returns \a angle_rad converted from radians to seconds */
52 static inline double radToSec(double angle_rad) { return angle_rad * RAD2SEC; }
53 
54 /*! Returns \a angle_h converted from hours to radians */
55 static inline double hrsToRad(double angle_h) { return angle_h * HRS2RAD; }
56 /*! Returns \a angle_rad converted from radians to hours */
57 static inline double radToHrs(double angle_rad) { return angle_rad * RAD2HRS; }
58 
59 #else
60 /* C89/C90 compiler only - no inline functions. Need macros instead */
61 #define arcsecToRad(angle_arcsec__) ((angle_arcsec__) * ARCSEC2RAD)
62 #define radToArcsec(angle_rad__) ((angle_rad__) * RAD2ARCSEC)
63 
64 #define secToRad(angle_s__) ((angle_s__) * SEC2RAD)
65 #define radToSec(angle_rad__) ((angle_rad__) * RAD2SEC)
66 
67 #define hrsToRad(angle_h__) ((angle_h__) * HRS2RAD)
68 #define radToHrs(angle_rad__) ((angle_rad__) * RAD2HRS)
69 
70 #endif
71 
72 
73 #endif /*ASTRON_H*/
74 
HRS2RAD
#define HRS2RAD
hours to radians
Definition: astron.h:33
general.h
general.h - definitions of general use to (standard) C programs
SEC2RAD
#define SEC2RAD
seconds(time) to radians
Definition: astron.h:31
RAD2SEC
#define RAD2SEC
radians to seconds(time)
Definition: astron.h:32
radToHrs
static double radToHrs(double angle_rad)
Returns angle_rad converted from radians to hours.
Definition: astron.h:57
RAD2ARCSEC
#define RAD2ARCSEC
radians to arcseconds
Definition: astron.h:30
ARCSEC2RAD
#define ARCSEC2RAD
arcseconds to radians
Definition: astron.h:29
secToRad
static double secToRad(double angle_s)
Returns angle_s converted from seconds to radians.
Definition: astron.h:50
radToArcsec
static double radToArcsec(double angle_rad)
Returns angle_rad converted from radians to arcseconds.
Definition: astron.h:46
arcsecToRad
static double arcsecToRad(double angle_as)
Returns angle_as converted from arcseconds to radians.
Definition: astron.h:43
radToSec
static double radToSec(double angle_rad)
Returns angle_rad converted from radians to seconds.
Definition: astron.h:52
vectors3d.h
vectors3d.h - Three dimensional geometry, vectors and matrices
RAD2HRS
#define RAD2HRS
radians to hours
Definition: astron.h:34
hrsToRad
static double hrsToRad(double angle_h)
Returns angle_h converted from hours to radians.
Definition: astron.h:55