summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-25 08:42:43 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-28 22:16:22 (GMT)
commit13ac9e9eaadf61845fe54c13ba72fa23c01ddb56 (patch)
treea4ee3163e06d2c441f371dce96208c8a238f7d3b
parent5a9c6a424624b50fb071e171508cda5e4d565bab (diff)
Change LST and latitude to CachingDms -- this saves a lot of trig calls!
Test case: ========== Simulation clock running at 1s per step, centered around USNO NOMAD milky way artifact patch at the center of milky way, specifically on Globular Cluster NGC 6569 at Zoom Factor of 32000. Using Horizontal Coordinates. Projection = 3. Results: ======== Before: ------- For the USNO NOMAD catalog under these conditions, DeepStarComponent::draw spent ~ 0.25s doing ~2233550 trigonometric function calls per draw ( presumably without updateCoords() being called -- we call updateCoords only if there's a time slew of more than 1 solar minute; see StarObject::JITUpdate() ) After: ------ After the change, DSC::draw() spent only ~ 0.18s doing only ~1489260 trigonometric function calls. Note: A call to sincos() is considered to be 2 trigonometric calls.
-rw-r--r--kstars/ekos/scheduler.cpp8
-rw-r--r--kstars/ksalmanac.cpp6
-rw-r--r--kstars/skyobjects/ksplanetbase.cpp6
-rw-r--r--kstars/skyobjects/ksplanetbase.h6
-rw-r--r--kstars/skyobjects/skyobject.cpp2
-rw-r--r--kstars/skyobjects/skypoint.cpp8
-rw-r--r--kstars/skyobjects/skypoint.h7
-rw-r--r--kstars/skyobjects/starobject.cpp2
-rw-r--r--kstars/skyobjects/starobject.h2
-rw-r--r--kstars/tools/altvstime.cpp6
-rw-r--r--kstars/tools/ksconjunct.cpp2
-rw-r--r--kstars/tools/modcalcplanets.cpp10
-rw-r--r--kstars/tools/observinglist.cpp2
-rw-r--r--kstars/tools/wutdialog.cpp2
14 files changed, 39 insertions, 30 deletions
diff --git a/kstars/ekos/scheduler.cpp b/kstars/ekos/scheduler.cpp
index 9840835..9211f23 100644
--- a/kstars/ekos/scheduler.cpp
+++ b/kstars/ekos/scheduler.cpp
@@ -1462,7 +1462,7 @@ double Scheduler::findAltitude(const SkyPoint & target, const QDateTime when)
KStarsDateTime myUT = ut.addSecs(when.time().msecsSinceStartOfDay()/1000);
- dms LST = KStarsData::Instance()->geo()->GSTtoLST( myUT.gst() );
+ CachingDms LST = KStarsData::Instance()->geo()->GSTtoLST( myUT.gst() );
p.EquatorialToHorizontal( &LST, KStarsData::Instance()->geo()->lat() );
return p.alt().Degrees();
@@ -1490,7 +1490,7 @@ bool Scheduler::calculateAltitudeTime(SchedulerJob *job, double minAltitude, dou
if (rawFrac < Dawn || rawFrac > Dusk)
{
- dms LST = geo->GSTtoLST( myUT.gst() );
+ CachingDms LST = geo->GSTtoLST( myUT.gst() );
target.EquatorialToHorizontal( &LST, geo->lat() );
altitude = target.alt().Degrees();
@@ -1761,7 +1761,7 @@ double Scheduler::getCurrentMoonSeparation(SchedulerJob *job)
QDateTime midnight( KStarsData::Instance()->lt().date(), QTime() );
KStarsDateTime ut = geo->LTtoUT( midnight );
KStarsDateTime myUT = ut.addSecs(KStarsData::Instance()->lt().time().msecsSinceStartOfDay()/1000);
- dms LST = geo->GSTtoLST( myUT.gst() );
+ CachingDms LST = geo->GSTtoLST( myUT.gst() );
p.EquatorialToHorizontal( &LST, geo->lat() );
// Update moon
@@ -1783,7 +1783,7 @@ int16_t Scheduler::getMoonSeparationScore(SchedulerJob *job, QDateTime when)
QDateTime midnight( when.date(), QTime() );
KStarsDateTime ut = geo->LTtoUT( midnight );
KStarsDateTime myUT = ut.addSecs(when.time().msecsSinceStartOfDay()/1000);
- dms LST = geo->GSTtoLST( myUT.gst() );
+ CachingDms LST = geo->GSTtoLST( myUT.gst() );
p.EquatorialToHorizontal( &LST, geo->lat() );
double currentAlt = p.alt().Degrees();
diff --git a/kstars/ksalmanac.cpp b/kstars/ksalmanac.cpp
index 614fd54..bd76cc3 100644
--- a/kstars/ksalmanac.cpp
+++ b/kstars/ksalmanac.cpp
@@ -73,7 +73,7 @@ void KSAlmanac::RiseSetTime( SkyObject *o, double *riseTime, double *setTime, QT
// them back.
KSNumbers num( dt.djd() );
- dms LST = geo->GSTtoLST( dt.gst() );
+ CachingDms LST = geo->GSTtoLST( dt.gst() );
o->updateCoords( &num, true, geo->lat(), &LST, true );
if ( o->checkCircumpolar( geo->lat() ) ) {
if ( o->alt().Degrees() > 0.0 ) {
@@ -96,7 +96,7 @@ void KSAlmanac::findDawnDusk() {
KStarsDateTime today = dt;
KSNumbers num( today.djd() );
- dms LST = geo->GSTtoLST( today.gst() );
+ CachingDms LST = geo->GSTtoLST( today.gst() );
m_Sun.updateCoords( &num, true, geo->lat(), &LST, true ); // We can abuse our own copy of the sun
double dawn, da, dusk, du, max_alt, min_alt;
@@ -140,7 +140,7 @@ void KSAlmanac::findDawnDusk() {
void KSAlmanac::findMoonPhase() {
const KStarsDateTime today = dt;
KSNumbers num( today.djd() );
- dms LST = geo->GSTtoLST( today.gst() );
+ CachingDms LST = geo->GSTtoLST( today.gst() );
m_Sun.updateCoords( &num, true, geo->lat(), &LST, true ); // We can abuse our own copy of the sun and/or moon
m_Moon.updateCoords( &num, true, geo->lat(), &LST, true );
diff --git a/kstars/skyobjects/ksplanetbase.cpp b/kstars/skyobjects/ksplanetbase.cpp
index b186d5e..d9376a2 100644
--- a/kstars/skyobjects/ksplanetbase.cpp
+++ b/kstars/skyobjects/ksplanetbase.cpp
@@ -103,7 +103,7 @@ void KSPlanetBase::EclipticToEquatorial( const dms *Obliquity ) {
setFromEcliptic( Obliquity, ep.longitude, ep.latitude );
}
-void KSPlanetBase::updateCoords( const KSNumbers *num, bool includePlanets, const dms *lat, const dms *LST, bool )
+void KSPlanetBase::updateCoords( const KSNumbers *num, bool includePlanets, const CachingDms *lat, const CachingDms *LST, bool )
{
KStarsData *kd = KStarsData::Instance();
if ( includePlanets ) {
@@ -120,7 +120,7 @@ void KSPlanetBase::updateCoords( const KSNumbers *num, bool includePlanets, cons
}
}
-void KSPlanetBase::findPosition( const KSNumbers *num, const dms *lat, const dms *LST, const KSPlanetBase *Earth ) {
+void KSPlanetBase::findPosition( const KSNumbers *num, const CachingDms *lat, const CachingDms *LST, const KSPlanetBase *Earth ) {
// DEBUG edit
findGeocentricPosition( num, Earth ); //private function, reimplemented in each subclass
findPhase();
@@ -157,7 +157,7 @@ bool KSPlanetBase::isMajorPlanet() const {
return false;
}
-void KSPlanetBase::localizeCoords( const KSNumbers *num, const dms *lat, const dms *LST ) {
+void KSPlanetBase::localizeCoords( const KSNumbers *num, const CachingDms *lat, const CachingDms *LST ) {
//convert geocentric coordinates to local apparent coordinates (topocentric coordinates)
dms HA, HA2; //Hour Angle, before and after correction
double rsinp, rcosp, u, sinHA, cosHA, sinDec, cosDec, D;
diff --git a/kstars/skyobjects/ksplanetbase.h b/kstars/skyobjects/ksplanetbase.h
index 9816707..929993f 100644
--- a/kstars/skyobjects/ksplanetbase.h
+++ b/kstars/skyobjects/ksplanetbase.h
@@ -148,7 +148,7 @@ public:
* @param lat pointer to the geographic latitude; if NULL, we skip localizeCoords()
* @param LST pointer to the local sidereal time; if NULL, we skip localizeCoords()
*/
- virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute = false );
+ virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=0, const CachingDms *LST=0, bool forceRecompute = false );
/** @short Find position, including correction for Figure-of-the-Earth.
* @param num KSNumbers pointer for the target date/time
@@ -156,7 +156,7 @@ public:
* @param LST pointer to the local sidereal time; if NULL, we skip localizeCoords()
* @param Earth pointer to the Earth (not used for the Moon)
*/
- void findPosition( const KSNumbers *num, const dms *lat=0, const dms *LST=0, const KSPlanetBase *Earth = 0 );
+ void findPosition( const KSNumbers *num, const CachingDms *lat=0, const CachingDms *LST=0, const KSPlanetBase *Earth = 0 );
/** @return the Planet's position angle. */
virtual double pa() const { return PositionAngle; }
@@ -253,7 +253,7 @@ private:
* @param lat pointer to the geographic latitude of the location.
* @param LST pointer to the local sidereal time.
*/
- void localizeCoords( const KSNumbers *num, const dms *lat, const dms *LST );
+ void localizeCoords( const KSNumbers *num, const CachingDms *lat, const CachingDms *LST );
double PositionAngle, AngularSize, PhysicalSize;
QColor m_Color;
diff --git a/kstars/skyobjects/skyobject.cpp b/kstars/skyobjects/skyobject.cpp
index c064d47..3efb3b1 100644
--- a/kstars/skyobjects/skyobject.cpp
+++ b/kstars/skyobjects/skyobject.cpp
@@ -323,7 +323,7 @@ SkyPoint SkyObject::recomputeCoords( const KStarsDateTime &dt, const GeoLocation
// the passing of lat and LST
if ( isSolarSystem() && geo ) {
- dms LST = geo->GSTtoLST( dt.gst() );
+ CachingDms LST = geo->GSTtoLST( dt.gst() );
c->updateCoords( &num, true, geo->lat(), &LST );
} else {
c->updateCoords( &num );
diff --git a/kstars/skyobjects/skypoint.cpp b/kstars/skyobjects/skypoint.cpp
index e2f9a93..eede76f 100644
--- a/kstars/skyobjects/skypoint.cpp
+++ b/kstars/skyobjects/skypoint.cpp
@@ -60,6 +60,12 @@ SkyPoint::~SkyPoint(){
}
void SkyPoint::EquatorialToHorizontal( const dms *LST, const dms *lat ) {
+ qDebug() << "NOTE: This EquatorialToHorizontal overload (using dms pointers instead of CachingDms pointers) is deprecated and should be replaced with CachingDms prototype wherever speed is desirable!";
+ CachingDms _LST( *LST ), _lat( *lat );
+ EquatorialToHorizontal( &_LST, &_lat );
+}
+
+void SkyPoint::EquatorialToHorizontal( const CachingDms *LST, const CachingDms *lat ) {
#ifdef PROFILE_COORDINATE_CONVERSION
std::clock_t start = std::clock();
#endif
@@ -356,7 +362,7 @@ void SkyPoint::aberrate(const KSNumbers *num) {
}
// Note: This method is one of the major rate determining factors in how fast the map pans / zooms in or out
-void SkyPoint::updateCoords( const KSNumbers *num, bool /*includePlanets*/, const dms *lat, const dms *LST, bool forceRecompute ) {
+void SkyPoint::updateCoords( const KSNumbers *num, bool /*includePlanets*/, const CachingDms *lat, const CachingDms *LST, bool forceRecompute ) {
//Correct the catalog coordinates for the time-dependent effects
//of precession, nutation and aberration
bool recompute, lens;
diff --git a/kstars/skyobjects/skypoint.h b/kstars/skyobjects/skypoint.h
index b48b673..bdb5343 100644
--- a/kstars/skyobjects/skypoint.h
+++ b/kstars/skyobjects/skypoint.h
@@ -23,7 +23,7 @@
#include <QList>
-#include "dms.h"
+#include "cachingdms.h"
#include "kstarsdatetime.h"
#define PROFILE_COORDINATE_CONVERSION true
@@ -215,6 +215,9 @@ public:
*@param LST pointer to the local sidereal time
*@param lat pointer to the geographic latitude
*/
+ void EquatorialToHorizontal( const CachingDms* LST, const CachingDms* lat );
+
+ // Deprecated method provided for compatibility
void EquatorialToHorizontal( const dms* LST, const dms* lat );
/** Determine the (RA, Dec) coordinates of the
@@ -261,7 +264,7 @@ public:
*@param LST does nothing in this implementation (see KSPlanetBase::updateCoords()).
*@param forceRecompute reapplies precession, nutation and aberration even if the time passed since the last computation is not significant.
*/
- virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute = false );
+ virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=0, const CachingDms *LST=0, bool forceRecompute = false );
/**
* @brief updateCoordsNow Shortcut for updateCoords( const KSNumbers *num, false, NULL, NULL, true)
diff --git a/kstars/skyobjects/starobject.cpp b/kstars/skyobjects/starobject.cpp
index bbc7009..8ec9cbf 100644
--- a/kstars/skyobjects/starobject.cpp
+++ b/kstars/skyobjects/starobject.cpp
@@ -254,7 +254,7 @@ void StarObject::initPopupMenu( KSPopupMenu *pmenu ) {
#endif
}
-void StarObject::updateCoords( const KSNumbers *num, bool , const dms*, const dms*, bool ) {
+void StarObject::updateCoords( const KSNumbers *num, bool , const CachingDms*, const CachingDms*, bool ) {
//Correct for proper motion of stars. Determine RA and Dec offsets.
//Proper motion is given im milliarcsec per year by the pmRA() and pmDec() functions.
//That is numerically identical to the number of arcsec per millenium, so multiply by
diff --git a/kstars/skyobjects/starobject.h b/kstars/skyobjects/starobject.h
index b3bd72c..08a94c1 100644
--- a/kstars/skyobjects/starobject.h
+++ b/kstars/skyobjects/starobject.h
@@ -162,7 +162,7 @@ public:
* @param lat does nothing in this implementation (see KSPlanetBase::updateCoords()).
* @param LST does nothing in this implementation (see KSPlanetBase::updateCoords()).
*/
- virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute = false );
+ virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const CachingDms *lat=0, const CachingDms *LST=0, bool forceRecompute = false );
/** @short fills ra and dec with the coordinates of the star with the proper
* motion correction but without precesion and its friends. It is used
diff --git a/kstars/tools/altvstime.cpp b/kstars/tools/altvstime.cpp
index 77b3e6c..ae583e8 100644
--- a/kstars/tools/altvstime.cpp
+++ b/kstars/tools/altvstime.cpp
@@ -446,7 +446,7 @@ double AltVsTime::findAltitude( SkyPoint *p, double hour ) {
//getDate converts the user-entered local time to UT
KStarsDateTime ut = getDate().addSecs( hour*3600.0 );
- dms LST = geo->GSTtoLST( ut.gst() );
+ CachingDms LST = geo->GSTtoLST( ut.gst() );
p->EquatorialToHorizontal( &LST, geo->lat() );
return p->alt().Degrees();
}
@@ -972,7 +972,7 @@ void AltVsTime::slotUpdateDateLoc() {
KStarsDateTime today = getDate();
KSNumbers *num = new KSNumbers( today.djd() );
KSNumbers *oldNum = 0;
- dms LST = geo->GSTtoLST( today.gst() );
+ CachingDms LST = geo->GSTtoLST( today.gst() );
//First determine time of sunset and sunrise
computeSunRiseSetTimes();
@@ -1278,7 +1278,7 @@ void AltVsTime::setDawnDusk()
{
KStarsDateTime today = getDate();
KSNumbers num( today.djd() );
- dms LST = geo->GSTtoLST( today.gst() );
+ CachingDms LST = geo->GSTtoLST( today.gst() );
KSSun sun;
sun.updateCoords( &num, true, geo->lat(), &LST, true );
diff --git a/kstars/tools/ksconjunct.cpp b/kstars/tools/ksconjunct.cpp
index b0b31e7..bdb12da 100644
--- a/kstars/tools/ksconjunct.cpp
+++ b/kstars/tools/ksconjunct.cpp
@@ -139,7 +139,7 @@ dms KSConjunct::findDistance(long double jd, SkyObject *Object1, KSPlanetBase *O
KSPlanet *m_Earth = new KSPlanet( I18N_NOOP( "Earth" ), QString(), QColor( "white" ), 12756.28 /*diameter in km*/ );
m_Earth -> findPosition( &num );
- dms LST(geoPlace->GSTtoLST(t.gst()));
+ CachingDms LST(geoPlace->GSTtoLST(t.gst()));
KSPlanetBase* p = dynamic_cast<KSPlanetBase*>(Object1);
if( p )
diff --git a/kstars/tools/modcalcplanets.cpp b/kstars/tools/modcalcplanets.cpp
index d780f9a..1a4044b 100644
--- a/kstars/tools/modcalcplanets.cpp
+++ b/kstars/tools/modcalcplanets.cpp
@@ -84,7 +84,7 @@ void modCalcPlanets::slotComputePosition (void)
KStarsDateTime dt = DateTimeBox->dateTime();
long double julianDay = dt.djd();
KSNumbers num( julianDay );
- dms LST( geoPlace->GSTtoLST( dt.gst() ) );
+ CachingDms LST( geoPlace->GSTtoLST( dt.gst() ) );
// Earth
KSPlanet Earth( I18N_NOOP( "Earth" ));
@@ -250,7 +250,7 @@ void modCalcPlanets::processLines( QTextStream &istream )
unsigned int i = 0, nline = 0;
QTime utB;
QDate dtB;
- dms longB, latB, hlongB, hlatB, glongB, glatB, raB, decB, azmB, altB;
+ CachingDms longB, latB, hlongB, hlatB, glongB, glatB, raB, decB, azmB, altB;
double rSunB(0.0), rEarthB(0.0);
//Initialize planet names
@@ -341,7 +341,7 @@ void modCalcPlanets::processLines( QTextStream &istream )
// Read Longitude and write in ostream if corresponds
if (LongCheckBatch->isChecked() ) {
- longB = dms::fromString( fields[i],true);
+ longB = CachingDms::fromString( fields[i],true);
i++;
} else {
longB = LongBoxBatch->createDms(true);
@@ -351,7 +351,7 @@ void modCalcPlanets::processLines( QTextStream &istream )
// Read Latitude
if (LatCheckBatch->isChecked() ) {
- latB = dms::fromString( fields[i], true);
+ latB = CachingDms::fromString( fields[i], true);
i++;
} else {
latB = LatBoxBatch->createDms(true);
@@ -361,7 +361,7 @@ void modCalcPlanets::processLines( QTextStream &istream )
KStarsDateTime edt( dtB, utB );
- dms LST = edt.gst() + longB;
+ CachingDms LST = edt.gst() + longB;
KSNumbers num( edt.djd() );
KSPlanet Earth( I18N_NOOP( "Earth" ));
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp
index 4c14f8a..7a42e8b 100644
--- a/kstars/tools/observinglist.cpp
+++ b/kstars/tools/observinglist.cpp
@@ -282,7 +282,7 @@ void ObservingList::slotAddObject( SkyObject *obj, bool session, bool update ) {
obj->type() == SkyObject::PLANET) && obj->mag() == 0)
{
KSNumbers num( dt.djd() );
- dms LST = geo->GSTtoLST( dt.gst() );
+ CachingDms LST = geo->GSTtoLST( dt.gst() );
obj->updateCoords(&num, true, geo->lat(), &LST, true);
}
diff --git a/kstars/tools/wutdialog.cpp b/kstars/tools/wutdialog.cpp
index 11f48b2..da0c388 100644
--- a/kstars/tools/wutdialog.cpp
+++ b/kstars/tools/wutdialog.cpp
@@ -153,7 +153,7 @@ void WUTDialog::init() {
//check to see if Sun is circumpolar
KSNumbers *num = new KSNumbers( UT0.djd() );
KSNumbers *oldNum = new KSNumbers( data->ut().djd() );
- dms LST = geo->GSTtoLST( T0.gst() );
+ CachingDms LST = geo->GSTtoLST( T0.gst() );
oSun->updateCoords( num, true, geo->lat(), &LST, true );
if ( oSun->checkCircumpolar( geo->lat() ) ) {