add WRAP macro
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user