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

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • skyobjects
kssun.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  kssun.cpp - K Desktop Planetarium
3  -------------------
4  begin : Sun Jul 22 2001
5  copyright : (C) 2001 by Jason Harris
6  email : jharris@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 #include "kssun.h"
19 
20 #include <cmath>
21 
22 #include "ksnumbers.h"
23 #include "kstarsdata.h"
24 #include "kstarsdatetime.h"
25 
26 KSSun::KSSun( )
27  : KSPlanet( I18N_NOOP( "Sun" ), "sun", Qt::yellow, 1392000. /*diameter in km*/ )
28 {
29  setMag( -26.73 );
30 }
31 
32 KSSun* KSSun::clone() const
33 {
34  return new KSSun(*this);
35 }
36 
37 bool KSSun::loadData() {
38  OrbitDataColl odc;
39  return (odm.loadData(odc, "earth") != 0);
40 }
41 
42 // We don't need to do anything here
43 void KSSun::findMagnitude(const KSNumbers*) {}
44 
45 bool KSSun::findGeocentricPosition( const KSNumbers *num, const KSPlanetBase *Earth ) {
46  if (Earth) {
47  //
48  // For the precision we need, the earth's orbit is circular.
49  // So don't bother to iterate like KSPlanet does. Just subtract
50  // The current delay and recompute (once).
51  //
52 
53  //The light-travel time delay, in millenia
54  //0.0057755183 is the inverse speed of light, in days/AU
55  double delay = (.0057755183 * Earth->rsun()) / 365250.0;
56  //
57  // MHH 2002-02-04 I don't like this. But it avoids code duplication.
58  // Maybe we can find a better way.
59  //
60  const KSPlanet *pEarth = static_cast<const KSPlanet *>(Earth);
61  EclipticPosition trialpos;
62  pEarth->calcEcliptic(num->julianMillenia() - delay, trialpos);
63 
64  setEcLong( (trialpos.longitude + dms(180.0)).reduce() );
65  setEcLat( -trialpos.latitude );
66 
67  setRearth( Earth->rsun() );
68 
69  } else {
70  double sum[6];
71  dms EarthLong, EarthLat; //heliocentric coords of Earth
72  OrbitDataColl odc;
73  double T = num->julianMillenia(); //Julian millenia since J2000
74  double Tpow[6];
75 
76  Tpow[0] = 1.0;
77  for (int i=1; i<6; ++i) {
78  Tpow[i] = Tpow[i-1] * T;
79  }
80  //First, find heliocentric coordinates
81 
82  if ( ! odm.loadData(odc, "earth") ) return false;
83 
84  //Ecliptic Longitude
85  for (int i=0; i<6; ++i) {
86  sum[i] = 0.0;
87  for (int j = 0; j < odc.Lon[i].size(); ++j) {
88  sum[i] += odc.Lon[i][j].A * cos( odc.Lon[i][j].B + odc.Lon[i][j].C*T );
89  }
90  sum[i] *= Tpow[i];
91  //kDebug() << name() << " : sum[" << i << "] = " << sum[i];
92  }
93 
94  EarthLong.setRadians( sum[0] + sum[1] + sum[2] +
95  sum[3] + sum[4] + sum[5] );
96  EarthLong = EarthLong.reduce();
97 
98  //Compute Ecliptic Latitude
99  for (int i=0; i<6; ++i) {
100  sum[i] = 0.0;
101  for (int j = 0; j < odc.Lat[i].size(); ++j) {
102  sum[i] += odc.Lat[i][j].A * cos( odc.Lat[i][j].B + odc.Lat[i][j].C*T );
103  }
104  sum[i] *= Tpow[i];
105  }
106 
107 
108  EarthLat.setRadians( sum[0] + sum[1] + sum[2] + sum[3] +
109  sum[4] + sum[5] );
110 
111  //Compute Heliocentric Distance
112  for (int i=0; i<6; ++i) {
113  sum[i] = 0.0;
114  for (int j = 0; j < odc.Dst[i].size(); ++j) {
115  sum[i] += odc.Dst[i][j].A * cos( odc.Dst[i][j].B + odc.Dst[i][j].C*T );
116  }
117  sum[i] *= Tpow[i];
118  }
119 
120  ep.radius = sum[0] + sum[1] + sum[2] + sum[3] + sum[4] + sum[5];
121  setRearth( ep.radius );
122 
123  setEcLong( (EarthLong + dms(180.0)).reduce() );
124  setEcLat( -EarthLat );
125  }
126 
127  //Finally, convert Ecliptic coords to Ra, Dec. Ecliptic latitude is zero, by definition
128  EclipticToEquatorial( num->obliquity() );
129 
130 
131  nutate(num);
132 
133  // Store in RA0 and Dec0, the unaberrated coordinates
134  setRA0( ra() );
135  setDec0( dec() );
136 
137  aberrate(num);
138 
139  // We obtain the apparent geocentric ecliptic coordinates. That is, after
140  // nutation and aberration have been applied.
141  EquatorialToEcliptic( num->obliquity() );
142 
143  //Determine the position angle
144  findPA( num );
145 
146  return true;
147 }
148 
149 SkyObject::UID KSSun::getUID() const
150 {
151  return solarsysUID(UID_SOL_BIGOBJ) | 0;
152 }
KSSun::KSSun
KSSun()
Constructor.
Definition: kssun.cpp:26
KSPlanetBase::setRearth
void setRearth(double r)
Set the distance from Earth, in AU.
Definition: ksplanetbase.h:139
SkyPoint::ra
const dms & ra() const
Definition: skypoint.h:171
KSPlanet::OrbitDataManager::loadData
bool loadData(OrbitDataColl &odc, const QString &n)
Load orbital data for a planet from disk.
Definition: ksplanet.cpp:65
KSPlanet
A subclass of KSPlanetBase for seven of the major planets in the solar system (Earth and Pluto have t...
Definition: ksplanet.h:40
SkyPoint::aberrate
void aberrate(const KSNumbers *num)
Determine the effects of aberration for this SkyPoint.
Definition: skypoint.cpp:287
KSSun
Child class of KSPlanetBase; encapsulates information about the Sun.
Definition: kssun.h:31
SkyPoint::nutate
void nutate(const KSNumbers *num)
Determine the effects of nutation for this SkyPoint.
Definition: skypoint.cpp:202
KSPlanetBase::EquatorialToEcliptic
void EquatorialToEcliptic(const dms *Obliquity)
Convert Right Ascension/Declination to Ecliptic logitude/latitude.
Definition: ksplanetbase.cpp:97
KSPlanet::odm
static OrbitDataManager odm
Definition: ksplanet.h:179
EclipticPosition::latitude
dms latitude
Definition: ksplanetbase.h:43
KSPlanet::OrbitDataColl
OrbitDataColl contains three groups of six QVectors.
Definition: ksplanet.h:135
KSSun::getUID
virtual SkyObject::UID getUID() const
Return UID for object.
Definition: kssun.cpp:149
KSPlanetBase::UID_SOL_BIGOBJ
static const UID UID_SOL_BIGOBJ
Big object.
Definition: ksplanetbase.h:203
KSPlanetBase::ep
EclipticPosition ep
Definition: ksplanetbase.h:238
KSPlanetBase::findPA
void findPA(const KSNumbers *num)
Determine the position angle of the planet for a given date (used internally by findPosition() ) ...
Definition: ksplanetbase.cpp:240
KSSun::clone
virtual KSSun * clone() const
Create copy of object.
Definition: kssun.cpp:32
KSPlanetBase::solarsysUID
UID solarsysUID(UID type) const
Compute high 32-bits of UID.
Definition: ksplanetbase.h:210
KSSun::findGeocentricPosition
virtual bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth=NULL)
Determine geocentric RA, Dec coordinates for the Epoch given in the argument.
Definition: kssun.cpp:45
KSPlanetBase::rsun
double rsun() const
Definition: ksplanetbase.h:126
KSPlanet::calcEcliptic
virtual void calcEcliptic(double jm, EclipticPosition &ret) const
Calculate the ecliptic longitude and latitude of the planet for the given date (expressed in Julian M...
Definition: ksplanet.cpp:182
EclipticPosition
The ecliptic position of a planet (Longitude, Latitude, and distance from Sun).
Definition: ksplanetbase.h:40
SkyObject::UID
qint64 UID
Type for Unique object IDenticator.
Definition: skyobject.h:53
ksnumbers.h
KSNumbers::obliquity
const dms * obliquity() const
Definition: ksnumbers.h:58
KSPlanetBase::EclipticToEquatorial
void EclipticToEquatorial(const dms *Obliquity)
Convert Ecliptic logitude/latitude to Right Ascension/Declination.
Definition: ksplanetbase.cpp:101
dms
An angle, stored as degrees, but expressible in many ways.
Definition: dms.h:42
SkyPoint::dec
const dms & dec() const
Definition: skypoint.h:174
EclipticPosition::longitude
dms longitude
Definition: ksplanetbase.h:42
SkyObject::setMag
void setMag(float m)
Set the object's sorting magnitude.
Definition: skyobject.h:409
KSNumbers
There are several time-dependent values used in position calculations, that are not specific to an ob...
Definition: ksnumbers.h:43
kssun.h
KSPlanetBase::setEcLat
void setEcLat(dms elat)
Set Ecliptic Geocentric Latitude according to argument.
Definition: ksplanetbase.h:104
SkyPoint::setRA0
void setRA0(dms r)
Sets RA0, the catalog Right Ascension.
Definition: skypoint.h:97
EclipticPosition::radius
double radius
Definition: ksplanetbase.h:44
KSPlanet::OrbitDataColl::Dst
OBArray Dst
Definition: ksplanet.h:142
KSPlanetBase
A subclass of TrailObject that provides additional information needed for most solar system objects...
Definition: ksplanetbase.h:63
kstarsdatetime.h
KSPlanet::OrbitDataColl::Lat
OBArray Lat
Definition: ksplanet.h:141
kstarsdata.h
KSPlanetBase::setEcLong
void setEcLong(dms elong)
Set Ecliptic Geocentric Longitude according to argument.
Definition: ksplanetbase.h:99
SkyPoint::setDec0
void setDec0(dms d)
Sets Dec0, the catalog Declination.
Definition: skypoint.h:108
KSSun::loadData
virtual bool loadData()
Read orbital data from disk.
Definition: kssun.cpp:37
KSNumbers::julianMillenia
double julianMillenia() const
Definition: ksnumbers.h:96
KSPlanet::OrbitDataColl::Lon
OBArray Lon
Definition: ksplanet.h:140
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • 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