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

Jason Harris kstars at 30doradus.org
Wed Mar 21 18:31:45 CET 2007


SVN commit 645106 by harris:

Fixing bug #139676.  There was a bug in the calculation of a planet's 
phase angle, which resulted in nonsense magnitudes (most obviously in 
Mars).  For the Sun, the apparent magnitude was never set, so it 
displayed 0.0 instead of the true value of -26.73.

I will forward-port to trunk as well.

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



 M  +12 -10    ksplanetbase.cpp  
 M  +1 -0      kssun.cpp  


--- branches/KDE/3.5/kdeedu/kstars/kstars/ksplanetbase.cpp #645105:645106
@@ -202,10 +202,11 @@
 	double cosDec, sinDec;
 	dec()->SinCos(cosDec, sinDec);
 	
-	//JH: Fixing calculation of phase. Using formula from 
-	//"Practical Astronomy With Your Calculator":
-	double d = ecLong()->radians() - helEcLong()->radians();
-	double f1 = 0.5*( 1 + cos( d ) );
+	/* Phase of the planet in degrees */
+	double earthSun = 1.;
+	double cosPhase = (rsun()*rsun() + rearth()*rearth() - earthSun*earthSun) 
+	  / (2 * rsun() * rearth() );   
+	double phase = acos ( cosPhase ) * 180.0 / dms::PI;
 
 	/* Computation of the visual magnitude (V band) of the planet.
 	* Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional)
@@ -216,17 +217,18 @@
 	float magnitude = 30;
 
 	double param = 5 * log10(rsun() * rearth() );
+	double f1 = phase/100.;
 
 	if ( name() == "Mercury" ) {
-		if ( f1 > 1.5 ) f1 = 1.5; //JH: but this will never be true
+		if ( phase > 150. ) f1 = 1.5; 
 		magnitude = -0.36 + param + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1;
 	}
 	if ( name() =="Venus")
 		magnitude = -4.29 + param + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1*f1;
 	if( name() == "Mars")
-		magnitude = -1.52 + param + 16.*f1;  //JH: was + 0.016*phase;
+		magnitude = -1.52 + param + 0.016*phase; 
 	if( name() == "Jupiter") 
-		magnitude = -9.25 + param + 0.5*f1;  //JH: was + 0.005*phase;
+		magnitude = -9.25 + param + 0.005*phase;  
 
 	if( name() == "Saturn") {
 		double T = num->julianCenturies();
@@ -235,15 +237,15 @@
 		double sinx = -cos(d0)*cosDec*cos(a0 - ra()->radians());
 		sinx = fabs(sinx-sin(d0)*sinDec);
 		double rings = -2.6*sinx + 1.25*sinx*sinx;
-		magnitude = -8.88 + param + 4.4*f1 + rings;  //JH: was  + 0.044*phase + rings
+		magnitude = -8.88 + param + 0.044*phase + rings;  
 	}
 
 	if( name() == "Uranus")
-		magnitude = -7.19 + param + 0.28*f1;  //JH: was 0.0028*phase;
+		magnitude = -7.19 + param + 0.0028*phase;  
 	if( name() == "Neptune")
 		magnitude = -6.87 + param;
 	if( name() == "Pluto" )
-		magnitude = -1.01 + param + 4.1*f1;  //JH: was 0.041*phase;
+		magnitude = -1.01 + param + 0.041*phase;
 
 	setMag(magnitude);
 }
--- branches/KDE/3.5/kdeedu/kstars/kstars/kssun.cpp #645105:645106
@@ -30,6 +30,7 @@
 	plong0 = 282.768422; //longitude of sun at perigee for JD0
 	e0 = 0.016713; //eccentricity of Earth's orbit at JD0
 	*/
+	setMag( -26.73 );
 }
 
 bool KSSun::loadData() {


More information about the Kstars-devel mailing list