00001 #include "ReVolt.h"
00002 #include "Util.h"
00003
00004
00006
00007
00008
00009
00011 REAL GoodWrap(REAL *var, REAL min, REAL max)
00012 {
00013 int n;
00014 REAL diff, range;
00015 if (*var < min) {
00016 range = max - min;
00017 diff = min - *var;
00018 n = (int) (diff / range);
00019 *var += range * (n + 1);
00020 }
00021 else if (*var > max) {
00022 range = max - min;
00023 diff = *var - max;
00024 n = (int) (diff / range);
00025 *var -= range * (n + 1);
00026 }
00027 return *var;
00028 }
00029