• 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
ksasteroid.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  ksasteroid.cpp - K Desktop Planetarium
3  -------------------
4  begin : Wed 19 Feb 2003
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 "ksasteroid.h"
19 
20 #include <kdebug.h>
21 
22 #include "dms.h"
23 #include "ksnumbers.h"
24 #include "kstarsdata.h"
25 
26 KSAsteroid::KSAsteroid( int _catN, const QString &s, const QString &imfile,
27  long double _JD, double _a, double _e, dms _i, dms _w, dms _Node, dms _M, double _H, double _G )
28  : KSPlanetBase(s, imfile),
29  catN(_catN), JD(_JD), a(_a), e(_e), i(_i), w(_w), M(_M), N(_Node), H(_H), G(_G)
30 {
31  setType( SkyObject::ASTEROID );
32  //Compute the orbital Period from Kepler's 3rd law:
33  P = 365.2568984 * pow(a, 1.5); //period in days
34 }
35 
36 KSAsteroid* KSAsteroid::clone() const
37 {
38  return new KSAsteroid(*this);
39 }
40 
41 bool KSAsteroid::findGeocentricPosition( const KSNumbers *num, const KSPlanetBase *Earth ) {
42  //determine the mean anomaly for the desired date. This is the mean anomaly for the
43  //ephemeis epoch, plus the number of days between the desired date and ephemeris epoch,
44  //times the asteroid's mean daily motion (360/P):
45  dms m = dms( double( M.Degrees() + ( num->julianDay() - JD ) * 360.0/P ) ).reduce();
46  double sinm, cosm;
47  m.SinCos( sinm, cosm );
48 
49  //compute eccentric anomaly:
50  double E = m.Degrees() + e*180.0/dms::PI * sinm * ( 1.0 + e*cosm );
51 
52  if ( e > 0.05 ) { //need more accurate approximation, iterate...
53  double E0;
54  int iter(0);
55  do {
56  E0 = E;
57  iter++;
58  E = E0 - ( E0 - e*180.0/dms::PI *sin( E0*dms::DegToRad ) - m.Degrees() )/(1 - e*cos( E0*dms::DegToRad ) );
59  } while ( fabs( E - E0 ) > 0.001 && iter < 1000 );
60  }
61 
62  double sinE, cosE;
63  dms E1( E );
64  E1.SinCos( sinE, cosE );
65 
66  double xv = a * ( cosE - e );
67  double yv = a * sqrt( 1.0 - e*e ) * sinE;
68 
69  //v is the true anomaly; r is the distance from the Sun
70  double v = atan2( yv, xv ) / dms::DegToRad;
71  double r = sqrt( xv*xv + yv*yv );
72 
73  //vw is the sum of the true anomaly and the argument of perihelion
74  dms vw( v + w.Degrees() );
75  double sinN, cosN, sinvw, cosvw, sini, cosi;
76 
77  N.SinCos( sinN, cosN );
78  vw.SinCos( sinvw, cosvw );
79  i.SinCos( sini, cosi );
80 
81  //xh, yh, zh are the heliocentric cartesian coords with the ecliptic plane congruent with zh=0.
82  double xh = r * ( cosN * cosvw - sinN * sinvw * cosi );
83  double yh = r * ( sinN * cosvw + cosN * sinvw * cosi );
84  double zh = r * ( sinvw * sini );
85 
86  //the spherical ecliptic coordinates:
87  double ELongRad = atan2( yh, xh );
88  double ELatRad = atan2( zh, r );
89 
90  helEcPos.longitude.setRadians( ELongRad );
91  helEcPos.latitude.setRadians( ELatRad );
92  setRsun( r );
93 
94  if ( Earth ) {
95  //xe, ye, ze are the Earth's heliocentric cartesian coords
96  double cosBe, sinBe, cosLe, sinLe;
97  Earth->ecLong().SinCos( sinLe, cosLe );
98  Earth->ecLat().SinCos( sinBe, cosBe );
99 
100  double xe = Earth->rsun() * cosBe * cosLe;
101  double ye = Earth->rsun() * cosBe * sinLe;
102  double ze = Earth->rsun() * sinBe;
103 
104  //convert to geocentric ecliptic coordinates by subtracting Earth's coords:
105  xh -= xe;
106  yh -= ye;
107  zh -= ze;
108  }
109 
110  //the spherical geocentricecliptic coordinates:
111  ELongRad = atan2( yh, xh );
112  double rr = sqrt( xh*xh + yh*yh + zh*zh );
113  ELatRad = atan2( zh, rr );
114 
115  ep.longitude.setRadians( ELongRad );
116  ep.latitude.setRadians( ELatRad );
117  if ( Earth ) setRearth( Earth );
118 
119  EclipticToEquatorial( num->obliquity() );
120  nutate( num );
121  aberrate( num );
122 
123  return true;
124 }
125 
126 void KSAsteroid::findMagnitude(const KSNumbers*)
127 {
128  double param = 5 * log10(rsun() * rearth() );
129  double phase_rad = phase().radians();
130  double phi1 = exp( -3.33 * pow( tan( phase_rad / 2 ), 0.63 ) );
131  double phi2 = exp( -1.87 * pow( tan( phase_rad / 2 ), 1.22 ) );
132 
133  setMag( H + param - 2.5 * log( (1 - G) * phi1 + G * phi2 ) );
134 }
135 
136 void KSAsteroid::setPerihelion( double perihelion )
137 {
138  q = perihelion;
139 }
140 
141 void KSAsteroid::setEarthMOID( double earth_moid )
142 {
143  EarthMOID = earth_moid;
144 }
145 
146 void KSAsteroid::setAlbedo( float albedo )
147 {
148  Albedo = albedo;
149 }
150 
151 void KSAsteroid::setDiameter( float diam )
152 {
153  Diameter = diam;
154 }
155 
156 void KSAsteroid::setDimensions( QString dim )
157 {
158  Dimensions = dim;
159 }
160 
161 void KSAsteroid::setNEO( bool neo )
162 {
163  NEO = neo;
164 }
165 
166 void KSAsteroid::setOrbitClass( QString orbit_class )
167 {
168  OrbitClass = orbit_class;
169 }
170 
171 void KSAsteroid::setOrbitID( QString orbit_id )
172 {
173  OrbitID = orbit_id;
174 }
175 
176 void KSAsteroid::setPeriod( float per )
177 {
178  Period = per;
179 }
180 
181 void KSAsteroid::setRotationPeriod(float rot_per)
182 {
183  RotationPeriod = rot_per;
184 }
185 
186 //Unused virtual function from KSPlanetBase
187 bool KSAsteroid::loadData() { return false; }
188 
189 SkyObject::UID KSAsteroid::getUID() const
190 {
191  return solarsysUID(UID_SOL_ASTEROID) | catN;
192 }
KSAsteroid::getUID
virtual SkyObject::UID getUID() const
Return UID for object.
Definition: ksasteroid.cpp:189
KSPlanetBase::setRearth
void setRearth(double r)
Set the distance from Earth, in AU.
Definition: ksplanetbase.h:139
SkyPoint::aberrate
void aberrate(const KSNumbers *num)
Determine the effects of aberration for this SkyPoint.
Definition: skypoint.cpp:287
KSAsteroid::setOrbitID
void setOrbitID(QString orbit_id)
Sets the asteroid's orbit solution ID.
Definition: ksasteroid.cpp:171
SkyPoint::nutate
void nutate(const KSNumbers *num)
Determine the effects of nutation for this SkyPoint.
Definition: skypoint.cpp:202
KSAsteroid::setAlbedo
void setAlbedo(float albedo)
Sets the asteroid's albedo.
Definition: ksasteroid.cpp:146
dms::Degrees
const double & Degrees() const
Definition: dms.h:98
KSPlanetBase::setRsun
void setRsun(double r)
Set the solar distance in AU.
Definition: ksplanetbase.h:131
KSAsteroid::setPeriod
void setPeriod(float per)
Sets the asteroid's period.
Definition: ksasteroid.cpp:176
KSAsteroid::setEarthMOID
void setEarthMOID(double earth_moid)
Sets the asteroid's earth minimum orbit intersection distance.
Definition: ksasteroid.cpp:141
EclipticPosition::latitude
dms latitude
Definition: ksplanetbase.h:43
KSAsteroid::setDiameter
void setDiameter(float diam)
Sets the asteroid's diameter.
Definition: ksasteroid.cpp:151
dms.h
KSPlanetBase::ep
EclipticPosition ep
Definition: ksplanetbase.h:238
KSAsteroid::setNEO
void setNEO(bool neo)
Sets if the comet is a near earth object.
Definition: ksasteroid.cpp:161
N
#define N(n)
Definition: RangeConvex.cpp:13
KSAsteroid::setRotationPeriod
void setRotationPeriod(float rot_per)
Sets the asteroid's rotation period.
Definition: ksasteroid.cpp:181
KSPlanetBase::solarsysUID
UID solarsysUID(UID type) const
Compute high 32-bits of UID.
Definition: ksplanetbase.h:210
KSPlanetBase::helEcPos
EclipticPosition helEcPos
Definition: ksplanetbase.h:242
KSAsteroid::loadData
virtual bool loadData()
This is inherited from KSPlanetBase.
Definition: ksasteroid.cpp:187
KSPlanetBase::rsun
double rsun() const
Definition: ksplanetbase.h:126
SkyObject::UID
qint64 UID
Type for Unique object IDenticator.
Definition: skyobject.h:53
KSNumbers::julianDay
long double julianDay() const
Definition: ksnumbers.h:93
KSAsteroid
A subclass of KSPlanetBase that implements asteroids.
Definition: ksasteroid.h:48
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
SkyObject::setType
void setType(int t)
Set the object's type identifier to the argument.
Definition: skyobject.h:171
EclipticPosition::longitude
dms longitude
Definition: ksplanetbase.h:42
KSPlanetBase::ecLat
const dms & ecLat() const
Definition: ksplanetbase.h:94
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
KSPlanetBase::ecLong
const dms & ecLong() const
Definition: ksplanetbase.h:91
KSPlanetBase::rearth
double rearth() const
Definition: ksplanetbase.h:134
PI
#define PI
Definition: satellite.cpp:43
KSAsteroid::clone
virtual KSAsteroid * clone() const
Create copy of object.
Definition: ksasteroid.cpp:36
KSAsteroid::setOrbitClass
void setOrbitClass(QString orbit_class)
Sets the asteroid's orbit class.
Definition: ksasteroid.cpp:166
KSAsteroid::setPerihelion
void setPerihelion(double perihelion)
Sets the asteroid's perihelion distance.
Definition: ksasteroid.cpp:136
KSPlanetBase
A subclass of TrailObject that provides additional information needed for most solar system objects...
Definition: ksplanetbase.h:63
SkyObject::ASTEROID
Definition: skyobject.h:110
KSAsteroid::setDimensions
void setDimensions(QString dim)
Sets the asteroid's dimensions.
Definition: ksasteroid.cpp:156
ksasteroid.h
kstarsdata.h
KSPlanetBase::UID_SOL_ASTEROID
static const UID UID_SOL_ASTEROID
Asteroids.
Definition: ksplanetbase.h:205
KSAsteroid::findGeocentricPosition
virtual bool findGeocentricPosition(const KSNumbers *num, const KSPlanetBase *Earth=NULL)
Calculate the geocentric RA, Dec coordinates of the Asteroid.
Definition: ksasteroid.cpp:41
KSAsteroid::KSAsteroid
KSAsteroid(int catN, const QString &s, const QString &image_file, long double JD, double a, double e, dms i, dms w, dms N, dms M, double H, double G)
Constructor.
Definition: ksasteroid.cpp:26
KSPlanetBase::phase
dms phase()
Definition: ksplanetbase.h:187
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