summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-26 06:56:15 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-29 02:20:26 (GMT)
commit5c0232bf4518319350648efdb9e538c15a0209ed (patch)
treecbb0580b55bb21012b931cf82dab63cc42b60e6b
parentb3d5b616ed04dfe48f1c67c49243eab636816735 (diff)
Improve CachingDms use in SkyPoint
1. SkyPoint constructor that uses CachingDms (so the computed sin/cos values are transferred rather than being recomputed) 2. Improve SkyPoint::moveAway()
-rw-r--r--kstars/skyobjects/skypoint.cpp17
-rw-r--r--kstars/skyobjects/skypoint.h8
2 files changed, 16 insertions, 9 deletions
diff --git a/kstars/skyobjects/skypoint.cpp b/kstars/skyobjects/skypoint.cpp
index d6ba764..02d7aa6 100644
--- a/kstars/skyobjects/skypoint.cpp
+++ b/kstars/skyobjects/skypoint.cpp
@@ -266,7 +266,7 @@ void SkyPoint::nutate(const KSNumbers *num) {
}
SkyPoint SkyPoint::moveAway( const SkyPoint &from, double dist ) const {
- dms lat1, dtheta;
+ CachingDms lat1, dtheta;
if( dist == 0.0 ) {
qDebug() << "moveAway called with zero distance!";
@@ -276,19 +276,20 @@ SkyPoint SkyPoint::moveAway( const SkyPoint &from, double dist ) const {
double dst = fabs( dist * dms::DegToRad / 3600.0 ); // In radian
// Compute the bearing angle w.r.t. the RA axis ("latitude")
- dms dRA( ra() - from.ra() );
- dms dDec( dec() - from.dec() );
+ CachingDms dRA( ra() - from.ra() );
+ CachingDms dDec( dec() - from.dec() );
double bearing = atan2( dRA.sin() / dRA.cos(), dDec.sin() ); // Do not use dRA = PI / 2!!
//double bearing = atan2( dDec.radians() , dRA.radians() );
+
double dir0 = (dist >= 0 ) ? bearing : bearing + dms::PI; // in radian
dist = fabs( dist ); // in radian
+ double sinDst = sin( dst ), cosDst = cos( dst );
-
- lat1.setRadians( asin( dec().sin() * cos( dst ) +
- dec().cos() * sin( dst ) * cos( dir0 ) ) );
- dtheta.setRadians( atan2( sin( dir0 ) * sin( dst ) * dec().cos(),
- cos( dst ) - dec().sin() * lat1.sin() ) );
+ lat1.setUsing_asin( dec().sin() * cosDst +
+ dec().cos() * sinDst * cos( dir0 ) );
+ dtheta.setUsing_atan2( sin( dir0 ) * sinDst * dec().cos(),
+ cosDst - dec().sin() * lat1.sin() );
return SkyPoint( ra() + dtheta, lat1 );
}
diff --git a/kstars/skyobjects/skypoint.h b/kstars/skyobjects/skypoint.h
index 97a7b05..fa52d1f 100644
--- a/kstars/skyobjects/skypoint.h
+++ b/kstars/skyobjects/skypoint.h
@@ -64,7 +64,13 @@ public:
, lastPrecessJD( J2000 )
{}
-
+ SkyPoint( const CachingDms& r, const CachingDms& d ) : RA0(r)
+ , Dec0(d)
+ , RA(r)
+ , Dec(d)
+ , lastPrecessJD( J2000 )
+ {}
+
/** Alternate constructor using double arguments, for convenience.
*It behaves essentially like the default constructor.
*@param r Right Ascension, expressed as a double