1/***************************************************************************
2 ksnumbers.h - description
3 -------------------
4 begin : Sun Jan 13 2002
5 copyright : (C) 2002-2005 by Jason Harris
6 email : kstars@30doradus.org
7 copyright : (C) 2004-2005 by Pablo de Vicente
8 email : p.devicente@wanadoo.es
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#ifndef KSNUMBERS_H_
21#define KSNUMBERS_H_
22
23#define NUTTERMS 63
24
25#include "dms.h"
26
27/**@class KSNumbers
28 *
29 *There are several time-dependent values used in position calculations,
30 *that are not specific to an object. This class provides
31 *storage for these values, and methods for calculating them for a given date.
32 *The numbers include solar data like the true/mean solar anomalies
33 *and longitudes, the longitude of the Earth's perihelion, the
34 *eccentricity of Earth's orbit, the
35 *constant of aberration, the obliquity of the Ecliptic, the effects of
36 *Nutation (delta Obliquity and delta Ecliptic longitude),
37 *the Julian Day/Century/Millenium, and arrays for computing the precession.
38 *@short Store several time-dependent astronomical quantities.
39 *@author Jason Harris
40 *@version 1.0
41 */
42
43class KSNumbers {
44public:
45
46 /**
47 * Constructor.
48 *@param jd Julian Day for which the new instance is initialized
49 */
50 explicit KSNumbers( long double jd );
51
52 /**Destructor (empty). */
53 ~KSNumbers();
54
55 /**@return the current Obliquity (the angle of inclination between
56 *the celestial equator and the ecliptic)
57 */
58 const dms* obliquity() const { return &Obliquity; }
59
60 /**@return the constant of aberration (20.49 arcsec). */
61 dms constAberr() const { return K; }
62
63 /**@return the mean solar anomaly. */
64 dms sunMeanAnomaly() const { return M; }
65
66 /**@return the mean solar longitude. */
67 dms sunMeanLongitude() const { return L; }
68
69 /**@return the true solar anomaly. */
70 dms sunTrueAnomaly() const { return M0; }
71
72 /**@return the true solar longitude. */
73 dms sunTrueLongitude() const { return L0; }
74
75 /**@return the longitude of the Earth's perihelion point. */
76 dms earthPerihelionLongitude() const { return P; }
77
78 /**@return eccentricity of Earth's orbit.*/
79 double earthEccentricity() const { return e; }
80
81 /**@return the change in obliquity due to the nutation of
82 * Earth's orbit. Value is in degrees */
83 double dObliq() const { return deltaObliquity; }
84
85 /**@return the change in Ecliptic Longitude due to nutation.
86 * Value is in degrees. */
87 double dEcLong() const { return deltaEcLong; }
88
89 /**@return Julian centuries since J2000*/
90 double julianCenturies() const { return T; }
91
92 /**@return Julian Day*/
93 long double julianDay() const { return days; }
94
95 /**@return Julian Millenia since J2000*/
96 double julianMillenia() const { return jm; }
97
98 /**@return element of P1 precession array at position [i1][i2] */
99 double p1( int i1, int i2 ) const { return P1[i1][i2]; }
100
101 /**@return element of P2 precession array at position [i1][i2] */
102 double p2( int i1, int i2 ) const { return P2[i1][i2]; }
103
104 /**@return element of P1B precession array at position [i1][i2] */
105 double p1b( int i1, int i2 ) const { return P1B[i1][i2]; }
106
107 /**@return element of P2B precession array at position [i1][i2] */
108 double p2b( int i1, int i2 ) const { return P2B[i1][i2]; }
109
110 /**
111 *@short compute constant values that need to be computed only once per instance of the application
112 */
113 void computeConstantValues();
114
115 /**@short update all values for the date given as an argument.
116 *@param jd the Julian date for which to compute values
117 */
118 void updateValues( long double jd );
119
120 /**
121 *@return the JD for which these values hold (i.e. the last updated JD)
122 */
123 inline long double getJD() const { return days; }
124
125 double vEarth(int i) const {return vearth[i];}
126
127private:
128 dms Obliquity, K, L, L0, LM, M, M0, O, P, D, MM, F;
129 dms XP, YP, ZP, XB, YB, ZB;
130 double CX, SX, CY, SY, CZ, SZ;
131 double CXB, SXB, CYB, SYB, CZB, SZB;
132 double P1[3][3], P2[3][3], P1B[3][3], P2B[3][3];
133 double deltaObliquity, deltaEcLong;
134 double e, T;
135 long double days; // JD for which the last update was called
136 double jm;
137 static const int arguments[NUTTERMS][5];
138 static const int amp[NUTTERMS][4];
139 double vearth[3];
140};
141
142#endif
143