• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 15670918640

16 Jun 2025 02:08AM UTC coverage: 11.775% (-0.2%) from 11.931%
15670918640

push

github

alex-w
Updated data

14700 of 124846 relevant lines covered (11.77%)

18324.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/modules/Planet.hpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2002 Fabien Chereau
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18
 */
19

20
#ifndef PLANET_HPP
21
#define PLANET_HPP
22

23
#include <memory>
24
#include <qopengl.h>
25
#include "StelObject.hpp"
26
#include "StelProjector.hpp"
27
#include "StelPropertyMgr.hpp"
28
#include "StelTranslator.hpp"
29
#include "VecMath.hpp"
30
#include "GeomMath.hpp"
31
#include "StelFader.hpp"
32
#include "StelTextureTypes.hpp"
33
#include "RotationElements.hpp"
34

35
#include <QCache>
36
#include <QString>
37

38
// The callback type for the external position computation function
39
// arguments are JDE, position[3], velocity[3].
40
// The last variable is the userData pointer, which is Q_NULLPTR for Planets, but used in derived classes. E.g. points to the KeplerOrbit for Comets.
41
typedef void (*posFuncType)(double, double*, double*, void*);
42

43
typedef void (OsculatingFunctType)(double jde0,double jde,double xyz[3], double xyzdot[3]);
44

45
class Orbit;
46
class KeplerOrbit;
47
class StelFont;
48
class StelPainter;
49
class StelTranslator;
50
class StelObserver;
51
class StelOBJ;
52
class StelOpenGLArray;
53
class HipsSurvey;
54
template <class T> class QFuture;
55
class QOpenGLBuffer;
56
class QOpenGLFunctions;
57
class QOpenGLShaderProgram;
58
class QOpenGLTexture;
59
class QOpenGLVertexArrayObject;
60
#ifdef DEBUG_SHADOWMAP
61
class QOpenGLFramebufferObject;
62
#endif
63

64
typedef QSharedPointer<class HipsSurvey> HipsSurveyP;
65

66
// Class to manage rings for planets like Saturn
67
class Ring
68
{
69
public:
70
        Ring(float radiusMin, float radiusMax,const QString &texname);
71
        double getSize(void) const {return static_cast<double>(radiusMax);}
×
72
        const float radiusMin;
73
        const float radiusMax;
74
        StelTextureSP tex;
75
};
76

77
//! @class Planet
78
//! The Planet class is used for the major planets, moons, "Observer" planets, and artificial objects ("Spaceship").
79
//! Major planets and many moons have their own positional computation, the others, and derivatives Comet and MinorPlanet, use KeplerOrbit for their position.
80
//! "Observer" objects (Solar System Observer, Earth Observer, Mars Observer, Jupiter Observer, Saturn Observer, Uranus Observer, Neptune Observer)
81
//! are positioned with a GimbalOrbit and can be rotated around their parent by keyboard interaction.
82
//! These are oriented parallel to their parents' polar axis. The actual observer location must be on the North pole so that the vertical screen axis
83
//! aligns with the parent planet's rotational axis.
84
class Planet : public StelObject
85
{
86
public:
87
        static const QString PLANET_TYPE;
88
        friend class SolarSystem;
89

90
        //! numeric typecodes for the type descriptions in ssystem.ini
91
        // Until 0.13 QStrings were used for types.
92
        // Enums are slightly faster than string comparisons in time-critical comparisons.
93
        // If other types are introduced, add here and the string in init().
94
        // TBD for 0.19 or later: Preferably convert this into a bitfield and allow several bits set:
95
        // Cubewanos, SDO, OCO, Sednoids are Asteroids, Pluto is a Plutino and DwarfPlanet, Ceres is Asteroid and DwarfPlanet etc.!
96
        // Maybe even add queries like Planet::isAsteroid() { return (planetType & Planet::isAsteroid);}
97
        enum PlanetType
98
        {
99
                isStar,         // ssystem.ini: type="star"
100
                isPlanet,       // ssystem.ini: type="planet"
101
                isMoon,         // ssystem.ini: type="moon"
102
                isObserver,     // ssystem.ini: type="observer"
103
                isArtificial,   // Used in transitions from planet to planet.
104
                isAsteroid,     // ssystem.ini: type="asteroid". all types >= isAsteroid are "Minor Bodies".
105
                                // Put other things (spacecraft etc) before isAsteroid.
106
                isPlutino,      // ssystem.ini: type="plutino"
107
                isComet,        // ssystem.ini: type="comet"
108
                isDwarfPlanet,  // ssystem.ini: type="dwarf planet"
109
                isCubewano,     // ssystem.ini: type="cubewano"
110
                isSDO,          // ssystem.ini: type="scattered disc object"
111
                isOCO,          // ssystem.ini: type="oco"
112
                isSednoid,      // ssystem.ini: type="sednoid"
113
                isInterstellar, // ssystem.ini: type="interstellar object"
114
                isUNDEFINED     // ssystem.ini: type=<anything else>. THIS IS ONLY IN CASE OF ERROR!
115
        };
116
        Q_ENUM(PlanetType)
117

118
        enum PlanetOrbitColorStyle
119
        {
120
                ocsOneColor,               // One color for all orbits
121
                ocsGroups,                 // Separate colors for each group of Solar system bodies
122
                ocsMajorPlanets,           // Separate colors for each of major planets of Solar system
123
                ocsMajorPlanetsMinorTypes  // Separate colors for each of major planets of Solar system
124
        };
125
        Q_ENUM(PlanetOrbitColorStyle)
126

127
        enum ApparentMagnitudeAlgorithm
128
        {
129
                Mueller_1893,               // G. Mueller, based on visual observations 1877-91. [Explanatory Supplement to the Astronomical Almanac, 1961]
130
                AstronomicalAlmanac_1984,   // Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes (allegedly from D.L. Harris, but this is wrong!)
131
                ExplanatorySupplement_1992, // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) (Was called "Planesas")
132
                ExplanatorySupplement_2013, // Explanatory Supplement to the Astronomical Almanac, 3rd edition 2013
133
                MallamaHilton_2018,         // A. Mallama, J. L. Hilton: Computing apparent planetary magnitudes for the Astronomical Almanac. Astron.&Computing 25 (2018) 10-24
134
                UndefinedAlgorithm,
135
                Generic                     // Visual magnitude based on phase angle and albedo. The formula source for this is totally unknown!
136
        };
137
        Q_ENUM(ApparentMagnitudeAlgorithm)
×
138

139
        //! enums to indicate for which purpose we check positional quality.
140
        //! Objects on KeplerOrbits may be too far from their epoch to provide useful data.
141
        enum PositionQuality
142
        {
143
                Position,                   // Good enough for positions.
144
                OrbitPlotting               // Good enough for orbitplotting?
145
        };
146
        Q_ENUM(PositionQuality)
147

148
        // epoch J2000: 12 UT on 1 Jan 2000
149
        static inline constexpr double J2000 = 2451545.0;
150

151
public:
152
        Planet(const QString& englishName,
153
               double equatorialRadius,
154
               double oblateness,
155
               Vec3f halocolor,
156
               float albedo,
157
               float roughness,
158
               const QString& texMapName,
159
               const QString& normalMapName,
160
               const QString& ahorizonMapName,
161
               const QString& objModelName,
162
               posFuncType _coordFunc,
163
               Orbit *anOrbitPtr,
164
               OsculatingFunctType *osculFunc,
165
               bool closeOrbit,
166
               bool hidden,
167
               bool hasAtmosphere,
168
               bool hasHalo,
169
               const QString &pTypeStr);
170

171
        ~Planet() override;
172

173
        //! Initializes static vars. Must be called before creating first planet.
174
        // Currently ensured by SolarSystem::init()
175
        static void init();
176

177
        ///////////////////////////////////////////////////////////////////////////
178
        // Methods inherited from StelObject
179
        //! Get a string with data about the Planet.
180
        //! Planets support the following InfoStringGroup flags:
181
        //! - Name
182
        //! - Magnitude
183
        //! - RaDec
184
        //! - AltAzi
185
        //! - Distance
186
        //! - Size
187
        //! - PlainText
188
        //! - Extra: Heliocentric Ecliptical Coordinates & Observer-planetocentric Ecliptical Coordinates, Phase, illumination, phase angle & elongation from the Sun
189
        //! @note subclasses should prefer to override only the component infostrings getInfoString...(), not this method!
190
        //! @param core the StelCore object
191
        //! @param flags a set of InfoStringGroup items to include in the return value.
192
        //! @return a QString containing an HTML encoded description of the Planet.
193
        QString getInfoString(const StelCore *core, const InfoStringGroup& flags) const override;
194
        //! In addition to the entries from StelObject::getInfoMap(), Planet objects provide
195
        //! - phase (result of getPhase)
196
        //! - illumination (=100*phase)
197
        //! - phase-angle (radians)
198
        //! - phase-angle-dms (formatted string; DMS)
199
        //! - phase-angle-deg (formatted string; degrees)
200
        //! - elongation (radians)
201
        //! - elongation-dms (formatted string; DMS)
202
        //! - elongation-deg (formatted string; degrees)
203
        //! - ecl-elongation (elongation in ecliptic longitude or Δλ; on Earth only; radians)
204
        //! - ecl-elongation-dms (elongation in ecliptic longitude or Δλ; on Earth only; formatted string; DMS)
205
        //! - ecl-elongation-deg (elongation in ecliptic longitude or Δλ; on Earth only; formatted string; degrees)
206
        //! - type (object type description)
207
        //! - velocity (formatted string)
208
        //! - heliocentric-velocity (formatted string)
209
        //! - scale
210
        //! - eclipse-obscuration (for Sun only)
211
        //! - eclipse-magnitude (for Sun only)
212
        //! - eclipse-crescent-angle (for Sun only; degrees)
213
        //! - central_l (on Earth only; degrees)
214
        //! - central_b (on Earth only; degrees)
215
        //! - pa_axis (on Earth only; degrees)
216
        //! - subsolar_l (on Earth only; degrees)
217
        //! - subsolar_b (on Earth only; degrees)
218
        //! - libration_l (on Earth for Moon only; degrees)
219
        //! - libration_b (on Earth for Moon only; degrees)
220
        //! - colongitude (on Earth for Moon only; degrees)
221
        //! - phase-name (on Earth for Moon only; string)
222
        //! - age (on Earth for Moon only; days. This is currently "elongation angle age" only, not time since last conjunction!)
223
        //! - penumbral-eclipse-magnitude (on Earth for Moon only)
224
        //! - umbral-eclipse-magnitude (on Earth for Moon only)
225
        //! - heliocentric-distance (distance to object from the Sun; for Solar system objects, except the Sun; A.U.)
226
        //! - heliocentric-distance-km (distance to object from the Sun; for Solar system objects, except the Sun; kilometers)
227
        //! - distance (distance to object; for Solar system objects only; A.U.)
228
        //! - distance-km (distance to object; for Solar system objects only; kilometers)
229
        QVariantMap getInfoMap(const StelCore *core) const  override;
230
        double getCloseViewFov(const StelCore* core) const override;
231
        double getSatellitesFov(const StelCore* core) const override;
232
        double getParentSatellitesFov(const StelCore* core) const override;
233
        //! This actually calls getVMagnitude(core, 1.0);
234
        //! If there is danger the object is partly obscured (eclipsed), prefer to use getVMagnitude(core, eclipseFactor).
235
        float getVMagnitude(const StelCore* core) const override;
236
        //! Compute visual magnitude following the algorithm set in setApparentMagnitudeAlgorithm().
237
        //! This is most important to compute Solar magnitude during a solar eclipse.
238
        //! @param eclipseFactor can be computed with SolarSystem::getSolarEclipseFactor(core)
239
        virtual float getVMagnitude(const StelCore* core, double eclipseFactor) const;
240
        float getSelectPriority(const StelCore* core) const override;
241
        Vec3f getInfoColor(void) const override;
242
        //! @return "Planet". For technical reasons this is also returned by Comets and MinorPlanets and the Sun. A better type is returned by getObjectType()
243
        QString getType(void) const override {return PLANET_TYPE;}
×
244
        //! Get more specific Planet type for scripts
245
        //! @return an English type description of planet (star, planet, moon, observer, artificial, asteroid, plutino, comet, dwarf planet, cubewano, scattered disc object, Oort cloud object, sednoid, interstellar object)
246
        QString getObjectType(void) const override { return pTypeMap.value(pType); }
×
247
        //! Get more specific Planet type for scripts
248
        //! @return a localized type description of planet (star, planet, moon, observer, artificial, asteroid, plutino, comet, dwarf planet, cubewano, scattered disc object, Oort cloud object, sednoid, interstellar object)
249
        QString getObjectTypeI18n(void) const override { return q_(pTypeMap.value(pType)); }
×
250
        //! @return English name of planet
251
        QString getID(void) const override { return englishName; }
×
252
        //! A Planet's own eclipticPos is in VSOP87 ref. frame (practically equal to ecliptic of J2000 for us) coordinates relative to the parent body (sun, planet).
253
        //! To get J2000 equatorial coordinates, we require heliocentric ecliptical positions (adding up parent positions) of observer and Planet.
254
        //! Then we use the matrix rotation multiplication with an existing matrix in StelCore to orient from eclipticalJ2000 to equatorialJ2000.
255
        //! The end result is a non-normalized 3D vector which allows retrieving distances etc.
256
        //! The positional computation is called by SolarSystem. If the core's aberration setting is active, the J2000 position will then include it.
257
        Vec3d getJ2000EquatorialPos(const StelCore *core) const override;
258
        QString getEnglishName(void) const override {return englishName;}
×
259
        QString getNameI18n(void) const override {return nameI18;}
×
260

261
        virtual QString getIAUDesignation(void) const;
262
        QString getNameNative(void) const override { return (culturalNames.isEmpty() ? "" : culturalNames.constFirst().native); }
×
263
        QString getNameNativeI18n(void) const { return (culturalNames.isEmpty() ? "" : culturalNames.constFirst().translatedI18n); }
×
264

265
        // NEW Skyculture-related names
266
        //! retrieve pronunciation from the first of the cultural names
267
        QString getNamePronounce() const override {return (culturalNames.empty() ? "" : culturalNames.constFirst().pronounceI18n);}
×
268
        //! Combine screen label from various components, depending on settings in SkyCultureMgr
269
        QString getScreenLabel() const override;
270
        //! Combine InfoString label from various components, depending on settings in SkyCultureMgr
271
        QString getInfoLabel() const override;
272
        //! Underlying worker that processes the culturalNames
273
        QStringList getCultureLabels(StelObject::CulturalDisplayStyle style) const;
274
        void removeAllCulturalNames() { culturalNames.clear();}
×
275
        //! Add a name for the currently set skyculture
276
        void addCulturalName(StelObject::CulturalName culturalName){culturalNames.append(culturalName);}
×
277

278

279

280
        //! Get angular semidiameter, degrees. If planet display is artificially enlarged (e.g. Moon upscale), value will also be increased.
281
        double getAngularRadius(const StelCore* core) const override;
282
        virtual bool hasAtmosphere(void) {return atmosphere;}
×
283
        virtual bool hasHalo(void) {return halo;}
×
284
        //! Returns whether planet positions are valid and useful for the current simulation time.
285
        //! E.g. outdated orbital elements for Kepler orbits (beyond their orbit_good .ini file entries)
286
        //! may lead to invalid positions which should better not be used.
287
        //! @param purpose signal whether result should be good enough for observation of just for plotting orbit data.
288
        //! For observation, date should be within the orbit_good value, or within 1 year from epoch of the orbital elements.
289
        //! @note for major planets and moons this method will always return true
290
        bool hasValidPositionalData(const double JDE, const PositionQuality purpose) const;
291
        //! Returns JDE dates of presumably valid data for positional calculation or acceptable range for graphics.
292
        //! For the major planets and moons, this is always (std::numeric_limits<double>::min(), std::numeric_limits<double>::max())
293
        //! For planets with Keplerian orbits, this is [epoch-orbit_good, epoch+orbit_good] or,
294
        //! if purpose=Position, [epoch-min(orbit_good, 365), epoch+min(orbit_good, 365)].
295
        //! This should help to detect and avoid using outdated orbital elements.
296
        Vec2d getValidPositionalDataRange(const PositionQuality purpose) const;
297
        float getAxisRotation(void) { return axisRotation;} //! return axisRotation last computed in computeTransMatrix(). [degrees]
×
298

299
        ///////////////////////////////////////////////////////////////////////////
300
        // Methods of SolarSystem object
301
        //! Translate planet name using the passed translator
302
        virtual void translateName(const StelTranslator &trans);
303

304
        // Draw the Planet
305
        // @param eclipseFactor should be precomputed via SolarSystem::getSolarEclipseFactor().
306
        virtual void draw(StelCore* core, float maxMagLabels, const QFont& planetNameFont, const double eclipseFactor);
307

308
        ///////////////////////////////////////////////////////////////////////////
309
        // Methods specific to Planet
310
        //! Get the equator radius of the planet in AU.
311
        //! @return the equator radius of the planet in astronomical units.
312
        double getEquatorialRadius(void) const {return equatorialRadius;}
×
313
        //! Get the value (1-f) for oblateness f=polarRadius/equatorialRadius.
314
        double getOneMinusOblateness(void) const {return oneMinusOblateness;}
×
315
        //! Get the polar radius of the planet in AU.
316
        //! @return the polar radius of the planet in astronomical units.
317
        double getPolarRadius(void) const {return equatorialRadius*oneMinusOblateness;}
318
        //! Get duration of sidereal day (earth days, may come from rot_periode or orbit_period (for moons) from ssystem_*.ini)
319
        double getSiderealDay(void) const { if (re.W1!=0.) return 360.0/re.W1; else return static_cast<double>(re.period);} // I assume the more modern values are better.
×
320
        //! Get duration of sidereal year [earth days]
321
        virtual double getSiderealPeriod(void) const { return siderealPeriod; }
×
322
        //! set duration of sidereal year. Also sets deltaOrbitJDE and may set closeOrbit for Planet objects which have KeplerOrbits.
323
        //! siderealPeriod [earth days] orbital duration.
324
        void setSiderealPeriod(const double siderealPeriod);
325
        //! Get duration of mean solar day, in earth days.
326
        double getMeanSolarDay(void) const;
327
        //! Get albedo
328
        double getAlbedo(void) const { return static_cast<double>(albedo); }
×
329

330
        //! @return texture map name
331
        const QString& getTextMapName() const {return texMapName;}
×
332
        //! @return a type code enum
333
        PlanetType getPlanetType() const {return pType;}
×
334
        Orbit* getOrbit() const {return orbitPtr;}
×
335

336
        //! set the IAU moon number (designation of the moon), if any.
337
        void setIAUMoonNumber(const QString& designation);
338

339
        //! set value for color index B-V
340
        void setColorIndexBV(float bv=99.f);
341

342
        //! set the discovery circumstances of celestial body
343
        //! @param date of discovery
344
        //! @param name of discoverer
345
        void setDiscoveryData(const QString& date, const QString& name) { discoveryDate = date; discoverer = name; }
×
346

347
        //! Return the absolute magnitude (read from file ssystem.ini)
348
        float getAbsoluteMagnitude() const {return absoluteMagnitude;}
×
349
        //! Return the mean opposition magnitude, defined as V(1,0)+5log10(a(a-1))
350
        //! A return value of 100 signals invalid result.
351
        float getMeanOppositionMagnitude() const;
352
        //! Return the mass in kg
353
        double getMass() const { return massKg; }
354
        //
355
        static ApparentMagnitudeAlgorithm getApparentMagnitudeAlgorithm()  { return vMagAlgorithm; }
×
356
        static void setApparentMagnitudeAlgorithm(ApparentMagnitudeAlgorithm algorithm){ vMagAlgorithm=algorithm; }
×
357

358
        //! Compute the axial z rotation (daily rotation around the polar axis) [degrees] to use from equatorial to hour angle based coordinates.
359
        //! On Earth, sidereal time on the other hand is the angle along the planet equator from RA0 to the meridian, i.e. hour angle of the first point of Aries.
360
        //! For Earth (of course) it is sidereal time at Greenwich.
361
        //! V0.21+ update:
362
        //! For planets and Moons, in this context this is the rotation angle W of the Prime meridian from the ascending node of the planet equator on the ICRF equator.
363
        //! The usual WGCCRE model is W=W0+d*W1. Some planets/moons have more complicated rotations though, these are also handled in here.
364
        //! The planet objects with old-style data are computed like in earlier versions of Stellarium. Their computational model is however questionable.
365
        //! For general applicability we need both time flavours:
366
        //! @param JD is JD(UT) for Earth
367
        //! @param JDE is used for other locations
368
        double getSiderealTime(double JD, double JDE) const;
369

370
        //! return a rotation matrix from the planet's equatorial coordinate frame to the VSOP87 (ecliptical J2000) frame.
371
        //! For planets/moons with WGCCRE rotation elements, this is just a single matrix.
372
        //! For objects with traditional elements, this builds up the matrix from the parents.
373
        Mat4d getRotEquatorialToVsop87(void) const;
374
        //! set a rotation matrix from the planet's equatorial coordinate frame to the VSOP87 (ecliptical J2000) frame.
375
        //! For planets/moons with WGCCRE rotation elements, this just sets this matrix.
376
        //! For objects with traditional elements, this builds up the matrix from the parents.
377
        void setRotEquatorialToVsop87(const Mat4d &m);
378

379
        const RotationElements &getRotationElements(void) const {return re;}
×
380

381
        //! Set the rotational elements.
382
        //! Given two data models, we must support both: the traditional elements relative to the parent object:
383
        //! name: English name of the object. A corrective function may be attached which depends on the name.
384
        //! _period: duration of sidereal rotation [Julian days]
385
        //! _offset: [angle at _epoch. ]
386
        //! _epoch: [JDE]
387
        //! _obliquity [rad]
388
        //! _ascendingNode of equator on ecliptic[rad]
389
        //! The more modern way to specify these elements are relative to the ICRF:
390
        //! ra_pole=_ra0 + T*_ra1. ra_pole and de_pole must be computed more than for initialisation for J2000
391
        //! de_pole=_de0 + T*_de1. ra and de values to be stored in [rad]
392
        //! _w0, _w1 to be given in degrees!
393
        //! If _ra0 is not zero, we understand WGCCRE data ra0, ra1, de0, de1, w0, w1 are used.
394
        void setRotationElements(const QString name, const double _period, const double _offset, const double _epoch,
395
                                 const double _obliquity, const double _ascendingNode,
396
                                 const double _ra0, const double _ra1,
397
                                 const double _de0, const double _de1,
398
                                 const double _w0,  const double _w1);
399

400
        //! Note: The only place where this is used is to build up orbits for planet moons w.r.t. the parent planet orientation.
401
        double getRotAscendingNode(void) const {return re.ascendingNode; }
×
402
        //! return angle between axis and normal of ecliptic plane (or, for a moon, equatorial/reference plane defined by parent).
403
        //! For Earth, this is the angle between axis and normal to current ecliptic of date, i.e. the ecliptic obliquity of date JDE.
404
        //! Note: The only place where this is not used for Earth is to build up orbits for planet moons w.r.t. the parent planet orientation.
405
        double getRotObliquity(double JDE) const;
406

407
        //! Compute the position and orbital velocity in the parent Planet coordinate system and set aberrationPush
408
        //! In case of the Sun, it is the heliocentric position and velocity so zeros are set
409
        //! Does not compute new position when dateJDE is less than deltaJDE away from lastJDE
410
        //! You can add the aberrationPush value according to Edot*lightTime in Explanatory Supplement (2013) formula 7.55.
411
        virtual void computePosition(const StelObserver *observer, const double dateJDE, const Vec3d &aberrationPush);
412
        //! Compute the position and orbital velocity in the parent Planet coordinate system, and return them in eclPosition and eclVelocity
413
        //! In case of the Sun, it is the heliocentric position and velocity so zeros are set
414
        //! These may be preferred when we want to avoid setting the actual position (e.g., RTS computation)
415
        virtual void computePosition(const double dateJDE, Vec3d &eclPosition, Vec3d &eclVelocity) const;
416

417

418
        //! Compute the transformation matrix from the local Planet coordinate to the parent Planet coordinate.
419
        //! This requires both flavours of JD in cases involving Earth.
420
        void computeTransMatrix(double JD, double JDE);
421

422
        //! Retrieve planetocentric rectangular coordinates of a location on the ellipsoid surface, or with altitude altMetres above the ellipsoid surface.
423
        //! Meeus, Astr. Alg. 2nd ed, Ch.11.
424
        //! @param longDeg longitude of location, degrees. (currently unused. Set to 0.)
425
        //! @param latDeg planetographic latitude, degrees.
426
        //! @param altMetres altitude above ellipsoid surface (metres)
427
        //! @return [rhoCosPhiPrime*a, rhoSinPhiPrime*a, phiPrime, rho*a]
428
        //! where a=equatorial radius [AU]
429
        //! phiPrime=planetocentric latitude
430
        //! rho*a=planetocentric distance of point [AU]
431
        Vec4d getRectangularCoordinates(const double longDeg, const double latDeg, const double altMetres=0.) const;
432

433
        //! Retrieve the hourly proper motion of Solar system bodies
434
        //! @return [hourlyMotion, positionAngle, deltaAlpha, deltaDelta]
435
        //! where hourlyMotion = hourly proper motion [radians]
436
        //! positionAngle = position angle (the direction of proper motion) [radians]
437
        //! deltaAlpha = hourly motion in R.A. [radians]
438
        //! deltaDelta = hourly motion in Dec. [radians]
439
        Vec4d getHourlyProperMotion(const StelCore *core) const;
440

441
        //! Get the phase angle (radians) for an observer at pos obsPos in heliocentric coordinates (in AU)
442
        double getPhaseAngle(const Vec3d& obsPos) const;
443
        //! Check whether the planet is in a waning phase, i.e. its phase angle is increasing
444
        bool isWaning(const Vec3d& observerPosition, const Vec3d& observerVelocity) const;
445
        //! Get the elongation angle (angular distance, radians, 0<e<2pi) for an observer at pos obsPos in heliocentric coordinates (in AU)
446
        double getElongation(const Vec3d& obsPos) const;
447
        //! Get the elongation angle from the Sun in terms of difference in ecliptical longitude (radians) from the Sun.
448
        //! Result e is within [0...2pi[ :
449
        //! - A result <pi implies eastern elongation, evening visibility.
450
        //! - A result pi<e<2pi implies western elongation, morning visibility.
451
        //! Calling this for the Sun returns 0.
452
        double getElongationDLambda() const;
453

454
        //! Get the angular radius (degrees) of the planet spheroid (i.e. without the rings)
455
        double getSpheroidAngularRadius(const StelCore* core) const;
456
        //! Get the planet phase (illuminated fraction of the planet disk, [0=dark..1=full]) for an observer at pos obsPos in heliocentric coordinates (in AU)
457
        float getPhase(const Vec3d& obsPos) const;
458
        //! Get the position angle of the illuminated limb of a planet
459
        //! The result depends on the arguments' coordinate system which must be identical.
460
        //! E.g. if both are equatorial for equinox of date or J2000, the angle is zero when the bright limb is towards the north of the disk.
461
        //! An angle of 90° indicates a bright limb on the eastern limb, like an old moon.
462
        //! Source: Meeus, Astr.Algorithms (2nd ed.), 48.5.
463
        static float getPAsun(const Vec3d &sunPos, const Vec3d &objPos);
464

465
        //! Get planetographic coordinates of subsolar and sub-observer points.
466
        //! These are defined so that over time the longitude of the central meridian increases.
467
        //! This means longitudes are counted positive towards the west for direct rotators and positive
468
        //! towards the East for negative rotators (e.g. Venus). Other cartographic conventions may have
469
        //! to be followed elsewhere in the program, though. (e.g. planetary feature nomenclature!)
470
        //! Only meaningful for earth-bound observers.
471
        //! Source: Explanatory Supplement 2013, 10.4.1
472
        //! @param jupiterGraphical Jupiter requires special treatment because its LII coordinate system does not
473
        //!                         stay in sync with the texture. (GRS is moving). Set this to true to return the
474
        //!                         incorrect, graphics-only longitude.
475
        //! first[0]  = 10.26 phi_e     [rad] Planetocentric latitude of sub-earth point
476
        //! first[1]  = 10.26 phi'_e    [rad] Planetographic latitude of sub-earth point
477
        //! first[2]  = 10.26 lambda'_e [rad] Planetographic longitude of sub-earth point (0..2pi)
478
        //! first[3]  = 10.29 P_n       [rad] Position angle of axis north pole in equatorial coordinates of date
479
        //! second[0] = 10.26 phi_s     [rad] Planetocentric latitude of sub-solar point
480
        //! second[1] = 10.26 phi'_s    [rad] Planetographic latitude of sub-solar point
481
        //! second[2] = 10.26 lambda'_s [rad] Planetographic longitude of sub-solar point (0..2pi)
482
        //! @note: For the Moon, it is more common to give Libration angles, where L=-lambda'_e, B=phi'_e.
483
        //! @note: For Jupiter, this returns central meridian in L_II.
484
        //! @note: For Saturn, this returns central meridian in L_III (rotation of magnetic field).
485
        QPair<Vec4d, Vec3d> getSubSolarObserverPoints(const StelCore *core, bool jupiterGraphical=false) const;
486

487
        //! returns if planet has retrograde rotation
488
        bool isRotatingRetrograde() const { return re.W1<0.; }
×
489

490
        //! Get the Planet position in the parent Planet ecliptic coordinate in AU
491
        Vec3d getEclipticPos(double dateJDE) const;
492
        //! Get the last computed Planet position in the parent Planet ecliptic coordinate in AU
493
        Vec3d getEclipticPos() const {return getEclipticPos(lastJDE);}
×
494

495
        //! Return the heliocentric ecliptical position
496
        Vec3d getHeliocentricEclipticPos() const {return getHeliocentricPos(eclipticPos);}
×
497
        Vec3d getHeliocentricEclipticPos(double dateJDE) const;
498

499
        //! Return the barycentric ecliptical position
500
        Vec3d getBarycentricEclipticPos(double dateJDE) const;
501

502
        //! Return the heliocentric transformation for local (parentocentric) coordinate
503
        //! @arg p planetocentric rectangular ecliptical coordinate (J2000)
504
        //! @return heliocentric rectangular ecliptical coordinates (J2000)
505
        Vec3d getHeliocentricPos(Vec3d p) const;
506
        //! Propagate the heliocentric coordinates to parentocentric coordinates
507
        //! @arg pos heliocentric rectangular ecliptical coordinate (J2000)
508
        void setHeliocentricEclipticPos(const Vec3d &pos);
509

510
        //! Get the planet velocity around the parent planet in ecliptical coordinates in AU/d
511
        Vec3d getEclipticVelocity() const {return eclipticVelocity;}
×
512

513
        //! Get the planet's heliocentric velocity in the solar system in ecliptical coordinates in AU/d.
514
        Vec3d getHeliocentricEclipticVelocity() const;
515

516
        //! Return the barycentric ecliptical velocity in the solar system in ecliptical coordinates in AU/d. Required for aberration!
517
        Vec3d getBarycentricEclipticVelocity(double dateJDE) const;
518

519
        //! Compute and return the distance to the given position in heliocentric ecliptical (J2000) coordinates (in AU)
520
        //! Preserves result for later retrieval by getDistance()
521
        //! As side effect, improve fps by juggling update frequency (deltaJDE) for asteroids and other minor bodies. They must be fast if close to observer, but can be slow if further away.
522
        double computeDistance(const Vec3d& obsHelioPos);
523
        //! Return the last computed distance to the given position in heliocentric ecliptical (J2000) coordinates (in AU)
524
        double getDistance(void) const {return distance;}
×
525

526
        void setRings(Ring* r) {rings = r;}
×
527

528
        void setSphereScale(double s) { if(!fuzzyEquals(s, sphereScale)) { sphereScale = s; if(objModel) objModel->needsRescale=true; } }
×
529
        double getSphereScale() const { return sphereScale; }
×
530

531
        const QSharedPointer<Planet> getParent(void) const {return parent;}
×
532

533
        static void setLabelColor(const Vec3f& lc) {labelColor = lc;}
×
534
        static const Vec3f& getLabelColor(void) {return labelColor;}
×
535

536
        // update displayed elements. @param deltaTime: ms (since last call)
537
        virtual void update(int deltaTime);
538

539
        void setFlagHints(bool b){hintFader = b;}
×
540
        bool getFlagHints(void) const {return hintFader;}
×
541

542
        void setFlagLabels(bool b){flagLabels = b;}
×
543
        bool getFlagLabels(void) const {return flagLabels;}
×
544

545
        ///////////////////////////////////////////////////////////////////////////
546
        ///// Orbit related code
547
        // Should move to an OrbitPath class which works on a SolarSystemObject, not a Planet
548
        void setFlagOrbits(bool b){orbitFader = b;}
×
549
        bool getFlagOrbits(void) const {return orbitFader;}
550
        LinearFader orbitFader;
551
        // draw orbital path of Planet
552
        void drawOrbit(const StelCore*);
553

554
        static constexpr int ORBIT_SEGMENTS = 360;
555
        Vec3d orbit[ORBIT_SEGMENTS+1];  // store heliocentric coordinates for drawing the orbit
556
        double deltaJDE;                // time difference between positional updates.
557
        double deltaOrbitJDE;
558
        bool closeOrbit;                // whether to connect the beginning of the orbit line to
559
                                        // the end: good for elliptical orbits, bad for parabolic
560
                                        // and hyperbolic orbits
561

562
        static Vec3f orbitColor;
563
        static void setOrbitColor(const Vec3f& oc) {orbitColor = oc;}
×
564
        static const Vec3f& getOrbitColor() {return orbitColor;}
×
565

566
        static Vec3f orbitMajorPlanetsColor;
567
        static void setMajorPlanetOrbitColor(const Vec3f& oc) { orbitMajorPlanetsColor = oc;}
×
568
        static const Vec3f& getMajorPlanetOrbitColor() {return orbitMajorPlanetsColor;}
×
569

570
        static Vec3f orbitMoonsColor;
571
        static void setMoonOrbitColor(const Vec3f& oc) { orbitMoonsColor = oc;}
×
572
        static const Vec3f& getMoonOrbitColor() {return orbitMoonsColor;}
×
573

574
        static Vec3f orbitMinorPlanetsColor;
575
        static void setMinorPlanetOrbitColor(const Vec3f& oc) { orbitMinorPlanetsColor = oc;}
×
576
        static const Vec3f& getMinorPlanetOrbitColor() {return orbitMinorPlanetsColor;}
×
577

578
        static Vec3f orbitDwarfPlanetsColor;
579
        static void setDwarfPlanetOrbitColor(const Vec3f& oc) { orbitDwarfPlanetsColor = oc;}
×
580
        static const Vec3f& getDwarfPlanetOrbitColor() {return orbitDwarfPlanetsColor;}
×
581

582
        static Vec3f orbitCubewanosColor;
583
        static void setCubewanoOrbitColor(const Vec3f& oc) { orbitCubewanosColor = oc;}
×
584
        static const Vec3f& getCubewanoOrbitColor() {return orbitCubewanosColor;}
×
585

586
        static Vec3f orbitPlutinosColor;
587
        static void setPlutinoOrbitColor(const Vec3f& oc) { orbitPlutinosColor = oc;}
×
588
        static const Vec3f& getPlutinoOrbitColor() {return orbitPlutinosColor;}
×
589

590
        static Vec3f orbitScatteredDiscObjectsColor;
591
        static void setScatteredDiscObjectOrbitColor(const Vec3f& oc) { orbitScatteredDiscObjectsColor = oc;}
×
592
        static const Vec3f& getScatteredDiscObjectOrbitColor() {return orbitScatteredDiscObjectsColor;}
×
593

594
        static Vec3f orbitOortCloudObjectsColor;
595
        static void setOortCloudObjectOrbitColor(const Vec3f& oc) { orbitOortCloudObjectsColor = oc;}
×
596
        static const Vec3f& getOortCloudObjectOrbitColor() {return orbitOortCloudObjectsColor;}
×
597

598
        static Vec3f orbitCometsColor;
599
        static void setCometOrbitColor(const Vec3f& oc) { orbitCometsColor = oc;}
×
600
        static const Vec3f& getCometOrbitColor() {return orbitCometsColor;}
×
601

602
        static Vec3f orbitSednoidsColor;
603
        static void setSednoidOrbitColor(const Vec3f& oc) { orbitSednoidsColor = oc;}
×
604
        static const Vec3f& getSednoidOrbitColor() {return orbitSednoidsColor;}
×
605

606
        static Vec3f orbitInterstellarColor;
607
        static void setInterstellarOrbitColor(const Vec3f& oc) { orbitInterstellarColor = oc;}
×
608
        static const Vec3f& getInterstellarOrbitColor() {return orbitInterstellarColor;}
×
609

610
        static Vec3f orbitMercuryColor;
611
        static void setMercuryOrbitColor(const Vec3f& oc) { orbitMercuryColor = oc;}
×
612
        static const Vec3f& getMercuryOrbitColor() {return orbitMercuryColor;}
×
613

614
        static Vec3f orbitVenusColor;
615
        static void setVenusOrbitColor(const Vec3f& oc) { orbitVenusColor = oc;}
×
616
        static const Vec3f& getVenusOrbitColor() {return orbitVenusColor;}
×
617

618
        static Vec3f orbitEarthColor;
619
        static void setEarthOrbitColor(const Vec3f& oc) { orbitEarthColor = oc;}
×
620
        static const Vec3f& getEarthOrbitColor() {return orbitEarthColor;}
×
621

622
        static Vec3f orbitMarsColor;
623
        static void setMarsOrbitColor(const Vec3f& oc) { orbitMarsColor = oc;}
×
624
        static const Vec3f& getMarsOrbitColor() {return orbitMarsColor;}
×
625

626
        static Vec3f orbitJupiterColor;
627
        static void setJupiterOrbitColor(const Vec3f& oc) { orbitJupiterColor = oc;}
×
628
        static const Vec3f& getJupiterOrbitColor() {return orbitJupiterColor;}
×
629

630
        static Vec3f orbitSaturnColor;
631
        static void setSaturnOrbitColor(const Vec3f& oc) { orbitSaturnColor = oc;}
×
632
        static const Vec3f& getSaturnOrbitColor() {return orbitSaturnColor;}
×
633

634
        static Vec3f orbitUranusColor;
635
        static void setUranusOrbitColor(const Vec3f& oc) { orbitUranusColor = oc;}
×
636
        static const Vec3f& getUranusOrbitColor() {return orbitUranusColor;}
×
637

638
        static Vec3f orbitNeptuneColor;
639
        static void setNeptuneOrbitColor(const Vec3f& oc) { orbitNeptuneColor = oc;}
×
640
        static const Vec3f& getNeptuneOrbitColor() {return orbitNeptuneColor;}
×
641

642
        static PlanetOrbitColorStyle orbitColorStyle;
643

644
        //! Return the list of planets which project some shadow on this planet
645
        QVector<const Planet*> getCandidatesForShadow() const;
646

647
        Vec3d getAberrationPush() const {return aberrationPush; }
×
648

649
        //! Compute times of nearest rise, transit and set for a solar system object for current location.
650
        //! @param core the currently active StelCore object
651
        //! @param altitude (optional; default=0) altitude of the object, degrees.
652
        //!        Setting this to -6. for the Sun will find begin and end for civil twilight.
653
        //! @return Vec4d - time of rise, transit and set closest to current time; JD.
654
        //! @note The fourth element flags particular conditions:
655
        //!       *  +100. for circumpolar objects. Rise and set give lower culmination times.
656
        //!       *  -100. for objects never rising. Rise and set give transit times.
657
        //!       * -1000. is used as "invalid" value. The result should then not be used.
658
        //! @note This is based on Meeus, Astronomical Algorithms (2nd ed.), but deviates in details.
659
        //! @note Limitation for efficiency: If this is a planet moon from another planet, we compute RTS for the parent planet instead!
660
        virtual Vec4d getClosestRTSTime(const StelCore* core, const double altitude=0.) const;
661

662
        //! Adaptation of getClosestRTSTime() to compute times of rise, transit and set for a solar system object for current location and date.
663
        //! @note The fourth element flags particular conditions:
664
        //!       *   +20 for objects with no transit time on current date.
665
        //!       *   +30 for objects with no rise time on current date.
666
        //!       *   +40 for objects with no set time on current date.
667
        Vec4d getRTSTime(const StelCore* core, const double altitude=0.) const override;
668

669
        //! Reset planet textures to those defined at start time. (You may load other textures with replaceTexture()
670
        void resetTextures();
671
        //! Use texture from @param texName (must reside inside the scripts directory!)
672
        void replaceTexture(const QString& texName);
673
        
674
protected:
675
        // These components for getInfoString() can be overridden in subclasses
676
        virtual QString getInfoStringName(const StelCore *core, const InfoStringGroup& flags) const;
677
        virtual QString getInfoStringAbsoluteMagnitude(const StelCore *core, const InfoStringGroup& flags) const;
678
        //! Any flag=Extra information to be displayed after the magnitude strings
679
        virtual QString getInfoStringExtraMag(const StelCore *core, const InfoStringGroup& flags) const;
680
        //! Any flag=Size information to be displayed
681
        virtual QString getInfoStringSize(const StelCore *core, const InfoStringGroup& flags) const;
682
        //! Return elongation and phase angle when flags=Elongation
683
        virtual QString getInfoStringEloPhase(const StelCore *core, const InfoStringGroup& flags, const bool withIllum) const;
684
        //! Return sidereal and synodic periods when flags=Extra
685
        virtual QString getInfoStringPeriods(const StelCore *core, const InfoStringGroup& flags) const;
686
        //! Any flag=Extra information to be displayed at the end
687
        virtual QString getInfoStringExtra(const StelCore *core, const InfoStringGroup& flags) const;
688

689
        virtual QString getDiscoveryCircumstances() const;
690

691
protected:
692
        struct PlanetOBJModel
693
        {
694
                PlanetOBJModel();
695
                ~PlanetOBJModel();
696

697
                //! Loads the data from the StelOBJ into the StelOpenGLArray
698
                bool loadGL();
699

700
                void performScaling(double scale);
701

702
                //! The BBox of the original model before any transformations
703
                AABBox bbox;
704
                //! Contains the original positions in model space in km, they need scaling and projection
705
                QVector<Vec3f> posArray;
706
                //! True when the positions need to be rescaled before drawing
707
                bool needsRescale;
708
                //! Contains the scaled positions (sphere scale in AU), need StelProjector transformation for display
709
                QVector<Vec3f> scaledArray;
710
                //! Used to store the projected array data, avoids re-allocation each frame
711
                QVector<Vec3f> projectedPosArray;
712
                //! An OpenGL buffer for the projected positions
713
                QOpenGLBuffer* projPosBuffer;
714
                //! The single texture to use
715
                StelTextureSP texture;
716
                //! The original StelOBJ data, deleted after loading to GL
717
                StelOBJ* obj;
718
                //! The opengl array, created by loadObjModel() but filled later in main thread
719
                StelOpenGLArray* arr;
720
        };
721

722
        static StelTextureSP texEarthShadow;     // for lunar eclipses
723

724
        //! Used in drawSphere() to compute shadows, and inside a function to derive eclipse sizes.
725
        //! @param solarEclipseCase For reasons currently unknown we must handle solar eclipses as special case.
726
        void computeModelMatrix(Mat4d &result, bool solarEclipseCase) const;
727

728
        //! Update the orbit position values.
729
        void computeOrbit();
730

731
        Vec3f getCurrentOrbitColor() const;
732
        
733
        //! Return the information string "ready to print"
734
        QString getPlanetLabel() const;
735

736
        //! Draw the 3d model. Call the proper functions if there are rings etc..
737
        //! @param screenRd radius in screen pixels
738
        //! @param solarEclipseFactor Full sun is 1.0, fully covered sun is 0.0.
739
        //! This should be determined beforehand so that repeated calls to this function can be avoided.
740
        //! It is usually safe to use 1.0 when eclipses are rare and umimportant.
741
        void draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenRd, double solarEclipseFactor, bool drawOnlyRing=false);
742

743
        //! Draws the OBJ model, assuming it is available
744
        //! @param screenRd radius in screen pixels.
745
        //! @return false if the model can currently not be drawn (not loaded)
746
        bool drawObjModel(StelPainter* painter, float screenRd);
747

748
        bool drawObjShadowMap(StelPainter* painter, QMatrix4x4 &shadowMatrix);
749

750
        //! Starts the OBJ loading process, if it has not been done yet.
751
        //! Returns true when the OBJ is ready to draw
752
        bool ensureObjLoaded();
753

754
        //! Draw the 3D sphere
755
        void drawSphere(StelPainter* painter, float screenRd, bool drawOnlyRing=false);
756

757
        //! Draw the Hips survey.
758
        void drawSurvey(StelCore* core, StelPainter* painter);
759

760
        //! Draw the circle and name of the Planet
761
        void drawHints(const StelCore* core, StelPainter &sPainter, const QFont& planetNameFont);
762

763
        PlanetOBJModel* loadObjModel() const;
764

765
        QString englishName;             //!< english planet name
766
        QString nameI18;                 //!< International translated name
767
        QString texMapName;              //!< Texture file path
768
        QString normalMapName;           //!< Texture file path
769
        QString horizonMapName;          //!< Texture file path
770
        RotationElements re;             //!< Rotation and axis orientation parameters
771
        double siderealPeriod;           //!< sidereal period (Planet year or a moon's sidereal month) [earth days]
772
        double equatorialRadius;         //!< Planet's equatorial radius in AU
773
        double oneMinusOblateness;       //!< OneMinusOblateness=(polar radius)/(equatorial radius). Geometric flattening f=1-oneMinusOblateness (ExplanSup2013 10.1)
774
        Vec3d eclipticPos;               //!< Position in AU in the rectangular ecliptic coordinate system (J2000) centered on the parent body.
775
                                         //!< To get heliocentric coordinates, use getHeliocentricEclipticPos()
776
        Vec3d eclipticVelocity;          //!< Speed in AU/d in the rectangular ecliptic coordinate system (J2000) around the parent body.
777
                                         //!< NEW FEATURE in late 2017. For now, this may be 0/0/0 when we are not yet able to compute it.
778
                                         //!< to get velocity, preferably read getEclipticVelocity() and getHeliocentricEclipticVelocity()
779
                                         //!< The "State Vector" [Heafner 1999] can be formed from (JDE, eclipticPos, eclipticVelocity)
780
        Vec3d aberrationPush;            //!< 0.21.2+: a small displacement to be applied if aberred positions are requested.
781
        Vec3d screenPos;                 //!< Used to store temporarily the 2D position on screen. We need double for moons. Observe Styx from Pluto w/o atmosphere to see that.
782
        Vec3f haloColor;                 //!< used for drawing the planet halo. Also, when non-spherical (OBJ) model without texture is used, its color is derived from haloColour*albedo.
783

784
        float absoluteMagnitude;         //!< since 2017 this moved to the Planet class: V(1,0) from Explanatory Supplement or WGCCRE2009 paper for the planets, H in the H,G magnitude system for Minor planets, H10 for comets.
785
                                         //!< This is the apparent visual magnitude when 1AU from sun and observer, with zero phase angle.
786
        double massKg;                   //!< 23.1+: mass of the planet in kg
787
        float albedo;                    //!< Planet albedo. Used for magnitude computation when no other formula in use. Also, when non-spherical (OBJ) model without texture is used, its color is derived from haloColour*albedo.
788
        float roughness;                 //!< Oren-Nayar roughness for Moon and OBJ-based models
789
        float outgas_intensity;          //!< The intensity of a pseudo-outgas effect, based on an inverse exponential Lambert shading, with the light at the viewing position
790
                                         //!< Non-null only for Comets, but we use one shader for all Planets and derivatives, so we need a placeholder here.
791
        float outgas_falloff;            //!< Exponent for falloff of outgas effect, should probably be < 1
792
                                         //!< Non-null only for Comets, but we use one shader for all Planets and derivatives, so we need a placeholder here.
793
        Mat4d rotLocalToParent;          //!< retro-documented:
794
                                         //!< rotation matrix of axis orientation with respect to the rotation axes of the parent body.
795
                                         //!< For planets, this is the axis orientation w.r.t. VSOP87A/J2000 ecliptical system.
796
                                         //!< For planets' satellites, this used to be a rotation into the planet's equatorial system.
797
                                         //!< 0.21+: if rot_pole... data available in ssystem_*.ini (and therefore re.method==WGCCRE), this is not the rotation from planet axes over ICRF to the VSOP frame on which Stellarium is defined.
798
                                         //!<
799
        float axisRotation;              //!< Rotation angle of the Planet on its axis, degrees.
800
                                         //!< For Earth, this should be Greenwich Mean Sidereal Time GMST.
801
                                         //!< For V0.21+, and for planets computed after the IAU2009/WGCCRE papers this is angle W (rotDeg),
802
                                         //!< i.e. angle between ascending node of body equator w.r.t. ICRF equator and its prime meridian.
803
        StelTextureSP texMap;            //!< Planet map texture
804
        StelTextureSP normalMap;         //!< Planet normal map texture
805
        StelTextureSP horizonMap;        //!< Planet horizon map texture
806

807
        PlanetOBJModel* objModel;                 //!< Planet model (when it has been loaded)
808
        QFuture<PlanetOBJModel*>* objModelLoader; //!< For async loading of the OBJ file
809
        QString objModelPath;
810

811
        HipsSurveyP survey;
812
        HipsSurveyP surveyForNormals;
813
        HipsSurveyP surveyForHorizons;
814

815
        Ring* rings;                     //!< Planet rings
816
        double distance;                 //!< Temporary variable used to store the distance to a given point
817
                                         //!< it is used for sorting while drawing
818
        double sphereScale;              //!< Artificial scaling for better viewing.
819
        double lastJDE;                  //!< caches JDE of last positional computation
820

821
        posFuncType coordFunc;           //!< callback for the calculation of the equatorial rectangular heliocentric position at time JDE.
822
        Orbit* orbitPtr;                 //!< Usually a KeplerOrbit for positional computations of Minor Planets, Comets and Moons.
823
                                         //!< For an "observer", it is GimbalOrbit.
824
                                         //!< For the major planets, it is Q_NULLPTR.
825

826
        OsculatingFunctType *const osculatingFunc;
827
        QSharedPointer<Planet> parent;                  //!< Planet parent i.e. sun for earth
828
        QList<QSharedPointer<Planet> > satellites;      //!< satellites of the Planet
829
        LinearFader hintFader;
830
        LinearFader labelsFader;         //!< Store the current state of the label for this planet
831
        bool flagLabels;                 //!< Define whether labels should be displayed
832
        bool hidden;                     //!< useful for fake planets used as observation positions - not drawn or labeled
833
        bool atmosphere;                 //!< Does the planet have an atmosphere?
834
        bool halo;                       //!< Does the planet have a halo?
835
        PlanetType pType;                //!< Type of body
836
        bool multisamplingEnabled_;
837
        bool planetShadowsSupersampEnabled_;
838

839
        static ApparentMagnitudeAlgorithm vMagAlgorithm;
840

841
        QOpenGLFunctions* gl;
842

843
        static Vec3f labelColor;
844
        static StelTextureSP hintCircleTex;              //!< The circle around an SSO
845
        static const QMap<PlanetType, QString> pTypeMap; //!< Maps fast type to english name.
846
        static const QMap<QString, QString> nPlanetMap;  //!< Maps fast IAU number to IAU designation.
847
        static bool drawMoonHalo;
848
        static bool drawSunHalo;
849
        //! If true, planet orbits will be drawn even if planet is off screen.
850
        static bool permanentDrawingOrbits;
851
        static int orbitsThickness;
852
        QString discoverer;    //!< Discovery data
853
        QString discoveryDate; //!< Discovery data
854

855
private:
856
        class StelPropertyMgr* propMgr;
857
        QString iauMoonNumber;
858
        float b_v;
859

860
        QList<StelObject::CulturalName> culturalNames; //!< names loaded from non-modern Skycultures. Usually just one, but there may be more!
861

862

863
        QString texMapFileOrig;     //!< File path for texture; used for saving original filename
864
        QString normalMapFileOrig;  //!< File path for normal map; used for saving original filename
865
        QString horizonMapFileOrig; //!< File path for horizon map; used for saving original filename
866

867
        std::unique_ptr<QOpenGLVertexArrayObject> sphereVAO;
868
        std::unique_ptr<QOpenGLVertexArrayObject> ringsVAO;
869
        GLuint sphereVBO=0;
870
        GLuint ringsVBO=0;
871

872
        std::unique_ptr<QOpenGLVertexArrayObject> surveyVAO;
873
        GLuint surveyVBO=0;
874

875
        const QString getContextString() const;
876
        QPair<double, double> getLunarEclipseMagnitudes() const;
877

878
        // Shader-related variables
879
        struct PlanetShaderVars {
880
                // Vertex attributes
881
                int texCoord;
882
                int unprojectedVertex;
883
                int vertex;
884
                int normalIn;
885

886
                // Common uniforms
887
                int projectionMatrix;
888
                int hasAtmosphere;
889
                int tex;
890
                int lightDirection;
891
                int eyeDirection;
892
                int diffuseLight;
893
                int ambientLight;
894
                int shadowCount;
895
                int shadowData;
896
                int sunInfo;
897
                int skyBrightness;
898
                int orenNayarParameters;
899
                int outgasParameters;
900

901
                // For Mars poles
902
                int poleLat; // latitudes of edges of northern (x) and southern (y) polar cap [texture y, moving from 0 (S) to 1 (N)]. Only used for Mars, use [1, 0] for other objects.
903

904
                // Moon-specific variables
905
                int earthShadow;
906
                int eclipsePush; // apparent brightness push for partial Lunar Eclipse (make bright rim overbright)
907
                int normalMap;
908
                int horizonMap;
909
                int hasNormalMap;
910
                int hasHorizonMap;
911

912
                // Rings-specific variables
913
                int isRing;
914
                int ring;
915
                int outerRadius;
916
                int innerRadius;
917
                int ringS;
918

919
                // Shadowmap variables
920
                int shadowMatrix;
921
                int shadowTex;
922
                int poissonDisk;
923
                
924
                void initLocations(QOpenGLShaderProgram*);
925
        };
926

927
        //! Encapsulates some calculated information used for rendering
928
        struct RenderData
929
        {
930
                Mat4d modelMatrix;
931
                Mat4d mTarget;
932
                QVector<const Planet*> shadowCandidates;
933
                QMatrix4x4 shadowCandidatesData;
934
                Vec3d eyePos;
935
        };
936

937
        //! Calculates and uploads the common shader uniforms (projection matrix, texture, lighting&shadow data)
938
        RenderData setCommonShaderUniforms(const StelPainter &painter, QOpenGLShaderProgram* shader,
939
                                           const PlanetShaderVars& shaderVars, bool hasNormalMap, bool hasHorizonMap);
940

941
        static PlanetShaderVars planetShaderVars;
942
        static QOpenGLShaderProgram* planetShaderProgram;
943

944
        static PlanetShaderVars ringPlanetShaderVars;
945
        static QOpenGLShaderProgram* ringPlanetShaderProgram;
946
        
947
        static PlanetShaderVars moonShaderVars;
948
        static QOpenGLShaderProgram* moonShaderProgram;
949

950
        static PlanetShaderVars objShaderVars;
951
        static QOpenGLShaderProgram* objShaderProgram;
952

953
        static PlanetShaderVars objShadowShaderVars;
954
        static QOpenGLShaderProgram* objShadowShaderProgram;
955

956
        static PlanetShaderVars transformShaderVars;
957
        static QOpenGLShaderProgram* transformShaderProgram;
958

959
        static bool shaderError;  // True if loading shaders caused errors
960

961
        static bool shadowInitialized;
962
        static Vec2f shadowPolyOffset;
963
#ifdef DEBUG_SHADOWMAP
964
        static QOpenGLFramebufferObject* shadowFBO;
965
#else
966
        static unsigned int shadowFBO;
967
#endif
968
        static unsigned int shadowTex;
969

970

971
        static bool initShader();
972
        static void deinitShader();
973
        static bool initFBO();
974
        static void deinitFBO();
975

976
        static QOpenGLShaderProgram* createShader(const QString& name,
977
                                                  PlanetShaderVars& vars,
978
                                                  const QByteArray& vSrc,
979
                                                  const QByteArray& fSrc,
980
                                                  const QByteArray& prefix=QByteArray(),
981
                                                  const QMap<QByteArray,int>& fixedAttributeLocations=QMap<QByteArray,int>());
982

983
        // Cache of positions in the parent ecliptic coordinates in AU.
984
        // Used only for orbit plotting
985
        mutable QCache<double, Vec3d> orbitPositionsCache;
986
};
987

988
#endif // PLANET_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc