1 /*
2     SPDX-FileCopyrightText: 2001 Jason Harris <jharris@30doradus.org>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ksplanetbase.h"
10 
11 /**
12  * @class KSComet
13  * @short A subclass of KSPlanetBase that implements comets.
14  *
15  * The orbital elements are stored as private member variables, and
16  * it provides methods to compute the ecliptic coordinates for any
17  * time from the orbital elements.
18  *
19  * All elements are in the heliocentric ecliptic J2000 reference frame.
20  *
21  * Check here for full description: https://ssd.jpl.nasa.gov/?sb_elem#legend
22  *
23  * The orbital elements are:
24  * @li JD    Epoch of element values
25  * @li q     perihelion distance (AU)
26  * @li e     eccentricity of orbit
27  * @li i     inclination angle (with respect to J2000.0 ecliptic plane)
28  * @li w     argument of perihelion (w.r.t. J2000.0 ecliptic plane)
29  * @li N     longitude of ascending node (J2000.0 ecliptic)
30  * @li Tp    time of perihelion passage (YYYYMMDD.DDD)
31  * @li M1    comet total magnitude parameter
32  * @li M2    comet nuclear magnitude parameter
33  * @li K1    total magnitude slope parameter
34  * @li K2    nuclear magnitude slope parameter
35  *
36  * @author Jason Harris
37  * @version 1.1
38  */
39 
40 class KSNumbers;
41 class dms;
42 
43 class KSComet : public KSPlanetBase
44 {
45   public:
46     /**
47      * Constructor.
48      * @param s the name of the comet
49      * @param image_file the filename for an image of the comet
50      * @param q the perihelion distance of the comet's orbit (AU)
51      * @param e the eccentricity of the comet's orbit
52      * @param i the inclination angle of the comet's orbit
53      * @param w the argument of the orbit's perihelion
54      * @param N the longitude of the orbit's ascending node
55      * @param Tp The date of the most proximate perihelion passage (YYYYMMDD.DDD)
56      * @param M1 the comet total magnitude parameter
57      * @param M2 the comet nuclear magnitude parameter
58      * @param K1 the comet total magnitude slope parameter
59      * @param K2 the comet nuclear magnitude slope parameter
60      */
61     KSComet(const QString &s, const QString &image_file, double q, double e, dms i, dms w, dms N,
62             double Tp, float M1, float M2, float K1, float K2);
63 
64     KSComet *clone() const override;
65     SkyObject::UID getUID() const override;
66 
67     /** Destructor (empty)*/
68     ~KSComet() override = default;
69 
70     /**
71      * Unused virtual function inherited from KSPlanetBase thus it's simply empty here.
72      */
73     bool loadData() override;
74 
75     /**
76      * @short Returns the Julian Day of Perihelion passage
77      * @return Julian Day of Perihelion Passage
78      */
getPerihelionJD()79     inline long double getPerihelionJD() { return JDp; }
80 
81     /**
82      * @short Returns Perihelion distance
83      * @return Perihelion distance
84      */
getPerihelion()85     inline double getPerihelion() { return q; }
86 
87     /** @return the comet total magnitude parameter */
getTotalMagnitudeParameter()88     inline float getTotalMagnitudeParameter() { return M1; }
89 
90     /** @return the comet nuclear magnitude parameter */
getNuclearMagnitudeParameter()91     inline float getNuclearMagnitudeParameter() { return M2; }
92 
93     /** @return the total magnitude slope parameter */
getTotalSlopeParameter()94     inline float getTotalSlopeParameter() { return K1; }
95 
96     /** @return the nuclear magnitude slope parameter */
getNuclearSlopeParameter()97     inline float getNuclearSlopeParameter() { return K2; }
98 
99     /** @short Sets the comet's tail length in km */
setTailSize(double tailsize)100     void setTailSize(double tailsize) { TailSize = tailsize; }
101 
102     /** @return the estimated tail length in km */
getTailSize()103     inline float getTailSize() { return TailSize; }
104 
105     /** @short Sets the comet's apparent tail length in degrees */
setComaAngSize(double comaAngSize)106     void setComaAngSize(double comaAngSize) { ComaAngSize = comaAngSize; }
107 
108     /** @return the estimated angular size of the tail as a dms */
getComaAngSize()109     inline dms getComaAngSize() { return dms(ComaAngSize); }
110 
111     /** @return the estimated diameter of the nucleus in km */
getNuclearSize()112     inline float getNuclearSize() { return NuclearSize; }
113 
114     /** @short Sets the comet's earth minimum orbit intersection distance */
115     void setEarthMOID(double earth_moid);
116 
117     /** @return the comet's earth minimum orbit intersection distance in km */
getEarthMOID()118     inline double getEarthMOID() { return EarthMOID; }
119 
120     /** @short Sets the comet's orbit solution ID */
121     void setOrbitID(QString orbit_id);
122 
123     /** @return the comet's orbit solution ID */
getOrbitID()124     inline QString getOrbitID() { return OrbitID; }
125 
126     /** @short Sets the comet's orbit class */
127     void setOrbitClass(QString orbit_class);
128 
129     /** @return the comet's orbit class */
getOrbitClass()130     inline QString getOrbitClass() { return OrbitClass; }
131 
132     /** @short Sets if the comet is a near earth object */
133     void setNEO(bool neo);
134 
135     /** @return true if the comet is a near earth object */
isNEO()136     inline bool isNEO() { return NEO; }
137 
138     /** @short Sets the comet's albedo */
139     void setAlbedo(float albedo);
140 
141     /** @return the comet's albedo */
getAlbedo()142     inline float getAlbedo() { return Albedo; }
143 
144     /** @short Sets the comet's diameter */
145     void setDiameter(float diam);
146 
147     /** @return the comet's diameter */
getDiameter()148     inline float getDiameter() { return Diameter; }
149 
150     /** @short Sets the comet's dimensions */
151     void setDimensions(QString dim);
152 
153     /** @return the comet's dimensions */
getDimensions()154     inline QString getDimensions() { return Dimensions; }
155 
156     /** @short Sets the comet's rotation period */
157     void setRotationPeriod(float rot_per);
158 
159     /** @return the comet's rotation period */
getRotationPeriod()160     inline float getRotationPeriod() { return RotationPeriod; }
161 
162     /** @short Sets the comet's period */
163     void setPeriod(float per);
164 
165     /** @return the comet's period */
getPeriod()166     inline float getPeriod() { return Period; }
167 
168   protected:
169     /**
170      * Calculate the geocentric RA, Dec coordinates of the Comet.
171      * @note reimplemented from KSPlanetBase
172      * @param num time-dependent values for the desired date
173      * @param Earth planet Earth (needed to calculate geocentric coords)
174      * @return true if position was successfully calculated.
175      */
176     bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth = nullptr) override;
177 
178     /**
179      * @short Estimate physical parameters of the comet such as coma size, tail length and size of the nucleus
180      * @note invoked from findGeocentricPosition in order
181      */
182     void findPhysicalParameters();
183 
184   private:
185     void findMagnitude(const KSNumbers *) override;
186 
187     long double JDp { 0 };
188     double q { 0 };
189     double e { 0 };
190     double a { 0 };
191     double P { 0 };
192     double EarthMOID { 0 };
193     double TailSize { 0 };
194     double ComaAngSize { 0 };
195     double ComaSize { 0 };
196     double NuclearSize { 0 };
197     float M1 { 0 };
198     float M2 { 0 };
199     float K1 { 0 };
200     float K2 { 0 };
201     float Albedo { 0 };
202     float Diameter { 0 };
203     float RotationPeriod { 0 };
204     float Period { 0 };
205     dms i, w, N;
206     QString OrbitID, OrbitClass, Dimensions;
207     bool NEO { false };
208     /// Part of UID
209     qint64 uidPart { 0 };
210 };
211