diff options
author | Stijn Buys <ingar@osirion.org> | 2008-05-01 21:08:40 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-05-01 21:08:40 +0000 |
commit | 36ce28a7557c4b2b73316621471558354024ca54 (patch) | |
tree | 3aeb4502b3a4f91a54df5d25bedfd262e61d1cec /src/math | |
parent | a22542f273de28d06ecaf2bd6fd741821e98512b (diff) |
roll control
Diffstat (limited to 'src/math')
-rw-r--r-- | src/math/functions.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/math/functions.h b/src/math/functions.h index d9f78df..b44a4e5 100644 --- a/src/math/functions.h +++ b/src/math/functions.h @@ -49,6 +49,12 @@ float degrees180f(float angle); /// return an angle in the [0,360[ range float degrees360f(float angle); +/// clamp a float to a specified range +inline void clamp(float &value, float min=0.0f, float max=1.0f) +{ + if (value < min) value = min; else if (value > max) value = max; +} + } // namespace math #endif // __INCLUDED_MATH_FUNCTIONS_H__ |