diff options
Diffstat (limited to 'Client/Source/Math/Functions.h')
-rw-r--r-- | Client/Source/Math/Functions.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Client/Source/Math/Functions.h b/Client/Source/Math/Functions.h new file mode 100644 index 0000000..3dd17dd --- /dev/null +++ b/Client/Source/Math/Functions.h @@ -0,0 +1,30 @@ +#pragma once + +namespace MathUtils +{ + template <typename T> + inline T Max(T a, T b) + { + return a < b ? b : a; + } + + template <typename T> + inline T Min(T a, T b) + { + return a < b ? a : b; + } + +} + +#define max(a, b)\ +((a)>(b)?(a):(b)) + +#define min(a, b)\ +(a)<(b)?(a):(b) + +#define clamp(v, lo, hi)\ +max((lo), min((v), (hi))) + +// ÆæÊý·µ»Ø1£¬·ñÔò0 +#define odd(n) \ +(((n)&1)?1:0) |