Kstars

ksplanet.h
1 /*
2  SPDX-FileCopyrightText: 2001 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ksplanetbase.h"
10 
11 #include <QHash>
12 #include <QString>
13 #include <QVector>
14 
15 class KSNumbers;
16 
17 /**
18  * @class KSPlanet
19  * A subclass of KSPlanetBase for seven of the major planets in the solar system
20  * (Earth and Pluto have their own specialized classes derived from KSPlanetBase).
21  * @note The Sun is subclassed from KSPlanet.
22  *
23  * KSPlanet contains internal classes to manage the computations of a planet's position.
24  * The position is computed as a series of sinusoidal sums, similar to a Fourier
25  * transform. See "Astronomical Algorithms" by Jean Meeus or the file README.planetmath
26  * for details.
27  * @short Provides necessary information about objects in the solar system.
28  *
29  * @author Jason Harris
30  * @version 1.0
31  */
32 class KSPlanet : public KSPlanetBase
33 {
34  public:
35  /**
36  * Constructor.
37  * @param s Name of planet
38  * @param image_file filename of the planet's image
39  * @param c the color for the planet
40  * @param pSize physical diameter of the planet, in km
41  */
42  explicit KSPlanet(const QString &s = "unnamed", const QString &image_file = QString(), const QColor &c = Qt::white,
43  double pSize = 0);
44 
45  /**
46  * Simplified constructor
47  * @param n identifier of the planet to be created
48  * @see PLANET enum
49  */
50  explicit KSPlanet(int n);
51 
52  KSPlanet *clone() const override;
53  SkyObject::UID getUID() const override;
54 
55  ~KSPlanet() override = default;
56 
57  /**
58  * @short return the untranslated name
59  * This is a dirty way to solve a lot of localization-related trouble for the KDE 4.2 release
60  * TODO: Change the whole architecture for names later
61  */
62  QString untranslatedName() const;
63 
64  /** @short Preload the data used by findPosition. */
65  bool loadData() override;
66 
67  /**
68  * Calculate the ecliptic longitude and latitude of the planet for
69  * the given date (expressed in Julian Millenia since J2000). A reference
70  * to the ecliptic coordinates is returned as the second object.
71  * @param jm Julian Millenia (=jd/1000)
72  * @param ret The ecliptic coordinates are returned by reference through this argument.
73  */
74  virtual void calcEcliptic(double jm, EclipticPosition &ret) const;
75 
76  protected:
77  /**
78  * Calculate the geocentric RA, Dec coordinates of the Planet.
79  * @note reimplemented from KSPlanetBase
80  * @param num pointer to object with time-dependent values for the desired date
81  * @param Earth pointer to the planet Earth (needed to calculate geocentric coords)
82  * @return true if position was successfully calculated.
83  */
84  bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth = nullptr) override;
85 
86  /**
87  * @class OrbitData
88  * This class contains doubles A,B,C which represent a single term in a planet's
89  * positional expansion sums (each sum-term is A*COS(B+C*T)).
90  *
91  * @author Mark Hollomon
92  * @version 1.0
93  */
94  class OrbitData
95  {
96  public:
97  /** Default constructor */
98  OrbitData() : A(0.), B(0.), C(0.) {}
99  /**
100  * Constructor
101  * @param a the A value
102  * @param b the B value
103  * @param c the C value
104  */
105  OrbitData(double a, double b, double c) : A(a), B(b), C(c) {}
106 
107  double A, B, C;
108  };
109 
110  typedef QVector<OrbitData> OBArray[6];
111 
112  /**
113  * OrbitDataColl contains three groups of six QVectors. Each QVector is a
114  * list of OrbitData objects, representing a single sum used in computing
115  * the planet's position. A set of six of these vectors comprises the large
116  * "meta-sum" which yields the planet's Longitude, Latitude, or Distance value.
117  *
118  * @author Mark Hollomon
119  * @version 1.0
120  */
122  {
123  public:
124  /** Constructor */
125  OrbitDataColl() = default;
126 
127  OBArray Lon;
128  OBArray Lat;
129  OBArray Dst;
130  };
131 
132  /**
133  * OrbitDataManager places the OrbitDataColl objects for all planets in a QDict
134  * indexed by the planets' names. It also loads the positional data of each planet from disk.
135  *
136  * @author Mark Hollomon
137  * @version 1.0
138  */
140  {
141  public:
142  /** Constructor */
144 
145  /**
146  * Load orbital data for a planet from disk.
147  * The data is stored on disk in a series of files named
148  * "name.[LBR][0...5].vsop", where "L"=Longitude data, "B"=Latitude data,
149  * and R=Radius data.
150  * @param n the name of the planet whose data is to be loaded from disk.
151  * @param odc reference to the OrbitDataColl containing the planet's orbital data.
152  * @return true if data successfully loaded
153  */
154  bool loadData(OrbitDataColl &odc, const QString &n);
155 
156  private:
157  /**
158  * Read a single orbital data file from disk into an OrbitData vector.
159  * The data files are named "name.[LBR][0...5].vsop", where
160  * "L"=Longitude data, "B"=Latitude data, and R=Radius data.
161  * @param fname the filename to be read.
162  * @param vector pointer to the OrbitData vector to be filled with these data.
163  */
164  bool readOrbitData(const QString &fname, QVector<KSPlanet::OrbitData> *vector);
165 
167  };
168 
169  private:
170  void findMagnitude(const KSNumbers *) override;
171 
172  protected:
173  bool data_loaded { false };
174  static OrbitDataManager odm;
175 };
OrbitDataColl contains three groups of six QVectors.
Definition: ksplanet.h:121
bool loadData() override
Preload the data used by findPosition.
Definition: ksplanet.cpp:186
QString untranslatedName() const
return the untranslated name This is a dirty way to solve a lot of localization-related trouble for t...
Definition: ksplanet.cpp:157
OrbitDataColl()=default
Constructor.
OrbitDataManager places the OrbitDataColl objects for all planets in a QDict indexed by the planets' ...
Definition: ksplanet.h:139
OrbitDataManager()
Constructor.
Definition: ksplanet.cpp:23
KSPlanet * clone() const override
Create copy of object.
Definition: ksplanet.cpp:150
OrbitData(double a, double b, double c)
Constructor.
Definition: ksplanet.h:105
qint64 UID
Type for Unique object IDenticator.
Definition: skyobject.h:49
The ecliptic position of a planet (Longitude, Latitude, and distance from Sun).
Definition: ksplanetbase.h:25
bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth=nullptr) override
Calculate the geocentric RA, Dec coordinates of the Planet.
Definition: ksplanet.cpp:265
Store several time-dependent astronomical quantities.
Definition: ksnumbers.h:42
bool loadData(OrbitDataColl &odc, const QString &n)
Load orbital data for a planet from disk.
Definition: ksplanet.cpp:56
virtual void calcEcliptic(double jm, EclipticPosition &ret) const
Calculate the ecliptic longitude and latitude of the planet for the given date (expressed in Julian M...
Definition: ksplanet.cpp:192
Provides necessary information about objects in the solar system.
Definition: ksplanet.h:32
SkyObject::UID getUID() const override
Return UID for object.
Definition: ksplanet.cpp:402
OrbitData()
Default constructor.
Definition: ksplanet.h:98
KSPlanet(const QString &s="unnamed", const QString &image_file=QString(), const QColor &c=Qt::white, double pSize=0)
Constructor.
Definition: ksplanet.cpp:114
Provides necessary information about objects in the solar system.
Definition: ksplanetbase.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Nov 30 2023 04:05:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.