Kstars
12 #include "kstarsdata.h"
14 #include "kspopupmenu.h"
16 #include "skycomponents/skymapcomposite.h"
17 #include "skycomponents/solarsystemcomposite.h"
18 #include "texturemanager.h"
21 #include <QTextStream>
32 #include <qtskipemptyparts.h>
59 static 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)
93 bool KSMoon::data_loaded =
false;
94 int 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;
240 void KSMoon::findMagnitude(
const KSNumbers *)
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);
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);
void append(const T &value)
SkyObject::UID getUID() const override
Return UID for object.
static constexpr double PI
PI is a const static member; it's public so that it can be used anywhere, as long as dms....
virtual void findPhase()
Determine the phase of the planet.
constexpr double degToRad(double deg)
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
KSMoon * clone() const override
Create copy of object.
static constexpr double DegToRad
DegToRad is a const static member equal to the number of radians in one degree (dms::PI/180....
QString phaseName() const
void setEcLat(dms elat)
Set Ecliptic Geocentric Latitude according to argument.
Provides necessary information about the Moon. A subclass of SkyObject that provides information need...
qint64 UID
Type for Unique object IDenticator.
bool loadData() override
reimplemented from KSPlanetBase
void setEcLong(dms elong)
Set Ecliptic Geocentric Longitude according to argument.
Provides necessary information about the Sun.
QString i18n(const char *text, const TYPE &arg...)
Store several time-dependent astronomical quantities.
void setMag(float m)
Set the object's sorting magnitude.
void initPopupMenu(KSPopupMenu *pmenu) override
Initialize the popup menut.
const dms & ecLong() const
bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *) override
Reimplemented from KSPlanetBase, this function employs unique algorithms for estimating the lunar coo...
QString readLine(qint64 maxlen)
SkyMapComposite * skyComposite()
UID solarsysUID(UID type) const
Compute high 32-bits of UID.
An angle, stored as degrees, but expressible in many ways.
const CachingDms * obliquity() const
const double & Degrees() const
static const QImage & getImage(const QString &name)
Return texture image.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
double julianCenturies() const
KSMoon()
Default constructor.
const dms reduce() const
return the equivalent angle between 0 and 360 degrees.
void EclipticToEquatorial(const CachingDms *Obliquity)
Convert Ecliptic longitude/latitude to Right Ascension/Declination.
void setType(int t)
Set the object's type identifier to the argument.
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() )
Provides necessary information about objects in the solar system.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Oct 1 2023 04:02:40 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.