Julian Foad writes:
>
> Norman Vine wrote:
> > 
> > This is the poor man's version taken from sg_inlines.h
> > 
> > // 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;
> > };
> 
> That's effectively what we have (or had).

Close but not quite and may not solve all of your perceived problems
and you are right about the < had > :-(
 
> > A proper version needs to be based on Interval Arithmetic we could just 
> > snag a subset of the scalar functions from an existing package 
> > http://www.ti3.tu-harburg.de/~knueppel/profil/docu/Profil.texinfo_19.html
> 
> Er ... we are not trying to do arithmetic on intervals.  We are just 
> incrementing and decrementing a scaler value within an interval.

Er... If you want to assign a 'stepsize' that is not an integral value 
then you are doing Interval Arirthmetic

in fact you are doing interval arithmetic with an integral stepsize
except that with integer arithmetic there are no precison problems
like the ones you brought up

also note I said 'snag a subset' ie just the scalar add and subtract 
parts

Granted you can make a special arithmetic for the frequency adjuster
but why not use a proven mathematically sound methodology that will 
just work for any stepsize for all adjusters with or without wrap around

ie a 'proper' implementation in the rigourous sense

Cheers

Norman


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to