Kstars

ksmoon.h
1/*
2 SPDX-FileCopyrightText: 2001 Jason Harris <kstars@30doradus.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "ksplanetbase.h"
10#include "dms.h"
11
12class KSSun;
13
14/**
15 * @class KSMoon
16 * @short Provides necessary information about the Moon.
17 * A subclass of SkyObject that provides information
18 * needed for the Moon. Specifically, KSMoon provides a moon-specific
19 * findPosition() function. Also, there is a method findPhase(), which returns
20 * the lunar phase as a floating-point number between 0.0 and 1.0.
21 *
22 * @author Jason Harris
23 * @version 1.0
24 */
25class KSMoon : public KSPlanetBase
26{
27 public:
29
30 /** Default constructor. Set name="Moon". */
31 KSMoon();
32 /** Copy constructor */
33 KSMoon(const KSMoon &o);
34
35 ~KSMoon() override;
36
37 KSMoon *clone() const override;
38 SkyObject::UID getUID() const override;
39
40 /**
41 * Determine the phase angle of the moon, and assign the appropriate moon image
42 * @param Sun a KSSun pointer with coordinates updated to the time of computation.
43 * If not supplied, the sun is retrieved via KStarsData
44 * @note Overrides KSPlanetBase::findPhase()
45 */
46 void findPhase(const KSSun *Sun = nullptr);
47
48 /** @return the illuminated fraction of the Moon as seen from Earth */
49 double illum() const { return 0.5 * (1.0 - cos(Phase * dms::PI / 180.0)); }
50
51 /** @return a short string describing the moon's phase */
52 QString phaseName() const;
53
54 /** reimplemented from KSPlanetBase */
55 bool loadData() override;
56
57 /** @return iPhase, which is used as a key to find the right image file */
58 inline short int getIPhase() const { return iPhase; }
59
60 /**
61 * Reimplemented from KSPlanetBase, this function employs unique algorithms for
62 * estimating the lunar coordinates. Finding the position of the moon is
63 * much more difficult than the other planets. For one thing, the Moon is
64 * a lot closer, so we can detect smaller deviations in its orbit. Also,
65 * the Earth has a significant effect on the Moon's orbit, and their
66 * interaction is complex and nonlinear. As a result, the positions as
67 * calculated by findPosition() are only accurate to about 10 arcseconds
68 * (10 times less precise than the planets' positions!)
69 * @short moon-specific coordinate finder
70 * @param num KSNumbers pointer for the target date/time
71 * @note we don't use the Earth pointer here
72 */
73 bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *) override;
74
75 /**
76 * @brief updateMag calls findMagnitude() to calculate current magnitude of moon
77 * according to current phase. This function is required to perform findMagnitude()
78 * from any where in Kstars
79 */
80 void updateMag() { findMagnitude(nullptr); }
81
82 void initPopupMenu(KSPopupMenu *pmenu) override;
83
84 private:
85 void findMagnitude(const KSNumbers *) override;
86
87 static bool data_loaded;
88 static int instance_count;
89
90 /**
91 * @class MoonLRData
92 * @short Moon Longitude and radius data object
93 * Encapsulates the Longitude and radius terms of the sums
94 * used to compute the moon's position.
95 */
96 struct MoonLRData
97 {
98 int nd { 0 };
99 int nm { 0 };
100 int nm1 { 0 };
101 int nf { 0 };
102 double Li { 0 };
103 double Ri { 0 };
104 };
105
106 static QList<MoonLRData> LRData;
107
108 /**
109 * @class MoonBData
110 * Encapsulates the Latitude terms of the sums used to compute the moon's position.
111 * @short Moon Latitude data object
112 */
113 struct MoonBData
114 {
115 int nd { 0 };
116 int nm { 0 };
117 int nm1 { 0 };
118 int nf { 0 };
119 double Bi { 0 };
120 };
121
122 static QList<MoonBData> BData;
123 unsigned int iPhase { 0 };
124 KSSun *defaultSun=nullptr;
125};
Provides necessary information about the Moon.
Definition ksmoon.h:26
bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *) override
Reimplemented from KSPlanetBase, this function employs unique algorithms for estimating the lunar coo...
Definition ksmoon.cpp:153
KSMoon()
Default constructor.
Definition ksmoon.cpp:64
QString phaseName() const
Definition ksmoon.cpp:288
short int getIPhase() const
Definition ksmoon.h:58
SkyObject::UID getUID() const override
Return UID for object.
Definition ksmoon.cpp:329
bool loadData() override
reimplemented from KSPlanetBase
Definition ksmoon.cpp:98
void initPopupMenu(KSPopupMenu *pmenu) override
Initialize the popup menut.
Definition ksmoon.cpp:320
double illum() const
Definition ksmoon.h:49
void updateMag()
updateMag calls findMagnitude() to calculate current magnitude of moon according to current phase.
Definition ksmoon.h:80
KSMoon * clone() const override
Create copy of object.
Definition ksmoon.cpp:76
virtual void findPhase()
Determine the phase of the planet.
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.
virtual void findPhase()
Determine the phase of the planet.
The KStars Popup Menu.
Definition kspopupmenu.h:35
Child class of KSPlanetBase; encapsulates information about the Sun.
Definition kssun.h:24
qint64 UID
Type for Unique object IDenticator.
Definition skyobject.h:49
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
Definition dms.h:385
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:11:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.