12#include "kstarsdata.h"
14#include "kspopupmenu.h"
16#include "skycomponents/skymapcomposite.h"
17#include "skycomponents/solarsystemcomposite.h"
18#include "texturemanager.h"
32#include <qtskipemptyparts.h>
59static const double MagArray[19] = { -12.7, -12.4, -12.1, -11.8, -11.5, -11.2, -11.0, -10.8, -10.4, -10.0,
60 -9.6, -9.2, -8.7, -8.2, -7.6, -6.7, -3.4, 0, 0
78 Q_ASSERT(
typeid(
this) ==
typeid(
static_cast<const KSMoon *
>(
this)));
85 if (instance_count <= 0)
93bool KSMoon::data_loaded =
false;
94int KSMoon::instance_count = 0;
106 if (KSUtils::openDataFile(f,
"moonLR.dat"))
109 while (!stream.
atEnd())
113 if (fields.size() == 6)
115 LRData.
append(MoonLRData());
116 LRData.
last().nd = fields[0].toInt();
117 LRData.
last().nm = fields[1].toInt();
118 LRData.
last().nm1 = fields[2].toInt();
119 LRData.
last().nf = fields[3].toInt();
120 LRData.
last().Li = fields[4].toDouble();
121 LRData.
last().Ri = fields[5].toDouble();
129 if (KSUtils::openDataFile(f,
"moonB.dat"))
132 while (!stream.
atEnd())
136 if (fields.size() == 5)
138 BData.
append(MoonBData());
139 BData.
last().nd = fields[0].toInt();
140 BData.
last().nm = fields[1].toInt();
141 BData.
last().nm1 = fields[2].toInt();
142 BData.
last().nf = fields[3].toInt();
143 BData.
last().Bi = fields[4].toDouble();
159 double T, L, D, M, M1, F, A1, A2, A3;
160 double sumL, sumR, sumB;
165 double Et = 1.0 - 0.002516 * T - 0.0000074 * T * T;
168 L = degToRad(218.3164477 + 481267.88123421 * T - 0.0015786 * T * T + T * T * T / 538841.0 -
169 T * T * T * T / 65194000.0);
171 D = degToRad(297.8501921 + 445267.1114034 * T - 0.0018819 * T * T + T * T * T / 545868.0 -
172 T * T * T * T / 113065000.0);
174 M = degToRad(357.5291092 + 35999.0502909 * T - 0.0001536 * T * T + T * T * T / 24490000.0);
176 M1 = degToRad(134.9633964 + 477198.8675055 * T + 0.0087414 * T * T + T * T * T / 69699.0 -
177 T * T * T * T / 14712000.0);
179 F = degToRad(93.2720950 + 483202.0175233 * T - 0.0036539 * T * T - T * T * T / 3526000.0 +
180 T * T * T * T / 863310000.0);
182 A1 = degToRad(119.75 + 131.849 * T);
183 A2 = degToRad(53.09 + 479264.290 * T);
184 A3 = degToRad(313.45 + 481266.484 * T);
194 for (
const auto &mlrd : LRData)
201 if (abs(mlrd.nm) == 2)
204 sumL += E * mlrd.Li * sin(mlrd.nd * D + mlrd.nm * M + mlrd.nm1 * M1 + mlrd.nf * F);
205 sumR += E * mlrd.Ri * cos(mlrd.nd * D + mlrd.nm * M + mlrd.nm1 * M1 + mlrd.nf * F);
209 for (
const auto &mbd : BData)
216 if (abs(mbd.nm) == 2)
219 sumB += E * mbd.Bi * sin(mbd.nd * D + mbd.nm * M + mbd.nm1 * M1 + mbd.nf * F);
223 sumL += (3958.0 * sin(A1) + 1962.0 * sin(L - F) + 318.0 * sin(A2));
224 sumB += (-2235.0 * sin(L) + 382.0 * sin(A3) + 175.0 * sin(A1 - F) + 175.0 * sin(A1 + F) + 127.0 * sin(L - M1) -
225 115.0 * sin(L + M1));
230 Rearth = (385000.56 + sumR / 1000.0) / AU_KM;
240void KSMoon::findMagnitude(
const KSNumbers *)
245 double phd =
phase().Degrees();
250 phd =
phase().Degrees();
259 int j = (i + 1 > 18) ? 18 : i + 1;
262 if (i >= 0 && j >= 0 && i <= 18 && j <= 18)
264 setMag(MagArray[i] + (MagArray[j] - MagArray[i]) * k / 10);
272 if (defaultSun ==
nullptr)
273 defaultSun = KStarsData::Instance()->
skyComposite()->solarSystemComposite()->sun();
277 Q_ASSERT(Sun !=
nullptr);
282 double DegPhase = dms(Phase).reduce().Degrees();
283 iPhase = int(0.1 * DegPhase + 0.5) % 36;
291 double p = abs(dms(Phase).reduce().Degrees());
295 return i18nc(
"moon phase, 100 percent illuminated",
"Full moon");
297 return i18nc(
"moon phase, 0 percent illuminated",
"New moon");
298 if (fabs(f - 0.50) < 0.06)
301 return i18nc(
"moon phase, half-illuminated and growing",
"First quarter");
303 return i18nc(
"moon phase, half-illuminated and shrinking",
"Third quarter");
308 return i18nc(
"moon phase between new moon and 1st quarter",
"Waxing crescent");
310 return i18nc(
"moon phase between 1st quarter and full moon",
"Waxing gibbous");
312 return i18nc(
"moon phase between full moon and 3rd quarter",
"Waning gibbous");
314 return i18nc(
"moon phase between 3rd quarter and new moon",
"Waning crescent");
317 return i18n(
"unknown");
325 pmenu->createMoonMenu(
this);
Provides necessary information about the Moon.
bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *) override
Reimplemented from KSPlanetBase, this function employs unique algorithms for estimating the lunar coo...
KSMoon()
Default constructor.
QString phaseName() const
SkyObject::UID getUID() const override
Return UID for object.
bool loadData() override
reimplemented from KSPlanetBase
void initPopupMenu(KSPopupMenu *pmenu) override
Initialize the popup menut.
KSMoon * clone() const override
Create copy of object.
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...
const CachingDms * obliquity() const
double julianCenturies() const
A subclass of TrailObject that provides additional information needed for most solar system objects.
UID solarsysUID(UID type) const
Compute high 32-bits of UID.
static const UID UID_SOL_BIGOBJ
Big object.
void findPA(const KSNumbers *num)
Determine the position angle of the planet for a given date (used internally by findPosition() )
void setEcLong(dms elong)
Set Ecliptic Geocentric Longitude according to argument.
const dms & ecLong() const
void EclipticToEquatorial(const CachingDms *Obliquity)
Convert Ecliptic longitude/latitude to Right Ascension/Declination.
void setEcLat(dms elat)
Set Ecliptic Geocentric Latitude according to argument.
Child class of KSPlanetBase; encapsulates information about the Sun.
SkyMapComposite * skyComposite()
void setMag(float m)
Set the object's sorting magnitude.
qint64 UID
Type for Unique object IDenticator.
void setType(int t)
Set the object's type identifier to the argument.
static const QImage & getImage(const QString &name)
Return texture image.
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
static constexpr double DegToRad
DegToRad is a const static member equal to the number of radians in one degree (dms::PI/180....
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
constexpr double degToRad(double deg)
void append(QList< T > &&value)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString readLine(qint64 maxlen)