File indexing completed on 2024-04-14 03:43:11

0001 /*
0002     SPDX-FileCopyrightText: 2001 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kspluto.h"
0008 
0009 #include <typeinfo>
0010 
0011 #include <cmath>
0012 
0013 #include <QFile>
0014 
0015 #include <QDebug>
0016 
0017 #include "ksnumbers.h"
0018 #include "kstarsdatetime.h" //for J2000 define
0019 
0020 #ifdef B0
0021 // There are systems that #define B0 as a special termios flag (for baud rate)
0022 #undef B0
0023 #endif
0024 
0025 KSPluto::KSPluto(const QString &fn, double pSize)
0026     : KSAsteroid(0, xi18n("Pluto"), fn, J2000, 39.48168677, 0.24880766, dms(17.14175), dms(113.76329), dms(110.30347),
0027                  dms(14.86205), 1.0, 0.0)
0028 {
0029     //Initialize the base orbital element values for J2000:
0030     a0 = 39.48168677;   //semi-major axis (AU)
0031     e0 = 0.24880766;    //eccentricity
0032     i0.setD(17.14175);  //inclination (degrees)
0033     w0.setD(113.76329); //argument of perihelion (degrees)
0034     N0.setD(110.30347); //long. of ascending node (degrees)
0035     M0.setD(14.86205);  //mean anomaly (degrees)
0036 
0037     //rate-of-change values for the orbital elements
0038     a1 = -0.00076912;       // da/dt (AU/century)
0039     e1 = 0.00006465;        // de/dt (1/century)
0040     i1 = 11.07 / 3600.;     // di/dt (degrees/century)
0041     w1 = -94.92 / 3600.;    // dw/dt (degrees/century)
0042     N1 = -37.33 / 3600.;    // dN/dt (degrees/century)
0043     M1 = 522880.15 / 3600.; // dM/dt (degrees/century)
0044 
0045     setPhysicalSize(pSize);
0046 }
0047 
0048 KSPluto *KSPluto::clone() const
0049 {
0050     Q_ASSERT(typeid(this) == typeid(static_cast<const KSPluto *>(this))); // Ensure we are not slicing a derived class
0051     return new KSPluto(*this);
0052 }
0053 
0054 KSPluto::~KSPluto()
0055 {
0056 }
0057 
0058 //Determine values for the orbital elements for the requested JD, then
0059 //call KSAsteroid::findGeocentricPosition()
0060 bool KSPluto::findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth)
0061 {
0062     //First, set the orbital element values according to the current epoch
0063     double t = num->julianCenturies();
0064     set_a(a0 + a1 * t);
0065     set_e(e0 + e1 * t);
0066     set_i(i0.Degrees() + i1 * t);
0067     set_N(N0.Degrees() + N1 * t);
0068     set_M(M0.Degrees() + M1 * t);
0069     set_P(365.2568984 * pow((a0 + a1 * t), 1.5)); //set period from Kepler's 3rd law
0070     setJD(num->julianDay());
0071 
0072     return KSAsteroid::findGeocentricPosition(num, Earth);
0073 }
0074 
0075 void KSPluto::findMagnitude(const KSNumbers *)
0076 {
0077     setMag(-1.01 + 5 * log10(rsun() * rearth()) + 0.041 * phase().Degrees());
0078 }