• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
Planet.cpp
Go to the documentation of this file.
1 //Copyright 2009 Henry de Valence <hdevalence@gmail.com>
2 //Copyright 2009 David Roberts <dvdr18@gmail.com>
3 //Copyright 2012 Mohammed Nafees <nafees.technocool@gmail.com>
4 //
5 // This file is part of the Marble Virtual Globe.
6 //
7 // This program is free software licensed under the GNU LGPL. You can
8 // find a copy of this license in LICENSE.txt in the top directory of
9 // the source code.
10 //
11 #include "Planet.h"
12 
13 #include <QString>
14 #include <QHash>
15 #include <QObject>
16 
17 #include "MarbleDebug.h"
18 #include "MarbleGlobal.h"
19 #include "MarbleColors.h"
20 
21 namespace Marble
22 {
23 
24 class PlanetPrivate
25 {
26 public:
27  qreal M_0, M_1; // for calculating mean anomaly
28  qreal C_1, C_2, C_3, C_4, C_5, C_6; // for calculating equation of center
29  qreal Pi; // ecliptic longitude of the perihelion
30  qreal epsilon; // obliquity of the ecliptic plane
31  qreal theta_0, theta_1; // for calculating sidereal time
32  qreal radius; //in metres
33  QString name, id; //localized and nonlocalized names
34  bool atmosphere;
35  QColor atmosphereColor;
36  //convenience function
37  void setup(qreal M_0, qreal M_1, qreal C_1, qreal C_2, qreal C_3, qreal C_4,
38  qreal C_5, qreal C_6, qreal Pi, qreal epsilon, qreal theta_0,
39  qreal theta_1, qreal radius, const QString& name,
40  const QString& id, bool atmosphere = false )
41  {
42  this->M_0 = M_0;
43  this->M_1 = M_1;
44  this->C_1 = C_1;
45  this->C_2 = C_2;
46  this->C_3 = C_3;
47  this->C_4 = C_4;
48  this->C_5 = C_5;
49  this->C_6 = C_6;
50  this->Pi = Pi;
51  this->epsilon = epsilon;
52  this->theta_0 = theta_0;
53  this->theta_1 = theta_1;
54  this->radius = radius;
55  this->name = name;
56  this->id = id;
57  this->atmosphere = atmosphere;
58  };
59 };
60 
61 
62 //Constructor
63 Planet::Planet()
64  : d( new PlanetPrivate )
65 {
66  d->setup( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
67  QObject::tr("Unknown Planet", "a planet without data"), QString("unknown") );
68 }
69 
70 Planet::Planet( const QString& id )
71  : d( new PlanetPrivate )
72 {
73  // constants taken from
74  // http://www.astro.uu.nl/~strous/AA/en/reken/zonpositie.html
75  if ( id == "mercury" ) {
76  d->setup( (174.7948*DEG2RAD), (4.09233445*DEG2RAD),
77  (23.4400*DEG2RAD), (2.9818*DEG2RAD), (0.5255*DEG2RAD),
78  (0.1058*DEG2RAD), (0.0241*DEG2RAD), (0.0055*DEG2RAD),
79  (111.5943*DEG2RAD), (0.02*DEG2RAD), (13.5964*DEG2RAD),
80  (6.1385025*DEG2RAD), 2440000.0,
81  name( id ), id );
82  } else if ( id == "venus" ) {
83  d->setup( (50.4161*DEG2RAD), (1.60213034*DEG2RAD),
84  (0.7758*DEG2RAD), (0.0033*DEG2RAD), (0.0000*DEG2RAD),
85  (0.0000*DEG2RAD), (0.0000*DEG2RAD), (0.0000*DEG2RAD),
86  (73.9519*DEG2RAD), (2.64*DEG2RAD), (215.2995*DEG2RAD),
87  (-1.4813688*DEG2RAD), 6051800.0,
88  name( id ), id, true );
89  setAtmosphereColor(Oxygen::sunYellow4);
90  } else if ( id == "earth" ) {
91  d->setup( (357.5291*DEG2RAD), (0.98560028*DEG2RAD),
92  (1.9148*DEG2RAD), (0.0200*DEG2RAD), (0.0003*DEG2RAD),
93  (0.0000*DEG2RAD), (0.0000*DEG2RAD), (0.0000*DEG2RAD),
94  (102.9372*DEG2RAD), (23.45*DEG2RAD), (280.1600*DEG2RAD),
95  (360.9856235*DEG2RAD), 6378000.0,
96  name( id ), id, true );
97  setAtmosphereColor(Qt::white);
98  } else if ( id == "mars" ) {
99  d->setup( (19.3730*DEG2RAD), (0.52402068*DEG2RAD),
100  (10.6912*DEG2RAD), (0.6228*DEG2RAD), (0.0503*DEG2RAD),
101  (0.0046*DEG2RAD), (0.0005*DEG2RAD), (0.0000*DEG2RAD),
102  (70.9812*DEG2RAD), (25.19*DEG2RAD), (313.4803*DEG2RAD),
103  (350.89198226*DEG2RAD), 3397000.0,
104  name( id ), id, true );
105  setAtmosphereColor(Oxygen::hotOrange2);
106  } else if ( id == "jupiter" ) {
107  d->setup( (20.0202*DEG2RAD), (0.08308529*DEG2RAD),
108  (5.5549*DEG2RAD), (0.1683*DEG2RAD), (0.0071*DEG2RAD),
109  (0.0003*DEG2RAD), (0.0000*DEG2RAD), (0.0000*DEG2RAD),
110  (237.2074*DEG2RAD), (3.12*DEG2RAD), (146.0727*DEG2RAD),
111  (870.5366420*DEG2RAD), 71492000.0,
112  name( id ), id, true );
113  setAtmosphereColor(Oxygen::sunYellow2);
114  } else if ( id == "saturn" ) {
115  d->setup( (317.0207*DEG2RAD), (0.03344414*DEG2RAD),
116  (6.3585*DEG2RAD), (0.2204*DEG2RAD), (0.0106*DEG2RAD),
117  (0.0006*DEG2RAD), (0.0000*DEG2RAD), (0.0000*DEG2RAD),
118  (99.4571*DEG2RAD), (26.74*DEG2RAD), (174.3479*DEG2RAD),
119  (810.7939024*DEG2RAD), 60268000.0,
120  name( id ), id, true );
121  setAtmosphereColor(Oxygen::sunYellow2);
122  } else if ( id == "uranus" ) {
123  d->setup( (141.0498*DEG2RAD), (0.01172834*DEG2RAD),
124  (5.3042*DEG2RAD), (0.1534*DEG2RAD), (0.0062*DEG2RAD),
125  (0.0003*DEG2RAD), (0.0000*DEG2RAD), (0.0000*DEG2RAD),
126  (5.4639*DEG2RAD), (82.22*DEG2RAD), (17.9705*DEG2RAD),
127  (-501.1600928*DEG2RAD), 25559000.0,
128  name( id ), id, true );
129  setAtmosphereColor(Oxygen::seaBlue4);
130  } else if ( id == "neptune" ) {
131  d->setup( (256.2250*DEG2RAD), (0.00598103*DEG2RAD),
132  (1.0302*DEG2RAD), (0.0058*DEG2RAD), (0.0000*DEG2RAD),
133  (0.0000*DEG2RAD), (0.0000*DEG2RAD), (0.0000*DEG2RAD),
134  (182.1957*DEG2RAD), (27.84*DEG2RAD), (52.3996*DEG2RAD),
135  (536.3128492*DEG2RAD), 24766000.0,
136  name( id ), id, true );
137  setAtmosphereColor(Oxygen::skyBlue2);
138  // dwarf planets ... (everybody likes pluto)
139  } else if ( id == "pluto" ) {
140  d->setup( (14.882*DEG2RAD), (0.00396*DEG2RAD),
141  (28.3150*DEG2RAD), (4.3408*DEG2RAD), (0.9214*DEG2RAD),
142  (0.2235*DEG2RAD), (0.0627*DEG2RAD), (0.0174*DEG2RAD),
143  (4.5433*DEG2RAD), (57.46*DEG2RAD), (56.3183*DEG2RAD),
144  (-56.3623195*DEG2RAD), 1151000.0,
145  name( id ), id );
146  // sun and moon
147  } else if ( id == "sun" ) {
148  mDebug() << "WARNING:";
149  mDebug() << "creating \"sun\" which has invalid orbital elements";
150  //FIXME: fill in with valid data
151  d->setup( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 695000000.0,
152  name( id ), id, true );
153  setAtmosphereColor(Qt::white);
154  } else if ( id == "moon" ) {
155  mDebug() << "WARNING:";
156  mDebug() << "creating \"moon\" which has invalid orbital elements";
157  //FIXME: fill in with valid data
158  d->setup( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1738000.0,
159  name( id ), id );
160  setHasAtmosphere(false);
161  } else if ( id == "sky" ) {
162  mDebug() << "WARNING:";
163  mDebug() << "creating \"sky\" which has invalid orbital elements";
164  //FIXME: fill in with valid data
165  d->setup( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000000.0,
166  name( id ), id );
167  } else {
168  mDebug() << "WARNING:";
169  mDebug() << "creating planet" << id << "without enough info";
170  d->setup( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10000000.0,
171  name( QString() ), QString("unknown") );
172  }
173 }
174 
175 //Copy Constructor
176 Planet::Planet( const Planet& other )
177  : d( new PlanetPrivate )
178 {
179  // PlanetPrivate does not have pointer members, so we can just
180  // use its (compiler generated) assignment operator.
181  *d = *other.d;
182 }
183 
184 //Destructor
185 Planet::~Planet()
186 {
187  delete d;
188 }
189 
190 
191  /* Getter functions */
192  // for calculating mean anomaly
193 qreal Planet::M_0() const
194 {
195  return d->M_0;
196 }
197 qreal Planet::M_1() const
198 {
199  return d->M_1;
200 }
201 
202  // for calculating equation of center
203 qreal Planet::C_1() const
204 {
205  return d->C_1;
206 }
207 qreal Planet::C_2() const
208 {
209  return d->C_2;
210 }
211 qreal Planet::C_3() const
212 {
213  return d->C_3;
214 }
215 qreal Planet::C_4() const
216 {
217  return d->C_4;
218 }
219 qreal Planet::C_5() const
220 {
221  return d->C_5;
222 }
223 qreal Planet::C_6() const
224 {
225  return d->C_6;
226 }
227 
228  // ecliptic longitude of the perihelion
229 qreal Planet::Pi() const
230 {
231  return d->Pi;
232 }
233 
234  // obliquity of the ecliptic plane
235 qreal Planet::epsilon() const
236 {
237  return d->epsilon;
238 }
239 
240  // for calculating sidereal time
241 qreal Planet::theta_0() const
242 {
243  return d->theta_0;
244 }
245 qreal Planet::theta_1() const
246 {
247  return d->theta_1;
248 }
249 
250  // the radius of the planet, in metres
251 qreal Planet::radius() const
252 {
253  return d->radius;
254 }
255 
256 
257 QString Planet::name() const
258 {
259  return d->name;
260 }
261 
262 QString Planet::id() const
263 {
264  return d->id;
265 }
266 
267 
268  /* Setter functions */
269 void Planet::setM_0( qreal M_0 )
270 {
271  d->M_0 = M_0;
272 }
273 void Planet::setM_1( qreal M_1 )
274 {
275  d->M_1 = M_1;
276 }
277 
278 void Planet::setC_1( qreal C_1 )
279 {
280  d->C_1 = C_1;
281 }
282 void Planet::setC_2( qreal C_2 )
283 {
284  d->C_2 = C_2;
285 }
286 void Planet::setC_3( qreal C_3 )
287 {
288  d->C_3 = C_3;
289 }
290 void Planet::setC_4( qreal C_4 )
291 {
292  d->C_4 = C_4;
293 }
294 void Planet::setC_5( qreal C_5 )
295 {
296  d->C_5 = C_5;
297 }
298 void Planet::setC_6( qreal C_6 )
299 {
300  d->C_6 = C_6;
301 }
302 
303 void Planet::setPi( qreal Pi )
304 {
305  d->Pi = Pi;
306 }
307 
308 void Planet::setEpsilon( qreal epsilon )
309 {
310  d->epsilon = epsilon;
311 }
312 
313 void Planet::setTheta_0( qreal theta_0 )
314 {
315  d->theta_0 = theta_0;
316 }
317 void Planet::setTheta_1( qreal theta_1 )
318 {
319  d->theta_1 = theta_1;
320 }
321 
322 void Planet::setRadius( qreal radius )
323 {
324  d->radius = radius;
325 }
326 
327 void Planet::setName( const QString& name )
328 {
329  d->name = name;
330 }
331 
332 void Planet::setId( const QString& id )
333 {
334  d->id = id;
335 }
336 
337 QString Planet::name( const QString& id )
338 {
339  if ( id == "mercury" ) {
340  return QObject::tr("Mercury", "the planet");
341  } else if ( id == "venus" ) {
342  return QObject::tr("Venus", "the planet");
343  } else if ( id == "earth" ) {
344  return QObject::tr("Earth", "the planet");
345  } else if ( id == "mars" ) {
346  return QObject::tr("Mars", "the planet");
347  } else if ( id == "jupiter" ) {
348  return QObject::tr("Jupiter", "the planet");
349  } else if ( id == "saturn" ) {
350  return QObject::tr("Saturn", "the planet");
351  } else if ( id == "uranus" ) {
352  return QObject::tr("Uranus", "the planet");
353  } else if ( id == "neptune" ) {
354  return QObject::tr("Neptune", "the planet");
355  // dwarf planets ... (everybody likes pluto)
356  } else if ( id == "pluto" ) {
357  return QObject::tr("Pluto", "the planet");
358  // sun, moon and sky
359  } else if ( id == "sun" ) {
360  return QObject::tr("Sun", "the earth's star");
361  } else if ( id == "moon" ) {
362  return QObject::tr("Moon", "the earth's moon");
363  } else if ( id == "sky" ) {
364  return QObject::tr("Sky");
365  } else if ( id.isEmpty() ) {
366  mDebug() << "Warning: empty id";
367  return QObject::tr("Unknown Planet", "a planet without data");
368  }
369 
370  return id;
371 }
372 
373 QStringList Planet::planetList()
374 {
375 
376  QStringList planets;
377 
378  planets << "mercury"
379  << "venus"
380  << "earth"
381  << "mars"
382  << "jupiter"
383  << "saturn"
384  << "uranus"
385  << "neptune"
386  << "pluto"
387  << "sun"
388  << "moon"
389  << "sky";
390 
391  return planets;
392 }
393 
394 Planet& Planet::operator=(const Planet& rhs)
395 {
396  // PlanetPrivate does not have pointer members, so we can just
397  // use its (compiler generated) assignment operator.
398  *d = *rhs.d;
399  return *this;
400 }
401 
402 bool Planet::hasAtmosphere() const
403 {
404  return d->atmosphere;
405 }
406 
407 void Planet::setHasAtmosphere(bool enabled)
408 {
409  d->atmosphere = enabled;
410 }
411 
412 QColor Planet::atmosphereColor() const
413 {
414  return d->atmosphereColor;
415 }
416 
417 void Planet::setAtmosphereColor(const QColor &color)
418 {
419  d->atmosphereColor = color;
420 }
421 
422 } //namespace Marble
423 
MarbleColors.h
Marble::Planet::id
QString id() const
The internal, nonlocalized name of the planet.
Definition: Planet.cpp:262
Marble::Planet::~Planet
~Planet()
Destructor.
Definition: Planet.cpp:185
Marble::Oxygen::sunYellow2
QColor const sunYellow2
Definition: MarbleColors.h:82
Marble::Planet::setM_1
void setM_1(qreal M_1)
Definition: Planet.cpp:273
Marble::Planet::C_4
qreal C_4() const
Definition: Planet.cpp:215
Marble::Oxygen::skyBlue2
QColor const skyBlue2
Definition: MarbleColors.h:58
Marble::Oxygen::sunYellow4
QColor const sunYellow4
Definition: MarbleColors.h:80
Marble::Planet::Pi
qreal Pi() const
ecliptic longitude of the perihelion
Definition: Planet.cpp:229
Marble::Planet::theta_0
qreal theta_0() const
for calculating sidereal time
Definition: Planet.cpp:241
Marble::Oxygen::hotOrange2
QColor const hotOrange2
Definition: MarbleColors.h:88
Marble::Planet::setC_1
void setC_1(qreal C_1)
Definition: Planet.cpp:278
Marble::Planet::setPi
void setPi(qreal Pi)
Definition: Planet.cpp:303
Marble::Planet::operator=
Planet & operator=(const Planet &rhs)
Definition: Planet.cpp:394
Planet.h
MarbleDebug.h
Marble::Planet::planetList
static QStringList planetList()
Definition: Planet.cpp:373
Marble::Planet::C_1
qreal C_1() const
for calculating equation of center
Definition: Planet.cpp:203
Marble::Planet::M_0
qreal M_0() const
for calculating mean anomaly
Definition: Planet.cpp:193
Marble::Planet::hasAtmosphere
bool hasAtmosphere() const
Definition: Planet.cpp:402
Marble::Planet::setM_0
void setM_0(qreal M_0)
Definition: Planet.cpp:269
Marble::Planet::setTheta_1
void setTheta_1(qreal theta_1)
Definition: Planet.cpp:317
Marble::Planet::setHasAtmosphere
void setHasAtmosphere(bool enabled)
Definition: Planet.cpp:407
Marble::Planet
Definition: Planet.h:25
Marble::Oxygen::seaBlue4
QColor const seaBlue4
Definition: MarbleColors.h:62
Marble::Planet::setC_4
void setC_4(qreal C_4)
Definition: Planet.cpp:290
MarbleGlobal.h
Marble::DEG2RAD
const qreal DEG2RAD
Definition: MarbleGlobal.h:200
epsilon
qreal epsilon
Definition: shp2pn2.cpp:59
Marble::Planet::setC_6
void setC_6(qreal C_6)
Definition: Planet.cpp:298
Marble::Planet::setC_2
void setC_2(qreal C_2)
Definition: Planet.cpp:282
Marble::Planet::Planet
Planet()
Constructor to use for a custom planet All of the orbital elements are left empty, so you can fill them in yourself.
Definition: Planet.cpp:63
Marble::Planet::setC_5
void setC_5(qreal C_5)
Definition: Planet.cpp:294
Marble::Planet::C_6
qreal C_6() const
Definition: Planet.cpp:223
Marble::Planet::M_1
qreal M_1() const
Definition: Planet.cpp:197
Marble::Planet::radius
qreal radius() const
the radius of the planet, in metres
Definition: Planet.cpp:251
Marble::Planet::atmosphereColor
QColor atmosphereColor() const
Definition: Planet.cpp:412
Marble::Planet::C_3
qreal C_3() const
Definition: Planet.cpp:211
Marble::Planet::setName
void setName(const QString &name)
Definition: Planet.cpp:327
Marble::Planet::setEpsilon
void setEpsilon(qreal epsilon)
Definition: Planet.cpp:308
Marble::Planet::C_5
qreal C_5() const
Definition: Planet.cpp:219
Marble::Planet::C_2
qreal C_2() const
Definition: Planet.cpp:207
Marble::Planet::name
QString name() const
The user visible name of the planet.
Definition: Planet.cpp:257
Marble::Planet::epsilon
qreal epsilon() const
obliquity of the ecliptic plane
Definition: Planet.cpp:235
Marble::Planet::setAtmosphereColor
void setAtmosphereColor(const QColor &color)
Definition: Planet.cpp:417
Marble::Planet::setRadius
void setRadius(qreal radius)
Definition: Planet.cpp:322
Marble::Planet::setC_3
void setC_3(qreal C_3)
Definition: Planet.cpp:286
Marble::Planet::setTheta_0
void setTheta_0(qreal theta_0)
Definition: Planet.cpp:313
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
Marble::Planet::setId
void setId(const QString &id)
Definition: Planet.cpp:332
Marble::Planet::theta_1
qreal theta_1() const
Definition: Planet.cpp:245
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal