File indexing completed on 2024-04-21 14:46:45

0001 /*
0002     SPDX-FileCopyrightText: 2009 Jerome SONRIER <jsid@emor3j.fr.eu.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "skyobject.h"
0010 
0011 #include <QString>
0012 
0013 class KSPopupMenu;
0014 
0015 /**
0016  * @class Satellite
0017  * Represents an artificial satellites.
0018  *
0019  * @author Jérôme SONRIER
0020  * @version 0.1
0021  */
0022 class Satellite : public SkyObject
0023 {
0024     public:
0025         /** @short Constructor */
0026         Satellite(const QString &name, const QString &line1, const QString &line2);
0027 
0028         /**
0029          * @return a clone of this object
0030          * @note See SkyObject::clone()
0031          */
0032         Satellite *clone() const override;
0033 
0034         /** @short Destructor */
0035         virtual ~Satellite() override = default;
0036 
0037         /** @short Update satellite position */
0038         int updatePos();
0039 
0040         /**
0041          * @return True if the satellite is visible (above horizon, in the sunlight and sun at least 12° under horizon)
0042          */
0043         bool isVisible();
0044 
0045         /** @return True if the satellite is selected */
0046         bool selected();
0047 
0048         /** @short Select or not the satellite */
0049         void setSelected(bool selected);
0050 
0051         /** @return Satellite velocity in km/s */
0052         double velocity() const;
0053 
0054         /** @return Satellite altitude in km */
0055         double altitude() const;
0056 
0057         /** @return Satellite range from observer in km */
0058         double range() const;
0059 
0060         /** @return Satellite international designator */
0061         QString id() const;
0062 
0063         /** @return Satellite TLE */
0064         QString tle() const;
0065 
0066         /**
0067          * @brief sgp4ErrorString Get error string associated with sgp4 calculation failure
0068          * @param code error code as returned from sgp4() function
0069          * @return error string
0070          */
0071         QString sgp4ErrorString(int code);
0072 
0073         void initPopupMenu(KSPopupMenu *pmenu) override;
0074 
0075     private:
0076         /** @short Compute non time dependent parameters */
0077         void init();
0078 
0079         /** @short Compute satellite position */
0080         int sgp4(double tsince);
0081 
0082         /** @return Arcsine of the argument */
0083         double arcSin(double arg);
0084 
0085         /**
0086          * Provides the difference between UT (approximately the same as UTC)
0087          * and ET (now referred to as TDT).
0088          * This function is based on a least squares fit of data from 1950
0089          * to 1991 and will need to be updated periodically.
0090          */
0091         double deltaET(double year);
0092 
0093         /** @return arg1 mod arg2 */
0094         double Modulus(double arg1, double arg2);
0095 
0096         // TLE
0097         /// Satellite Number
0098         int m_number { 0 };
0099         /// Security Classification
0100         QChar m_class;
0101         /// International Designator
0102         QString m_id;
0103         /// Complete TLE
0104         QString m_tle;
0105         /// Epoch Year
0106         double m_epoch_year { 0 };
0107         /// Epoch (Day of the year and fractional portion of the day)
0108         double m_epoch { 0 };
0109         /// First Time Derivative of the Mean Motion
0110         double m_first_deriv { 0 };
0111         /// Second Time Derivative of Mean Motion
0112         double m_second_deriv { 0 };
0113         /// BSTAR drag term (decimal point assumed)
0114         double m_bstar { 0 };
0115         /// Ephemeris type
0116         int m_ephem_type { 0 };
0117         /// Element number
0118         int m_elem_number { 0 };
0119         /// Inclination [Radians]
0120         double m_inclination { 0 };
0121         /// Right Ascension of the Ascending Node [Radians]
0122         double m_ra { 0 };
0123         /// Eccentricity
0124         double m_eccentricity { 0 };
0125         /// Argument of Perigee [Radians]
0126         double m_arg_perigee { 0 };
0127         /// Mean Anomaly [Radians]
0128         double m_mean_anomaly { 0 };
0129         /// Mean Motion [Radians per minutes]
0130         double m_mean_motion { 0 };
0131         /// Revolution number at epoch [Revs]
0132         int m_nb_revolution { 0 };
0133         /// TLE epoch converted to julian date
0134         double m_tle_jd { 0 };
0135 
0136         // Satellite
0137         /// True if the satellite is visible
0138         bool m_is_visible { false };
0139         /// True if the satellite is in the shadow of the earth
0140         bool m_is_eclipsed { false };
0141         /// True if the satellite is selected
0142         bool m_is_selected { false };
0143         /// Satellite velocity in km/s
0144         double m_velocity { 0 };
0145         /// Satellite altitude in km
0146         double m_altitude { 0 };
0147         /// Satellite range from observer in km
0148         double m_range { 0 };
0149 
0150         // Near Earth
0151         bool isimp { false };
0152         double aycof { 0 }, con41 { 0 }, cc1 { 0 }, cc4 { 0 }, cc5 { 0 }, d2 { 0 }, d3 { 0 }, d4 { 0 };
0153         double delmo { 0 }, eta { 0 }, argpdot { 0 }, omgcof { 0 }, sinmao { 0 }, t { 0 }, t2cof { 0 };
0154         double t3cof { 0 }, t4cof { 0 }, t5cof { 0 }, x1mth2 { 0 }, x7thm1 { 0 }, mdot { 0 };
0155         double nodedot { 0 }, xlcof { 0 }, xmcof { 0 }, nodecf { 0 };
0156 
0157         // Deep Space
0158         int irez { 0 };
0159         double d2201 { 0 }, d2211 { 0 }, d3210 { 0 }, d3222 { 0 }, d4410 { 0 }, d4422 { 0 }, d5220 { 0 };
0160         double d5232 { 0 }, d5421 { 0 }, d5433 { 0 }, dedt { 0 }, del1 { 0 }, del2 { 0 }, del3 { 0 };
0161         double didt { 0 }, dmdt { 0 }, dnodt { 0 }, domdt { 0 }, e3 { 0 }, ee2 { 0 }, peo { 0 };
0162         double pgho { 0 }, pho { 0 }, pinco { 0 }, plo { 0 }, se2 { 0 }, se3 { 0 }, sgh2 { 0 };
0163         double sgh3 { 0 }, sgh4 { 0 }, sh2 { 0 }, sh3 { 0 }, si2 { 0 }, si3 { 0 }, sl2 { 0 }, sl3 { 0 };
0164         double sl4 { 0 }, gsto { 0 }, xfact { 0 }, xgh2 { 0 }, xgh3 { 0 }, xgh4 { 0 }, xh2 { 0 };
0165         double xh3 { 0 }, xi2 { 0 }, xi3 { 0 }, xl2 { 0 }, xl3 { 0 }, xl4 { 0 }, xlamo { 0 }, zmol { 0 };
0166         double zmos { 0 }, atime { 0 }, xli { 0 }, xni { 0 };
0167 
0168         char method;
0169 };