moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / ksplanet.h
blob1db3178aa3e2b9f78851e90eaa1a16d5ac1292ae
1 /***************************************************************************
2 ksplanet.h - K Desktop Planetarium
3 -------------------
4 begin : Sun Jul 22 2001
5 copyright : (C) 2001 by Jason Harris
6 email : jharris@30doradus.org
7 ***************************************************************************/
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 ***************************************************************************/
18 #include <qstring.h>
19 #include <qptrvector.h>
20 #include <qdict.h>
22 #include "ksplanetbase.h"
23 #include "dms.h"
25 #ifndef KSPLANET_H
26 #define KSPLANET_H
28 /**@class KSPlanet
29 *A subclass of KSPlanetBase for seven of the major planets in the solar system
30 *(Earth and Pluto have their own specialized classes derived from KSPlanetBase).
31 *@note The Sun is subclassed from KSPlanet.
33 *KSPlanet contains internal classes to manage the computations of a planet's position.
34 *The position is computed as a series of sinusoidal sums, similar to a Fourier
35 *transform. See "Astronomical Algorithms" by Jean Meeus or the file README.planetmath
36 *for details.
37 *@short Provides necessary information about objects in the solar system.
38 *@author Jason Harris
39 *@version 1.0
42 class KStarsData;
44 class KSPlanet : public KSPlanetBase {
45 public:
47 /**Constructor.
48 *@param s Name of planet
49 *@param image_file filename of the planet's image
50 *@param pSize physical diameter of the planet, in km
52 KSPlanet( KStarsData *kd, QString s="unnamed", QString image_file="", double pSize=0 );
54 /**Destructor (empty)
56 virtual ~KSPlanet() {}
58 /**@short Preload the data used by findPosition.
60 virtual bool loadData();
62 /**Calculate the ecliptic longitude and latitude of the planet for
63 *the given date (expressed in Julian Millenia since J2000). A reference
64 *to the ecliptic coordinates is returned as the second object.
65 *@param jm Julian Millenia (=jd/1000)
66 *@param ret The ecliptic coordinates are returned by reference through this argument.
68 virtual void calcEcliptic(double jm, EclipticPosition &ret) const;
70 protected:
72 bool data_loaded;
74 /**Calculate the geocentric RA, Dec coordinates of the Planet.
75 *@note reimplemented from KSPlanetBase
76 *@param num pointer to object with time-dependent values for the desired date
77 *@param Earth pointer to the planet Earth (needed to calculate geocentric coords)
78 *@return true if position was successfully calculated.
80 virtual bool findGeocentricPosition( const KSNumbers *num, const KSPlanetBase *Earth=NULL );
82 /**@class OrbitData
83 *This class contains doubles A,B,C which represent a single term in a planet's
84 *positional expansion sums (each sum-term is A*COS(B+C*T)).
85 *@author Mark Hollomon
86 *@version 1.0
88 class OrbitData {
89 public:
90 /**Constructor
91 *@p a the A value
92 *@p b the B value
93 *@p c the C value
95 OrbitData(double a, double b, double c) :
96 A(a), B(b), C(c) {};
98 double A, B, C;
101 typedef QPtrVector<OrbitData> OBArray[6];
103 /**OrbitDataColl contains three groups of six QPtrVectors. Each QPtrVector is a
104 *list of OrbitData objects, representing a single sum used in computing
105 *the planet's position. A set of six of these vectors comprises the large
106 *"meta-sum" which yields the planet's Longitude, Latitude, or Distance value.
107 *@author Mark Hollomon
108 *@version 1.0
110 class OrbitDataColl {
111 public:
112 /**Constructor*/
113 OrbitDataColl();
115 OBArray Lon;
116 OBArray Lat;
117 OBArray Dst;
121 /**OrbitDataManager places the OrbitDataColl objects for all planets in a QDict
122 *indexed by the planets' names. It also loads the positional data of each planet
123 *from disk.
124 *@author Mark Hollomon
125 *@version 1.0
127 class OrbitDataManager {
128 public:
129 /**Constructor*/
130 OrbitDataManager();
132 /**Load orbital data for a planet from disk.
133 *The data is stored on disk in a series of files named
134 *"name.[LBR][0...5].vsop", where "L"=Longitude data, "B"=Latitude data,
135 *and R=Radius data.
136 *@p n the name of the planet whose data is to be loaded from disk.
137 *@return pointer to the OrbitDataColl containing the planet's orbital data.
139 OrbitDataColl *loadData(QString n);
141 private:
142 /**Read a single orbital data file from disk into an OrbitData vector.
143 *The data files are named "name.[LBR][0...5].vsop", where
144 *"L"=Longitude data, "B"=Latitude data, and R=Radius data.
145 *@p fname the filename to be read.
146 *@p vector pointer to the OrbitData vector to be filled with these data.
148 bool readOrbitData(QString fname, QPtrVector<KSPlanet::OrbitData> *vector);
150 QDict<OrbitDataColl> dict;
153 static OrbitDataManager odm;
157 #endif