[Kstars-devel] KDE/kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Fri Dec 21 22:53:45 CET 2007


SVN commit 751453 by harris:

Applying Akarsh's patch to fix calculation of asteroid magnitudes.
I only changed "10" to "SkyObject::ASTEROID" where appropriate.

In testing the magnitudes, I found that the KStars values are always 
fainter than the published NASA values (at ssd.jpl.nasa.gov) by a few 
tenths of a magnitude.  I believe this is because the geocentric 
distance computed by kstars is larger than the NASA values.  I'll have 
to look into why that is happening.

CCMAIL: kstars-devel at kde.org



 M  +10 -2     ksasteroid.cpp  
 M  +29 -2     ksasteroid.h  
 M  +16 -2     ksplanetbase.cpp  
 M  +0 -2      ksplanetbase.h  
 M  +3 -2      skycomponents/asteroidscomponent.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/ksasteroid.cpp #751452:751453
@@ -26,10 +26,17 @@
 
 KSAsteroid::KSAsteroid( KStarsData *_kd, const QString &s, const QString &imfile,
                         long double _JD, double _a, double _e, dms _i, dms _w, dms _Node, dms _M, double _H )
-        : KSPlanetBase(_kd, s, imfile), kd(_kd), JD(_JD), a(_a), e(_e), H(_H), i(_i), w(_w), M(_M), N(_Node) {
+	: KSPlanetBase(_kd, s, imfile), kd(_kd), JD(_JD), a(_a), e(_e), H(_H), i(_i), w(_w), M(_M), N(_Node) {
+    KSAsteroid(_kd, s, imfile, _JD, _a, _e, _i, _w, _Node, _M, _H, -1); // Set G to -1 - G can never be negative in reality.
+}
 
+KSAsteroid::KSAsteroid( KStarsData *_kd, const QString &s, const QString &imfile,
+                        long double _JD, double _a, double _e, dms _i, dms _w, dms _Node, dms _M, double _H, double _G )
+        : KSPlanetBase(_kd, s, imfile), kd(_kd), JD(_JD), a(_a), e(_e), H(_H), G(_G), i(_i), w(_w), M(_M), N(_Node) {
+
     setType( 10 ); //Asteroid
-    setMag( H );
+    this -> H = H;
+    this -> G = G;
     //Compute the orbital Period from Kepler's 3rd law:
     P = 365.2568984 * pow(a, 1.5); //period in days
 }
@@ -122,6 +129,7 @@
     return true;
 }
 
+
 //Unused virtual function from KSPlanetBase
 bool KSAsteroid::loadData() { return false; }
 
--- trunk/KDE/kdeedu/kstars/kstars/ksasteroid.h #751452:751453
@@ -36,6 +36,7 @@
 	*@li N     longitude of ascending node (J2000.0 ecliptic)
 	*@li M     mean anomaly at epoch JD
 	*@li H     absolute magnitude
+	*@li G     slope parameter
 	*
 	*@author Jason Harris
 	*@version 1.0
@@ -48,7 +49,9 @@
 class KSAsteroid : public KSPlanetBase
 {
 public:
+
     /**Constructor.
+	*@note For use by KSPluto, which inherits from this class. Sets the slope parameter to -1.
     	*@p kd pointer to the KStarsData object
     	*@p s the name of the asteroid
     	*@p image_file the filename for an image of the asteroid
@@ -62,7 +65,23 @@
     	*@p H absolute magnitude
     	*/
     KSAsteroid( KStarsData *kd, const QString &s, const QString &image_file,
-                long double JD, double a, double e, dms i, dms w, dms N, dms M, double H );
+                long double JD, double a, double e, dms i, dms w, dms N, dms M, double H);
+    /**Constructor.
+    	*@p kd pointer to the KStarsData object
+    	*@p s the name of the asteroid
+    	*@p image_file the filename for an image of the asteroid
+    	*@p JD the Julian Day for the orbital elements
+    	*@p a the semi-major axis of the asteroid's orbit (AU)
+    	*@p e the eccentricity of the asteroid's orbit
+    	*@p i the inclination angle of the asteroid's orbit
+    	*@p w the argument of the orbit's perihelion
+    	*@p N the longitude of the orbit's ascending node
+    	*@p M the mean anomaly for the Julian Day
+    	*@p H absolute magnitude
+	*@p G slope parameter
+    	*/
+    KSAsteroid( KStarsData *kd, 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 );
 
     /**Destructor (empty)*/
     virtual ~KSAsteroid() {}
@@ -72,6 +91,13 @@
     	*/
     virtual bool loadData();
 
+    /**This lets other classes like KSPlanetBase access H and G values
+	*Used by KSPlanetBase::FindMagnitude
+	*/
+    double inline getAbsoluteMagnitude() { return H; }
+    double inline getSlopeParameter() { return G; }
+   
+
 protected:
     /**Calculate the geocentric RA, Dec coordinates of the Asteroid.
     	*@note reimplemented from KSPlanetBase
@@ -94,8 +120,9 @@
 private:
     KStarsData *kd;
     long double JD;
-    double a, e, H, P;
+    double a, e, P;
     dms i, w, M, N;
+    double H, G;
 };
 
 #endif
--- trunk/KDE/kdeedu/kstars/kstars/ksplanetbase.cpp #751452:751453
@@ -29,6 +29,7 @@
 #include "ksnumbers.h"
 #include "Options.h"
 #include "skymap.h"
+#include "ksasteroid.h"
 
 KSPlanetBase::KSPlanetBase( KStarsData *kd, const QString &s, 		const QString &image_file, const QColor &c, double pSize )
         : TrailObject( 2, 0.0, 0.0, 0.0, s ),
@@ -84,7 +85,7 @@
         if ( Trail.size() > MAXTRAIL ) Trail.takeFirst();
     }
 
-    if ( isMajorPlanet() )
+    if ( isMajorPlanet() || type() == SkyObject::ASTEROID )
         findMagnitude(num);
 }
 
@@ -239,7 +240,8 @@
     double earthSun = 1.;
     double cosPhase = (rsun()*rsun() + rearth()*rearth() - earthSun*earthSun)
                       / (2 * rsun() * rearth() );
-    double phase = acos ( cosPhase ) * 180.0 / dms::PI;
+    double phase_rad = acos ( cosPhase ); // Phase in radian - used for asteroid magnitudes
+    double phase = phase_rad * 180.0 / dms::PI;
 
     /* Computation of the visual magnitude (V band) of the planet.
     * Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional)
@@ -280,5 +282,17 @@
     if( name() == "Pluto" )
         magnitude = -1.01 + param + 0.041*phase;
 
+    if( type() == SkyObject::ASTEROID ) {
+        // Asteroid
+        KSAsteroid *me = (KSAsteroid *)this;
+        double phi1 = exp( -3.33 * pow(tan(phase_rad/2), 0.63) );
+        double phi2 = exp( -1.87 * pow(tan(phase_rad/2), 1.22) );
+        double H, G;
+        H = me -> getAbsoluteMagnitude();
+        G = me -> getSlopeParameter();
+        magnitude = H + param - 2.5 * log10( (1 - G) * phi1 + G * phi2 );
+    }
+    
     setMag(magnitude);
 }
+
--- trunk/KDE/kdeedu/kstars/kstars/ksplanetbase.h #751452:751453
@@ -324,8 +324,6 @@
      *@short Computes the visual magnitude for the major planets.
      *@param num pointer to a ksnumbers object. Needed for the saturn rings contribution to 
      *           saturn's magnitude.
-     *@param Earth pointer to an Earth object. Needed to know the distance between the Earth and the
-     *             Sun.
      */
     void findMagnitude(const KSNumbers *num);
 
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/asteroidscomponent.cpp #751452:751453
@@ -51,7 +51,7 @@
 
     QString line, name;
     int mJD;
-    double a, e, dble_i, dble_w, dble_N, dble_M, H;
+    double a, e, dble_i, dble_w, dble_N, dble_M, H, G;
     long double JD;
 
     KSFileReader fileReader;
@@ -72,11 +72,12 @@
         dble_N = line.mid( 72, 9 ).toDouble();
         dble_M = line.mid( 82, 11 ).toDouble();
         H = line.mid( 94, 5 ).toDouble();
+		G = line.mid( 102, 4 ).toDouble();
 
         JD = double( mJD ) + 2400000.5;
 
         ast = new KSAsteroid( data, name, QString(), JD, a, e, dms(dble_i),
-                              dms(dble_w), dms(dble_N), dms(dble_M), H );
+                              dms(dble_w), dms(dble_N), dms(dble_M), H, G );
         ast->setAngularSize( 0.005 );
         objectList().append( ast );
 


More information about the Kstars-devel mailing list