File indexing completed on 2024-04-21 03:44:40
0001 /* 0002 SPDX-FileCopyrightText: 2001 Jason Harris <jharris@30doradus.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "ksplanetbase.h" 0010 0011 #include <QDataStream> 0012 0013 class dms; 0014 class KSNumbers; 0015 0016 /** @class KSAsteroid 0017 *@short A subclass of KSPlanetBase that implements asteroids. 0018 * 0019 * All elements are in the heliocentric ecliptic J2000 reference frame. 0020 * 0021 * Check here for full description: https://ssd.jpl.nasa.gov/?sb_elem#legend 0022 * 0023 *The orbital elements are stored as private member variables, and it 0024 *provides methods to compute the ecliptic coordinates for any time 0025 *from the orbital elements. 0026 * 0027 *The orbital elements are: 0028 *@li JD Epoch of element values 0029 *@li a semi-major axis length (AU) 0030 *@li e eccentricity of orbit 0031 *@li i inclination angle (with respect to J2000.0 ecliptic plane) 0032 *@li w argument of perihelion (w.r.t. J2000.0 ecliptic plane) 0033 *@li N longitude of ascending node (J2000.0 ecliptic) 0034 *@li M mean anomaly at epoch JD 0035 *@li H absolute magnitude 0036 *@li G slope parameter 0037 * 0038 *@author Jason Harris 0039 *@version 1.0 0040 */ 0041 class KSAsteroid : public KSPlanetBase 0042 { 0043 public: 0044 /** Constructor. 0045 *@p catN number of asteroid 0046 *@p s the name of the asteroid 0047 *@p image_file the filename for an image of the asteroid 0048 *@p JD the Julian Day for the orbital elements 0049 *@p a the semi-major axis of the asteroid's orbit (AU) 0050 *@p e the eccentricity of the asteroid's orbit 0051 *@p i the inclination angle of the asteroid's orbit 0052 *@p w the argument of the orbit's perihelion 0053 *@p N the longitude of the orbit's ascending node 0054 *@p M the mean anomaly for the Julian Day 0055 *@p H absolute magnitude 0056 *@p G slope parameter 0057 */ 0058 KSAsteroid(int catN, const QString &s, const QString &image_file, long double JD, double a, double e, dms i, dms w, 0059 dms N, dms M, double H, double G); 0060 0061 KSAsteroid *clone() const override; 0062 SkyObject::UID getUID() const override; 0063 0064 static const SkyObject::TYPE TYPE = SkyObject::ASTEROID; 0065 0066 /** Destructor (empty)*/ 0067 ~KSAsteroid() override = default; 0068 0069 /** This is inherited from KSPlanetBase. We don't use it in this class, 0070 *so it is empty. 0071 */ 0072 bool loadData() override; 0073 0074 /** This lets other classes like KSPlanetBase access H and G values 0075 *Used by KSPlanetBase::FindMagnitude 0076 */ 0077 double inline getAbsoluteMagnitude() const { return H; } 0078 double inline getSlopeParameter() const { return G; } 0079 0080 /** 0081 *@short Sets the asteroid's perihelion distance 0082 */ 0083 void setPerihelion(double perihelion); 0084 0085 /** 0086 *@return Perihelion distance 0087 */ 0088 inline double getPerihelion() const { return q; } 0089 0090 /** 0091 *@short Sets the asteroid's earth minimum orbit intersection distance 0092 */ 0093 void setEarthMOID(double earth_moid); 0094 0095 /** 0096 *@return the asteroid's earth minimum orbit intersection distance in AU 0097 */ 0098 inline double getEarthMOID() const { return EarthMOID; } 0099 0100 /** 0101 *@short Sets the asteroid's orbit solution ID 0102 */ 0103 void setOrbitID(QString orbit_id); 0104 0105 /** 0106 *@return the asteroid's orbit solution ID 0107 */ 0108 inline QString getOrbitID() const { return OrbitID; } 0109 0110 /** 0111 *@short Sets the asteroid's orbit class 0112 */ 0113 void setOrbitClass(QString orbit_class); 0114 0115 /** 0116 *@return the asteroid's orbit class 0117 */ 0118 inline QString getOrbitClass() const { return OrbitClass; } 0119 0120 /** 0121 *@short Sets if the comet is a near earth object 0122 */ 0123 void setNEO(bool neo); 0124 0125 /** 0126 *@return true if the asteroid is a near earth object 0127 */ 0128 inline bool isNEO() const { return NEO; } 0129 0130 /** 0131 *@short Sets the asteroid's albedo 0132 */ 0133 void setAlbedo(float albedo); 0134 0135 /** 0136 *@return the asteroid's albedo 0137 */ 0138 inline float getAlbedo() const { return Albedo; } 0139 0140 /** 0141 *@short Sets the asteroid's diameter 0142 */ 0143 void setDiameter(float diam); 0144 0145 /** 0146 *@return the asteroid's diameter 0147 */ 0148 inline float getDiameter() const { return Diameter; } 0149 0150 /** 0151 *@short Sets the asteroid's dimensions 0152 */ 0153 void setDimensions(QString dim); 0154 0155 /** 0156 *@return the asteroid's dimensions 0157 */ 0158 inline QString getDimensions() const { return Dimensions; } 0159 0160 /** 0161 *@short Sets the asteroid's rotation period 0162 */ 0163 void setRotationPeriod(float rot_per); 0164 0165 /** 0166 *@return the asteroid's rotation period 0167 */ 0168 inline float getRotationPeriod() const { return RotationPeriod; } 0169 0170 /** 0171 *@short Sets the asteroid's period 0172 */ 0173 void setPeriod(float per); 0174 0175 /** 0176 *@return the asteroid's period 0177 */ 0178 inline float getPeriod() const { return Period; } 0179 0180 // TODO: Add top level implementation 0181 /** 0182 * @brief toDraw 0183 * @return whether to draw the asteroid 0184 * 0185 * Note that you'd check for other, older filtering methids 0186 * upn implementing this on other types! (a.k.a find nearest) 0187 */ 0188 inline bool toDraw() { return toCalculate(); } 0189 0190 /** 0191 * @brief toCalculate 0192 * @return whether to calculate the position 0193 */ 0194 bool toCalculate(); 0195 0196 protected: 0197 /** Calculate the geocentric RA, Dec coordinates of the Asteroid. 0198 *@note reimplemented from KSPlanetBase 0199 *@param num time-dependent values for the desired date 0200 *@param Earth planet Earth (needed to calculate geocentric coords) 0201 *@return true if position was successfully calculated. 0202 */ 0203 bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth = nullptr) override; 0204 0205 //these set functions are needed for the new KSPluto subclass 0206 void set_a(double newa) { a = newa; } 0207 void set_e(double newe) { e = newe; } 0208 void set_P(double newP) { P = newP; } 0209 void set_i(double newi) { i.setD(newi); } 0210 void set_w(double neww) { w.setD(neww); } 0211 void set_M(double newM) { M.setD(newM); } 0212 void set_N(double newN) { N.setD(newN); } 0213 void setJD(long double jd) { JD = jd; } 0214 0215 0216 private: 0217 /** 0218 * Serializers 0219 */ 0220 friend QDataStream &operator<<(QDataStream &out, const KSAsteroid &asteroid); 0221 friend QDataStream &operator>>(QDataStream &in, KSAsteroid *&asteroid); 0222 0223 void findMagnitude(const KSNumbers *) override; 0224 0225 int catN { 0 }; 0226 long double JD { 0 }; 0227 double q { 0 }; 0228 double a { 0 }; 0229 double e { 0 }; 0230 double P { 0 }; 0231 double EarthMOID { 0 }; 0232 float Albedo { 0 }; 0233 float Diameter { 0 }; 0234 float RotationPeriod { 0 }; 0235 float Period { 0 }; 0236 dms i, w, M, N; 0237 double H { 0 }; 0238 double G { 0 }; 0239 QString OrbitID, OrbitClass, Dimensions; 0240 bool NEO { false }; 0241 };