[Kstars-devel] KDE/kdeedu/kstars/kstars

Henry de Valence hdevalence at gmail.com
Fri Jul 23 21:34:55 CEST 2010


SVN commit 1153695 by hdevalence:

Use a closed form instead of an iterative solution for reducing angles.

Note: we don't just use fmod because it does not guarantee
a positive remainder.

CCMAIL:kstars-devel at kde.org


 M  +1 -4      dms.cpp  
 M  +1 -5      ksutils.h  


--- trunk/KDE/kdeedu/kstars/kstars/dms.cpp #1153694:1153695
@@ -197,10 +197,7 @@
 
 
 const dms dms::reduce( void ) const {
-    double a = D;
-    while (a<0.0) {a += 360.0;}
-    while (a>=360.0) {a -= 360.0;}
-    return dms( a );
+    return dms( D - 360.0*floor(D/360.0) );
 }
 
 const QString dms::toDMSString(const bool forceSign) const {
--- trunk/KDE/kdeedu/kstars/kstars/ksutils.h #1153694:1153695
@@ -67,11 +67,7 @@
     template<typename T>
     inline T reduceAngle(T x, T min, T max) {
         T delta = max - min;
-        while( x > max )
-            x -= delta;
-        while( x < min )
-            x += delta;
-        return x;
+        return x - delta*floor( (x-min)/delta );
     }
 }
 


More information about the Kstars-devel mailing list