1/***************************************************************************
2 ksmoon.h - K Desktop Planetarium
3 -------------------
4 begin : Sun Aug 26 2001
5 copyright : (C) 2001 by Jason Harris
6 email : kstars@30doradus.org
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef KSMOON_H_
19#define KSMOON_H_
20
21#include "ksplanetbase.h"
22#include "dms.h"
23
24/**@class KSMoon
25 *A subclass of SkyObject that provides information
26 *needed for the Moon. Specifically, KSMoon provides a moon-specific
27 *findPosition() function. Also, there is a method findPhase(), which returns
28 *the lunar phase as a floating-point number between 0.0 and 1.0.
29 *@short Provides necessary information about the Moon.
30 *@author Jason Harris
31 *@version 1.0
32 */
33
34class KSSun;
35
36class KSMoon : public KSPlanetBase {
37public:
38 /** Default constructor. Set name="Moon". */
39 KSMoon();
40 /** Copy constructor */
41 KSMoon(const KSMoon& o);
42
43 virtual KSMoon* clone() const;
44 virtual SkyObject::UID getUID() const;
45
46 /**Destructor (empty). */
47 ~KSMoon();
48
49 /**
50 *Determine the phase angle of the moon, and assign the appropriate
51 *moon image
52 * @param Sun a KSSun pointer with coordinates updated to the time of computation. If not supplied, the findByName() method will be used to find the sun.
53 *@note Overrides KSPlanetBase::findPhase()
54 */
55 virtual void findPhase( const KSSun *Sun = 0 );
56
57 /**@return the illuminated fraction of the Moon as seen from Earth */
58 double illum() const { return 0.5*(1.0 - cos( Phase * dms::PI / 180.0 ) ); }
59
60 /**@return a short string describing the moon's phase */
61 QString phaseName() const;
62
63 /** reimplemented from KSPlanetBase */
64 virtual bool loadData();
65
66 /** @return iPhase, which is used as a key to find the right image file */
67 inline short int getIPhase() const { return iPhase; }
68
69 /** Reimplemented from KSPlanetBase, this function employs unique algorithms for
70 * estimating the lunar coordinates. Finding the position of the moon is
71 * much more difficult than the other planets. For one thing, the Moon is
72 * a lot closer, so we can detect smaller deviations in its orbit. Also,
73 * the Earth has a significant effect on the Moon's orbit, and their
74 * interaction is complex and nonlinear. As a result, the positions as
75 * calculated by findPosition() are only accurate to about 10 arcseconds
76 * (10 times less precise than the planets' positions!)
77 * @short moon-specific coordinate finder
78 * @param num KSNumbers pointer for the target date/time
79 * @note we don't use the Earth pointer here
80 */
81 virtual bool findGeocentricPosition( const KSNumbers *num, const KSPlanetBase* );
82
83 /**
84 * @brief updateMag calls findMagnitude() to calculate current magnitude of moon
85 * according to current phase. This function is required to perform findMagnitude() from any where in Kstars
86 */
87 void updateMag() { findMagnitude(NULL); }
88
89private:
90 virtual void initPopupMenu( KSPopupMenu* pmenu );
91 virtual void findMagnitude(const KSNumbers*);
92
93 static bool data_loaded;
94 static int instance_count;
95
96 /**@class MoonLRData
97 * Encapsulates the Longitude and radius terms of the sums
98 * used to compute the moon's position.
99 * @short Moon Longitude and radius data object
100 * @author Mark Hollomon
101 * @version 1.0
102 */
103 struct MoonLRData {
104 int nd;
105 int nm;
106 int nm1;
107 int nf;
108 double Li;
109 double Ri;
110 };
111
112 static QList<MoonLRData> LRData;
113
114 /**@class MoonBData
115 * Encapsulates the Latitude terms of the sums
116 * used to compute the moon's position.
117 * @short Moon Latitude data object
118 * @author Mark Hollomon
119 * @version 1.0
120 */
121 struct MoonBData {
122 int nd;
123 int nm;
124 int nm1;
125 int nf;
126 double Bi;
127 };
128
129 static QList<MoonBData> BData;
130 unsigned int iPhase;
131};
132
133#endif
134