diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-08-22 07:52:33 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-08-22 07:52:33 +0000 |
| commit | 8b3c16e6152a527f9aec1a88a9eed74119de7000 (patch) | |
| tree | f0bde5cea15e696e42cade06a3b12ff6b13acc57 /src/game/math.h | |
| parent | 9899666a7ce6679a3b9667ab09f615f4d0769c16 (diff) | |
| download | zcatch-8b3c16e6152a527f9aec1a88a9eed74119de7000.tar.gz zcatch-8b3c16e6152a527f9aec1a88a9eed74119de7000.zip | |
major engine cleanup. dependency on baselib removed. engine is now C code (not ansi tho). some other cruft removed aswell
Diffstat (limited to 'src/game/math.h')
| -rw-r--r-- | src/game/math.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/game/math.h b/src/game/math.h new file mode 100644 index 00000000..7ef3baad --- /dev/null +++ b/src/game/math.h @@ -0,0 +1,29 @@ +#ifndef BASE_MATH_H +#define BASE_MATH_H + +template <typename T> +inline T clamp(T val, T min, T max) +{ + if(val < min) + return min; + if(val > max) + return max; + return val; +} + +inline float sign(float f) +{ + return f<0.0f?-1.0f:1.0f; +} + +template<typename T, typename TB> +inline T mix(const T a, const T b, TB amount) +{ + return a + (b-a)*amount; +} +const float pi = 3.1415926535897932384626433f; + +template <typename T> inline T min(T a, T b) { return a<b?a:b; } +template <typename T> inline T max(T a, T b) { return a>b?a:b; } + +#endif // BASE_MATH_H |