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

0001 /*
0002     SPDX-FileCopyrightText: Vipul Kumar Singh <vipulkrsingh@gmail.com>
0003     SPDX-FileCopyrightText: Médéric Boquien <mboquien@free.fr>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QString>
0011 #include <QVector>
0012 
0013 class KSNumbers;
0014 class KSPlanetBase;
0015 class KSSun;
0016 class TrailObject;
0017 class dms;
0018 
0019 /**
0020  * @class PlanetMoons
0021  *
0022  * Implements the moons of a planet.
0023  *
0024  * TODO: make the moons SkyObjects, rather than just points.
0025  *
0026  * @author Vipul Kumar Singh
0027  * @version 1.0
0028  */
0029 class PlanetMoons
0030 {
0031   public:
0032     /**
0033      * Constructor.  Assign the name of each moon,
0034      * and initialize their XYZ positions to zero.
0035      */
0036     PlanetMoons() = default;
0037 
0038     /** Destructor.  Delete moon objects */
0039     virtual ~PlanetMoons();
0040 
0041     /**
0042      * @return pointer to a moon given the ID number.
0043      * @param id which moon?
0044      */
0045     inline TrailObject *moon(int id) { return Moon[id]; }
0046 
0047     /**
0048      * @return the name of a moon.
0049      * @param id which moon?
0050      */
0051     QString name(int id) const;
0052 
0053     /**
0054      * Convert the RA,Dec coordinates of each moon to Az,Alt
0055      *
0056      * @param LSTh pointer to the current local sidereal time
0057      * @param lat pointer to the geographic latitude
0058      */
0059     void EquatorialToHorizontal(const dms *LSTh, const dms *lat);
0060 
0061     /**
0062      * @short Find the positions of each Moon, relative to the planet.
0063      *
0064      * We use an XYZ coordinate system, centered on the planet,
0065      * where the X-axis corresponds to the planet's Equator,
0066      * the Y-Axis is parallel to the planet's Poles, and the
0067      * Z-axis points along the line joining the Earth and
0068      * the planet. Once the XYZ positions are known, this
0069      * function also computes the RA, Dec positions of each
0070      * Moon, and sets the inFront bool variable to indicate
0071      * whether the Moon is nearer to us than the planet or not
0072      * (this information is used to determine whether the
0073      * Moon should be drawn on top of the planet, or vice versa).
0074      *
0075      * @param num pointer to the KSNumbers object describing
0076      * the date/time at which to find the positions.
0077      * @param pla pointer to the planet object
0078      * @param sunptr pointer to the Sun object
0079      */
0080     virtual void findPosition(const KSNumbers *num, const KSPlanetBase *pla, const KSSun *sunptr) = 0;
0081 
0082     /**
0083      * @return true if the Moon is nearer to Earth than Saturn.
0084      * @param id which moon? 0=Mimas,1=Enceladus,2=Tethys,3=Dione,4=Rhea,5=Titan,6=Hyperion,7=Lapetus
0085      */
0086     inline bool inFront(int id) const { return InFront[id]; }
0087 
0088     /**
0089      * @return the X-coordinate in the planet-centered coord. system.
0090      * @param i which moon?
0091      */
0092     double x(int i) const { return XP[i]; }
0093 
0094     /**
0095      * @return the Y-coordinate in the planet-centered coord. system.
0096      * @param i which moon?
0097      */
0098     double y(int i) const { return YP[i]; }
0099 
0100     /**
0101      * @return the Z-coordinate in the Planet-centered coord. system.
0102      * @param i which moon?
0103      */
0104     double z(int i) const { return ZP[i]; }
0105 
0106     /** @return the number of moons around the planet */
0107     int nMoons() const { return Moon.size(); }
0108 
0109   protected:
0110     QVector<TrailObject *> Moon;
0111     QVector<bool> InFront;
0112     //the rectangular position, relative to the planet. X-axis is equator of the planet; units are planet Radius
0113     QVector<double> XP, YP, ZP;
0114 
0115   private:
0116     PlanetMoons(const PlanetMoons &);
0117     PlanetMoons &operator=(const PlanetMoons &);
0118 };