From 0d3d59076687f42e04feccd5cadfa5fd91497c0c Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 31 Aug 2003 22:37:32 +0000 Subject: [PATCH] add WRAP macro --- stepmania/src/RageUtil.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index f62f2dedf6..e80ce0a98b 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -52,11 +52,14 @@ inline unsigned long max(unsigned long a, unsigned int b) { return a > b? a:b; } #define PI ((float)3.1415926535897932384626433832795) #define DegreeToRadian( degree ) ((degree) * (PI / 180.0f)) #define RadianToDegree( radian ) ((radian) * (180.0f / PI)) + // Scales x so that l1 corresponds to l2 and h1 corresponds to h2. Does not modify x, MUST assign the result to something! #define SCALE(x, l1, h1, l2, h2) (((x) - (l1)) / ((h1) - (l1)) * ((h2) - (l2)) + (l2)) -// Clamps x + #define CLAMP(x, l, h) {if (x > h) x = h; else if (x < l) x = l;} +#define WRAP(x, n) {if (x<0) x += ((-x/n)+1)*n; x = x%n;} + //----------------------------------------------------------------------------- // Misc helper functions