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

Akarsh Simha akarshsimha at gmail.com
Tue Oct 6 19:14:36 CEST 2009


SVN commit 1032026 by asimha:

Fixing a bug with the calculation of illuminated fraction of the
moon. The Phase was stored in degrees, but was multiplied by 180 / PI
instead of PI / 180 while converting it into radians!

BUG: 209646
CCMAIL: kstars-devel at kde.org



 M  +2 -2      ksmoon.cpp  
 M  +1 -1      ksmoon.h  


--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksmoon.cpp #1032025:1032026
@@ -231,8 +231,8 @@
 }
 
 void KSMoon::findPhase() {
-    KSSun *Sun = (KSSun*)KStarsData::Instance()->skyComposite()->findByName( "Sun" ); // TODO: Get rid of this ugly thing by making KSSun singleton.
-    Phase = ecLong()->Degrees() - Sun->ecLong()->Degrees();
+    KSSun *Sun = (KSSun*)KStarsData::Instance()->skyComposite()->findByName( "Sun" );
+    Phase = ecLong()->Degrees() - Sun->ecLong()->Degrees(); // Phase is obviously in degrees
     double DegPhase = dms( Phase ).reduce().Degrees();
     int iPhase = int( 0.1*DegPhase+0.5 ) % 36; // iPhase must be in [0,36) range
     QString imName = QString().sprintf("moon%02d.png", iPhase);
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksmoon.h #1032025:1032026
@@ -55,7 +55,7 @@
 
     /**@return the illuminated fraction of the Moon as seen from Earth
     	*/
-    double illum( void ) const { return 0.5*(1.0 - cos( Phase * 180.0 / dms::PI ) ); }
+    double illum( void ) const { return 0.5*(1.0 - cos( Phase * dms::PI / 180.0 ) ); }
 
     /**@return a short string describing the moon's phase
     	*/


More information about the Kstars-devel mailing list