summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkarsh Simha <akarsh@kde.org>2016-09-28 10:38:18 (GMT)
committerAkarsh Simha <akarsh@kde.org>2016-09-29 02:20:27 (GMT)
commitc5e709bd919f55d2335f22070b8d31ed5868efbb (patch)
tree8a7178705b6db8cbbc711e4287f6c69d037b58c5
parentc1dc0b46e51424ffcc11b0cdf822852381442556 (diff)
Reduce number of multiplications in SkyPoint::aberrate() by factoring
In an independent test, the new code seemed to consume consistently around 80% of the CPU cycles of the old code.
-rw-r--r--kstars/skyobjects/skypoint.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/kstars/skyobjects/skypoint.cpp b/kstars/skyobjects/skypoint.cpp
index 65f3d13..6f9ae9a 100644
--- a/kstars/skyobjects/skypoint.cpp
+++ b/kstars/skyobjects/skypoint.cpp
@@ -345,18 +345,21 @@ void SkyPoint::aberrate(const KSNumbers *num) {
Dec.SinCos( sinDec, cosDec );
num->obliquity()->SinCos( sinOb, cosOb );
- double tanOb = sinOb/cosOb;
+ // double tanOb = sinOb/cosOb;
num->sunTrueLongitude().SinCos( sinL, cosL );
num->earthPerihelionLongitude().SinCos( sinP, cosP );
//Step 3: Aberration
- double dRA = -1.0 * K * ( cosRA * cosL * cosOb + sinRA * sinL )/cosDec
- + e * K * ( cosRA * cosP * cosOb + sinRA * sinP )/cosDec;
+ // double dRA = -1.0 * K * ( cosRA * cosL * cosOb + sinRA * sinL )/cosDec
+ // + e * K * ( cosRA * cosP * cosOb + sinRA * sinP )/cosDec;
- double dDec = -1.0 * K * ( cosL * cosOb * ( tanOb * cosDec - sinRA * sinDec ) + cosRA * sinDec * sinL )
- + e * K * ( cosP * cosOb * ( tanOb * cosDec - sinRA * sinDec ) + cosRA * sinDec * sinP );
+ // double dDec = -1.0 * K * ( cosL * cosOb * ( tanOb * cosDec - sinRA * sinDec ) + cosRA * sinDec * sinL )
+ // + e * K * ( cosP * cosOb * ( tanOb * cosDec - sinRA * sinDec ) + cosRA * sinDec * sinP );
+
+ double dRA = K * ( cosRA * cosOb / cosDec ) * ( e * cosP - cosL );
+ double dDec = K * ( sinRA * ( sinOb * cosDec - cosOb * sinDec ) * ( e * cosP - cosL ) + cosRA * sinDec * ( e * sinP - sinL ) );
RA.setD( RA.Degrees() + dRA );
Dec.setD( Dec.Degrees() + dDec );