On Saturday 13 September 2008 10:49:54 James Turner wrote:
> I'm getting more and more encouraged to write a set of course and
> bearing helpers to deal with the normalisation and differencing. I've
> lost count of the number of times I've seen the:
>
>    if ( az1 >  180.0) az1 -= 360.0;
>    if ( az1 < -180.0) az1 += 360.0;
>
> Idiom repeated in the code, and lots of classes already have helpers
> for this - the KLN-89b and Mk-VIII, for example. Maybe there's some
> standard ones in SimGear I haven't spotted yet?

There is

// normalize a value to lie between min and max
template <class T>
inline void SG_NORMALIZE_RANGE( T &val, const T min, const T max ) {
    T step = max - min;
    while( val >= max )  val -= step;
    while( val < min ) val += step;
};

in simgear/sg_inlines.h


-- 
Roy Vegard Ovesen

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to