Kstars

ksplanet.h
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#include <QHash>
12#include <QString>
13#include <QVector>
14
15class 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 */
32class 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 */
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 */
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};
The ecliptic position of a planet (Longitude, Latitude, and distance from Sun).
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition ksnumbers.h:43
A subclass of TrailObject that provides additional information needed for most solar system objects.
OrbitDataColl contains three groups of six QVectors.
Definition ksplanet.h:122
OrbitDataColl()=default
Constructor.
OrbitDataManager places the OrbitDataColl objects for all planets in a QDict indexed by the planets' ...
Definition ksplanet.h:140
OrbitDataManager()
Constructor.
Definition ksplanet.cpp:23
This class contains doubles A,B,C which represent a single term in a planet's positional expansion su...
Definition ksplanet.h:95
OrbitData()
Default constructor.
Definition ksplanet.h:98
OrbitData(double a, double b, double c)
Constructor.
Definition ksplanet.h:105
A subclass of KSPlanetBase for seven of the major planets in the solar system (Earth and Pluto have t...
Definition ksplanet.h:33
KSPlanet * clone() const override
Create copy of object.
Definition ksplanet.cpp:150
SkyObject::UID getUID() const override
Return UID for object.
Definition ksplanet.cpp:402
bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth=nullptr) override
Calculate the geocentric RA, Dec coordinates of the Planet.
Definition ksplanet.cpp:265
KSPlanet(const QString &s="unnamed", const QString &image_file=QString(), const QColor &c=Qt::white, double pSize=0)
Constructor.
Definition ksplanet.cpp:114
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
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
qint64 UID
Type for Unique object IDenticator.
Definition skyobject.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.