[Kstars-devel] KDE/kdeedu/kstars/kstars
Akarsh Simha
akarshsimha at gmail.com
Sat Mar 21 21:54:53 CET 2009
SVN commit 942491 by asimha:
+ Make the phase angle a member of KSPlanetBase, along with methods to
access and compute it
+ Incorporate backends to calculate comet tail lengths. These will not
be accurate, however, till we sort out the issue with comet
distances.
CCMAIL: kstars-devel at kde.org
M +2 -0 skycomponents/cometscomponent.cpp
M +1 -1 skycomponents/solarsystemcomposite.cpp
M +1 -1 skyobjects/kscomet.cpp
M +17 -2 skyobjects/kscomet.h
M +6 -6 skyobjects/ksmoon.cpp
M +6 -11 skyobjects/ksmoon.h
M +31 -9 skyobjects/ksplanetbase.cpp
M +11 -0 skyobjects/ksplanetbase.h
M +1 -1 tools/modcalcdaylength.cpp
M +2 -2 tools/wutdialog.cpp
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/cometscomponent.cpp #942490:942491
@@ -119,6 +119,8 @@
psky.drawEllipse( QRectF( x1, y1, size, size ) );
}
+ float tailsize = com->getTailAngSize().Degrees() * map->scale() * dms::PI * Options::zoomFactor()/10800.0;
+
if ( hideLabels || com->rsun() >= rsunLabelLimit ) continue;
SkyLabeler::AddLabel( o, com, SkyLabeler::COMET_LABEL );
}
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/solarsystemcomposite.cpp #942490:942491
@@ -115,7 +115,7 @@
m_Sun->findPosition( num );
m_Moon->findPosition( num, data->geo()->lat(), data->lst() );
- m_Moon->findPhase( m_Sun );
+ m_Moon->findPhase();
m_JupiterMoons->updateMoons( data, num );
}
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/kscomet.cpp #942490:942491
@@ -93,7 +93,7 @@
D0 = pow( 10, -0.0033 * mHelio * mHelio - 0.07 * mHelio + 3.25 );
L = L0 * ( 1 - pow( 10, -4 * rsun() ) ) * ( 1 - pow( 10, -2 * rsun() ) );
D = D0 * ( 1 - pow( 10, -2 * rsun() ) ) * ( 1 - pow( 10, -rsun() ) );
- TailLength = L * 1e6;
+ TailSize = L * 1e6;
ComaSize = D * 1e3;
setPhysicalSize( ComaSize );
}
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/kscomet.h #942490:942491
@@ -112,11 +112,26 @@
inline float getAbsoluteMagnitude() { return H; }
/**
+ *@short Sets the comet's tail length in km
+ */
+ void setTailSize( double tailsize ) { TailSize = tailsize; }
+
+ /**
*@return the estimated tail length in km
*/
- inline float getTailLength() { return TailLength; }
+ inline float getTailSize() { return TailSize; }
/**
+ *@short Sets the comet's apparent tail length in degrees
+ */
+ void setTailAngSize( double tailangsize ) { TailAngSize = tailangsize; }
+
+ /**
+ *@return the estimated angular size of the tail as a dms
+ */
+ inline dms getTailAngSize() { return dms( TailAngSize ); }
+
+ /**
*@return the estimated diameter of the nucleus in km
*/
inline float getNuclearSize() { return NuclearSize; }
@@ -142,7 +157,7 @@
KStarsData *kd;
long double JD, JDp;
double q, e, a, P;
- double TailLength, ComaSize, NuclearSize; // All in kilometres
+ double TailSize, TailAngSize, ComaSize, NuclearSize; // All in kilometres
float H, G;
dms i, w, N;
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksmoon.cpp #942490:942491
@@ -208,11 +208,11 @@
return true;
}
-
-void KSMoon::findPhase( const KSSun *Sun ) {
- Phase.setD( ecLong()->Degrees() - Sun->ecLong()->Degrees() );
- Phase.setD( Phase.reduce().Degrees() );
- int iPhase = int( 0.1*Phase.Degrees()+0.5 );
+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();
+ double DegPhase = dms( Phase ).reduce().Degrees();
+ int iPhase = int( 0.1*DegPhase+0.5 );
if (iPhase==36) iPhase = 0;
QString sPhase;
sPhase = sPhase.sprintf( "%02d", iPhase );
@@ -228,7 +228,7 @@
QString KSMoon::phaseName() const {
double f = illum();
- double p = phase().Degrees();
+ double p = Phase;
//First, handle the major phases
if ( f > 0.99 ) return i18nc( "moon phase, 100 percent illuminated", "Full moon" );
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksmoon.h #942490:942491
@@ -45,24 +45,20 @@
~KSMoon();
/**
- *Determine the phase angle of the moon, and assign the appropriate
- *moon image
- *@param Sun The current Sun object.
- */
- void findPhase( const KSSun *Sun );
+ *Determine the phase angle of the moon, and assign the appropriate
+ *moon image
+ *@note Overrides KSPlanetBase::findPhase()
+ */
+ void findPhase();
/**
*@short Compute the magnitude of the moon
*/
void findMagnitude(const KSNumbers *num);
- /**@return the moon's current phase angle, as a dms angle
- */
- dms phase( void ) const { return Phase; }
-
/**@return the illuminated fraction of the Moon as seen from Earth
*/
- double illum( void ) const { return 0.5*(1.0 - cos( phase().radians() ) ); }
+ double illum( void ) const { return 0.5*(1.0 - cos( Phase * 180.0 / dms::PI ) ); }
/**@return a short string describing the moon's phase
*/
@@ -106,7 +102,6 @@
virtual bool findGeocentricPosition( const KSNumbers *num, const KSPlanetBase* );
private:
- dms Phase;
static bool data_loaded;
static int instance_count;
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksplanetbase.cpp #942490:942491
@@ -131,7 +131,14 @@
}
void KSPlanetBase::findPosition( const KSNumbers *num, const dms *lat, const dms *LST, const KSPlanetBase *Earth ) {
+ // DEBUG edit
findGeocentricPosition( num, Earth ); //private function, reimplemented in each subclass
+ if( type() == SkyObject::MOON ) { // Required till we make KSSun singleton and re-implement KSPlanetBase::findPhase()
+ KSMoon *me = (KSMoon *)this;
+ me->findPhase(); // Find the phase.
+ }
+ else
+ findPhase();
setAngularSize( asin(physicalSize()/Rearth/AU_KM)*60.*180./dms::PI ); //angular size in arcmin
if ( lat && LST )
@@ -144,6 +151,15 @@
if ( isMajorPlanet() || type() == SkyObject::ASTEROID || type() == SkyObject::COMET || type() == SkyObject::MOON )
findMagnitude(num);
+
+ if ( type() == SkyObject::COMET ) {
+ // Compute tail size
+ KSComet *me = (KSComet *)this;
+ double TailAngSize;
+ TailAngSize = asin(physicalSize()/Rearth/AU_KM)*60.0*180.0/dms::PI; // Convert the tail size in km to angular tail size (degrees)
+ me->setTailAngSize( TailAngSize * fabs(sin( phase().radians() ))); // Find the apparent length as projected on the celestial sphere (the comet's tail points away from the sun)
+ }
+
}
bool KSPlanetBase::isMajorPlanet() const {
@@ -289,17 +305,22 @@
Image = Image0.transformed( m ).scaledToWidth( int(size) );
}
+void KSPlanetBase::findPhase() {
+ /* Compute the phase of the planet in degrees */
+ double earthSun = KStarsData::Instance()->skyComposite()->earth()->rsun();
+ double cosPhase = (rsun()*rsun() + rearth()*rearth() - earthSun*earthSun)
+ / (2 * rsun() * rearth() );
+ Phase = acos ( cosPhase ) * 180.0 / dms::PI;
+ /* More elegant way of doing it, but requires the Sun.
+ TODO: Switch to this if and when we make KSSun a singleton */
+ // Phase = ecLong()->Degrees() - Sun->ecLong()->Degrees();
+}
+
+
void KSPlanetBase::findMagnitude(const KSNumbers *num) {
double cosDec, sinDec;
dec()->SinCos(cosDec, sinDec);
- /* Phase of the planet in degrees */
- double earthSun = data->skyComposite()->earth()->rsun();
- double cosPhase = (rsun()*rsun() + rearth()*rearth() - earthSun*earthSun)
- / (2 * rsun() * rearth() );
- 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)
* It has some simmilarity to J. Meeus algorithm in Astronomical Algorithms, Chapter 40.
@@ -309,14 +330,15 @@
float magnitude = 30;
double param = 5 * log10(rsun() * rearth() );
+ double phase_rad = phase().radians();
+ double phase = this->phase().Degrees();
double f1 = phase/100.;
if( name() == "Moon" ) {
// This block of code to compute Moon magnitude (and the
// relevant data put into ksplanetbase.h) was taken from
// SkyChart v3 Beta
- KSMoon *me = (KSMoon *)this;
- int p = (int)( floor( me->phase().Degrees() ) );
+ int p = (int)( floor( phase ) );
if( p > 180 )
p = p - 360;
int i = p / 10;
--- trunk/KDE/kdeedu/kstars/kstars/skyobjects/ksplanetbase.h #942490:942491
@@ -264,6 +264,11 @@
void setPhysicalSize( double size ) { PhysicalSize = size; }
/**
+ *@return the phase angle of this planet
+ */
+ inline dms phase() { return dms( Phase ); }
+
+ /**
*@return the color for the planet symbol
*/
QColor& color() { return m_Color; }
@@ -313,6 +318,11 @@
*/
void findPA( const KSNumbers *num );
+ /**
+ * Determine the phase of the planet.
+ */
+ void findPhase();
+
// Geocentric ecliptic position, but distance to the Sun
EclipticPosition ep;
@@ -320,6 +330,7 @@
// as obtained from VSOP.
EclipticPosition helEcPos;
double Rearth;
+ double Phase;
private:
/**
--- trunk/KDE/kdeedu/kstars/kstars/tools/modcalcdaylength.cpp #942490:942491
@@ -162,7 +162,7 @@
//Moon
KSMoon *Moon = new KSMoon( ((KStars*) topLevelWidget()->parent())->data() );
Moon->findPosition(num);
- Moon->findPhase(Sun);
+ Moon->findPhase();
QTime msTime = Moon->riseSetTime( jd0 , geo, false );
QTime mrTime = Moon->riseSetTime( jd0 , geo, true );
--- trunk/KDE/kdeedu/kstars/kstars/tools/wutdialog.cpp #942490:942491
@@ -192,14 +192,14 @@
WUT->MoonRiseLabel->setText( i18n( "Moon rises at: %1 on %2", sRise, KGlobal::locale()->formatDate( Evening.date(), KLocale::LongDate) ) );
WUT->MoonSetLabel->setText( i18n( "Moon sets at: %1 on %2", sSet, KGlobal::locale()->formatDate( Tomorrow.date(), KLocale::LongDate) ) );
- oMoon->findPhase( oSun );
+ oMoon->findPhase();
WUT->MoonIllumLabel->setText( oMoon->phaseName() + QString( " (%1%)" ).arg(
int(100.0*oMoon->illum() ) ) );
//Restore Sun's and Moon's coordinates, and recompute Moon's original Phase
oMoon->updateCoords( oldNum, true, geo->lat(), kstars->LST() );
oSun->updateCoords( oldNum, true, geo->lat(), kstars->LST() );
- oMoon->findPhase( oSun );
+ oMoon->findPhase();
if ( WUT->CategoryListWidget->currentItem() )
slotLoadList( WUT->CategoryListWidget->currentItem()->text() );
More information about the Kstars-devel
mailing list