summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/ksmoon.h
blob: ad424d7380e4f3459b56732331260448aad27c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
                          ksmoon.h  -  K Desktop Planetarium
                             -------------------
    begin                : Sun Aug 26 2001
    copyright            : (C) 2001 by Jason Harris
    email                : kstars@30doradus.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KSMOON_H
#define KSMOON_H

#include "ksplanetbase.h"
#include "dms.h"

/**@class KSMoon
	*A subclass of SkyObject that provides information
	*needed for the Moon.  Specifically, KSMoon provides a moon-specific
	*findPosition() function.  Also, there is a method findPhase(), which returns
	*the lunar phase as a floating-point number between 0.0 and 1.0.
	*@short Provides necessary information about the Moon.
	*@author Jason Harris
	*@version 1.0
	*/

class KStarsData;
class KSSun;

class KSMoon : public KSPlanetBase  {
public:
	/**
		*Default constructor.  Set name="Moon".
		*/
	KSMoon(KStarsData *kd);

	/**Destructor (empty). */
	~KSMoon();

	/**
		*Determine the phase angle of the moon, and assign the appropriate
		*moon image
		*@param Sun The current Sun object.
		*/
	void findPhase( const KSSun *Sun );

	/**@return the moon's current phase angle, as a dms angle
		*/
	dms phase( void ) const { return Phase; }

	/**@return the illuminated fraction of the Moon as seen from Earth
		*/
	double illum( void ) const { return 0.5*(1.0 - cos( phase().radians() ) ); }
	
	/**@return a short string describing the moon's phase
		*/
	TQString phaseName( void ) const;

	/** reimplemented from KSPlanetBase
		*/
	virtual bool loadData();

protected:
	/**Reimplemented from KSPlanetBase, this function employs unique algorithms for
		*estimating the lunar coordinates.  Finding the position of the moon is
		*much more difficult than the other planets.  For one thing, the Moon is
		*a lot closer, so we can detect smaller deviations in its orbit.  Also,
		*the Earth has a significant effect on the Moon's orbit, and their
		*interaction is complex and nonlinear.  As a result, the positions as
		*calculated by findPosition() are only accurate to about 10 arcseconds
		*(10 times less precise than the planets' positions!)
		*@short moon-specific coordinate finder
		*@param num KSNumbers pointer for the target date/time
		*@note we don't use the Earth pointer here
		*/
	virtual bool findGeocentricPosition( const KSNumbers *num, const KSPlanetBase* );

private:
	dms Phase;
	static bool data_loaded;

/**@class MoonLRData
	*Encapsulates the Longitude and radius terms of the sums
	*used to compute the moon's position.
	*@short Moon Longitude and radius data object
	*@author Mark Hollomon
	*@version 1.0
	*/
	class MoonLRData {
		public:
			int nd;
			int nm;
			int nm1;
			int nf;
			double Li;
			double Ri;

			MoonLRData( int pnd, int pnm, int pnm1, int pnf, double pLi, double pRi ):
				nd(pnd), nm(pnm), nm1(pnm1), nf(pnf), Li(pLi), Ri(pRi) {}
	};

	static TQPtrList<MoonLRData> LRData;

/**@class MoonBData
	*Encapsulates the Latitude terms of the sums
	*used to compute the moon's position.
	*@short Moon Latitude data object
	*@author Mark Hollomon
	*@version 1.0
	*/
	class MoonBData {
		public:
			int nd;
			int nm;
			int nm1;
			int nf;
			double Bi;

			MoonBData( int pnd, int pnm, int pnm1, int pnf, double pBi ):
				nd(pnd), nm(pnm), nm1(pnm1), nf(pnf), Bi(pBi) {}
	};

	static TQPtrList<MoonBData> BData;
};

#endif