[Kstars-devel] KDE/kdeedu/kstars/kstars
Akarsh Simha
akarshsimha at gmail.com
Wed Jul 22 19:39:32 CEST 2009
SVN commit 1001218 by asimha:
Adding some TODOs and some comments on KSAlmanac
CCMAIL: kstars-devel at kde.org, prakash.mohan at kdemail.net
M +8 -19 ksalmanac.cpp
M +81 -27 ksalmanac.h
--- trunk/KDE/kdeedu/kstars/kstars/ksalmanac.cpp #1001217:1001218
@@ -46,13 +46,13 @@
m_Moon = new KSMoon;
SunRise=SunSet=MoonRise=MoonSet=0;
update();
- riseRate = 4.0/ m_Sun->dec()->cos()/14400.0;
}
void KSAlmanac::update() {
RiseSetTime( m_Sun, &SunRise, &SunSet, &SunRiseT, &SunSetT );
RiseSetTime( m_Moon, &MoonRise, &MoonSet, &MoonRiseT, &MoonSetT );
}
+
void KSAlmanac::RiseSetTime( SkyObject *o, double *riseTime, double *setTime, QTime *RiseTime, QTime *SetTime ) {
//Compute Sun rise and set times
const KStarsDateTime today = dt;
@@ -95,22 +95,11 @@
update();
}
-/*TODO This way calculated twilights are longer than real. Moreover solution always
-exists even if sun never goes below 6/12/18 degrees.
-Right way to do this is to find when Sun goes above/below -6/12/18 deg. as done
-in SkyObject::riseSetTime.
- */
-double KSAlmanac::getAstroTwilight( bool begin ) {
- if(begin) return ( SunRise - 18 * riseRate );
- return ( SunSet + 18 * riseRate );
-}
-
-double KSAlmanac::getNauticalTwilight( bool begin ) {
- if(begin) return ( SunRise - 12 * riseRate );
- return ( SunSet + 12 * riseRate );
+/*
+double KSAlmanac::sunZenithAngleToTime( double z ) {
+ double HA = acos( ( cos( z * dms::DegToRad ) - m_Sun->dec()->sin() * geo->lat()->sin() ) / (m_Sun->dec()->cos() * geo->lat()->cos()) );
+ double HASunset = acos( ( -m_Sun->dec()->sin() * geo->lat()->sin() ) / (m_Sun->dec()->cos() * geo->lat()->cos()) );
+ return SunSet + ( HA - HASunset ) * 4.0 * 15.0; // Assumes SunSet is in minutes!! TODO: Fix otherwise
}
-
-double KSAlmanac::getCivilTwilight( bool begin ) {
- if(begin) return ( SunRise - 6 * riseRate );
- return ( SunSet + 6 * riseRate );
-}
+*/
+
--- trunk/KDE/kdeedu/kstars/kstars/ksalmanac.h #1001217:1001218
@@ -25,35 +25,89 @@
#include "kstars.h"
#include "kstarsdatetime.h"
#include "kstarsdata.h"
+
+/**
+ *@class KSAlmanac
+ *
+ *A class that implements methods to find sun rise, sun set, twilight
+ *begin / end times, moon rise and moon set times.
+ *
+ *@short Implement methods to find important times in a day
+ *@author Prakash Mohan
+ *@version 1.0
+ */
+
+// TODO: Fix the documentation for these methods
+
class KSAlmanac {
- public:
- void RiseSetTime( SkyObject *o, double *riseTime, double *setTime, QTime *RiseTime, QTime *SetTime );
- void setDate( KStarsDateTime *newdt );
- void setLocation( GeoLocation *m_geo );
- static KSAlmanac* Instance();
- inline double getSunRise() { return SunRise; }
- inline double getSunSet() { return SunSet; }
- inline double getMoonRise() { return MoonRise; }
- inline double getMoonSet() { return MoonSet; }
- inline QTime sunRise() { return SunRiseT; }
- inline QTime sunSet() { return SunSetT; }
- inline QTime moonRise() { return MoonRiseT; }
- inline QTime moonSet() { return MoonSetT; }
- double getAstroTwilight( bool begin = true );
- double getNauticalTwilight( bool begin = true );
- double getCivilTwilight( bool begin = true );
+ public:
+ /**
+ * ??? I have absolutely no clue what this method does and why it takes a SkyObject at all - Akarsh
+ */
+ void RiseSetTime( SkyObject *o, double *riseTime, double *setTime, QTime *RiseTime, QTime *SetTime );
- private:
- KSAlmanac();
- void update();
- static KSAlmanac *pinstance;
- KSSun *m_Sun;
- KSMoon *m_Moon;
- KStars *ks;
- KStarsDateTime dt;
- GeoLocation *geo;
- double SunRise, SunSet, MoonRise, MoonSet, riseRate;
- QTime SunRiseT, SunSetT, MoonRiseT, MoonSetT;
+ /**
+ *@short Set the date for computations to the given date
+ *@param The new date to set as a KStarsDateTime
+ */
+ void setDate( KStarsDateTime *newdt );
+
+ /**
+ *@short Set the location for computations to the given location
+ *@param The location to set for computations
+ */
+ void setLocation( GeoLocation *m_geo );
+
+ /**
+ *@short Returns an instance of this class
+ * TODO: Re-implement as a multiple-instance class
+ */
+ static KSAlmanac* Instance();
+
+ /**
+ *??? in what units does this return?
+ */
+ inline double getSunRise() { return SunRise; }
+
+ /**
+ *??? in what units does this return?
+ */
+ inline double getSunSet() { return SunSet; }
+
+ /**
+ *??? in what units does this return?
+ */
+ inline double getMoonRise() { return MoonRise; }
+
+ /**
+ *??? in what units does this return?
+ */
+ inline double getMoonSet() { return MoonSet; }
+
+ inline QTime sunRise() { return SunRiseT; }
+ inline QTime sunSet() { return SunSetT; }
+ inline QTime moonRise() { return MoonRiseT; }
+ inline QTime moonSet() { return MoonSetT; }
+
+
+ double getAstroTwilight( bool begin = true );
+ double getNauticalTwilight( bool begin = true );
+ double getCivilTwilight( bool begin = true );
+
+ private:
+ // TODO: Add documentation
+ KSAlmanac();
+ void update();
+
+ static KSAlmanac *pinstance;
+ KSSun *m_Sun;
+ KSMoon *m_Moon;
+ KStars *ks;
+ KStarsDateTime dt;
+
+ GeoLocation *geo;
+ double SunRise, SunSet, MoonRise, MoonSet;
+ QTime SunRiseT, SunSetT, MoonRiseT, MoonSetT;
};
#endif
More information about the Kstars-devel
mailing list