File indexing completed on 2024-04-28 11:25:42
0001 /* 0002 SPDX-FileCopyrightText: 2002-2005 Jason Harris <kstars@30doradus.org> 0003 SPDX-FileCopyrightText: 2004-2005 Pablo de Vicente <p.devicente@wanadoo.es> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "cachingdms.h" 0011 0012 #if __GNUC__ > 5 0013 #pragma GCC diagnostic push 0014 #pragma GCC diagnostic ignored "-Wignored-attributes" 0015 #endif 0016 #if __GNUC__ > 6 0017 #pragma GCC diagnostic ignored "-Wint-in-bool-context" 0018 #endif 0019 #include <Eigen/Core> 0020 #if __GNUC__ > 5 0021 #pragma GCC diagnostic pop 0022 #endif 0023 0024 #define NUTTERMS 63 0025 0026 /** @class KSNumbers 0027 * 0028 *There are several time-dependent values used in position calculations, 0029 *that are not specific to an object. This class provides 0030 *storage for these values, and methods for calculating them for a given date. 0031 *The numbers include solar data like the true/mean solar anomalies 0032 *and longitudes, the longitude of the Earth's perihelion, the 0033 *eccentricity of Earth's orbit, the 0034 *constant of aberration, the obliquity of the Ecliptic, the effects of 0035 *Nutation (delta Obliquity and delta Ecliptic longitude), 0036 *the Julian Day/Century/Millenium, and arrays for computing the precession. 0037 *@short Store several time-dependent astronomical quantities. 0038 *@author Jason Harris 0039 *@version 1.0 0040 */ 0041 0042 class KSNumbers 0043 { 0044 public: 0045 /** 0046 * Constructor. 0047 * @param jd Julian Day for which the new instance is initialized 0048 */ 0049 explicit KSNumbers(long double jd); 0050 ~KSNumbers() = default; 0051 0052 /** 0053 * @return the current Obliquity (the angle of inclination between 0054 * the celestial equator and the ecliptic) 0055 */ 0056 inline const CachingDms *obliquity() const { return &Obliquity; } 0057 0058 /** @return the constant of aberration (20.49 arcsec). */ 0059 inline dms constAberr() const { return K; } 0060 0061 /** @return the mean solar anomaly. */ 0062 inline dms sunMeanAnomaly() const { return M; } 0063 0064 /** @return the mean solar longitude. */ 0065 inline dms sunMeanLongitude() const { return L; } 0066 0067 /** @return the true solar anomaly. */ 0068 inline dms sunTrueAnomaly() const { return M0; } 0069 0070 /** @return the true solar longitude. */ 0071 inline CachingDms sunTrueLongitude() const { return L0; } 0072 0073 /** @return the longitude of the Earth's perihelion point. */ 0074 inline CachingDms earthPerihelionLongitude() const { return P; } 0075 0076 /** @return eccentricity of Earth's orbit.*/ 0077 inline double earthEccentricity() const { return e; } 0078 0079 /** @return the change in obliquity due to the nutation of 0080 * Earth's orbit. Value is in degrees */ 0081 inline double dObliq() const { return deltaObliquity; } 0082 0083 /** @return the change in Ecliptic Longitude due to nutation. 0084 * Value is in degrees. */ 0085 inline double dEcLong() const { return deltaEcLong; } 0086 0087 /** @return Julian centuries since J2000*/ 0088 inline double julianCenturies() const { return T; } 0089 0090 /** @return Julian Day*/ 0091 inline long double julianDay() const { return days; } 0092 0093 /** @return Julian Millenia since J2000*/ 0094 inline double julianMillenia() const { return jm; } 0095 0096 /** @return element of P1 precession array at position (i1, i2) */ 0097 inline double p1(int i1, int i2) const { return P1(i1, i2); } 0098 0099 /** @return element of P2 precession array at position (i1, i2) */ 0100 inline double p2(int i1, int i2) const { return P2(i1, i2); } 0101 0102 /** @return element of P1B precession array at position (i1, i2) */ 0103 inline double p1b(int i1, int i2) const { return P1B(i1, i2); } 0104 0105 /** @return element of P2B precession array at position (i1, i2) */ 0106 inline double p2b(int i1, int i2) const { return P2B(i1, i2); } 0107 0108 /** @return the precession matrix directly **/ 0109 inline const Eigen::Matrix3d &p2() const { return P1; } 0110 inline const Eigen::Matrix3d &p1() const { return P2; } 0111 inline const Eigen::Matrix3d &p1b() const { return P1B; } 0112 inline const Eigen::Matrix3d &p2b() const { return P2B; } 0113 0114 /** 0115 * @short compute constant values that need to be computed only once per instance of the application 0116 */ 0117 void computeConstantValues(); 0118 0119 /** 0120 * @short update all values for the date given as an argument. 0121 * @param jd the Julian date for which to compute values 0122 */ 0123 void updateValues(long double jd); 0124 0125 /** 0126 * @return the JD for which these values hold (i.e. the last updated JD) 0127 */ 0128 inline long double getJD() const { return days; } 0129 0130 inline double vEarth(int i) const { return vearth[i]; } 0131 0132 private: 0133 CachingDms Obliquity, L0, P; 0134 dms K, L, LM, M, M0, O, D, MM, F; 0135 dms XP, YP, ZP, XB, YB, ZB; 0136 double CX, SX, CY, SY, CZ, SZ; 0137 double CXB, SXB, CYB, SYB, CZB, SZB; 0138 Eigen::Matrix3d P1, P2, P1B, P2B; 0139 double deltaObliquity, deltaEcLong; 0140 double e, T; 0141 long double days; // JD for which the last update was called 0142 double jm; 0143 static const int arguments[NUTTERMS][5]; 0144 static const int amp[NUTTERMS][4]; 0145 double vearth[3]; 0146 };