diff options
Diffstat (limited to 'src/math/functions.h')
-rw-r--r-- | src/math/functions.h | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/src/math/functions.h b/src/math/functions.h index 5a53d44..8135392 100644 --- a/src/math/functions.h +++ b/src/math/functions.h @@ -15,17 +15,53 @@ namespace math { -/// return the smallest of two float values -float min(float a, float b); +/** + * @brief return the smallest of two floats + */ +inline const float min(const float a, const float b) +{ + return (a < b ? a : b); +} -/// return the smallest of two integers -int min(int a, int b); +/** + * @brief return the smallest of two integers + */ +inline const int min(const int a, const int b) +{ + return (a < b ? a : b); +} -/// return the largest of two float values -float max(float a, float b); +/** + * @brief return the smallest of two longs + */ +inline const long min(const long a, const long b) +{ + return (a < b ? a : b); +} -/// return the largest of two integers -int max(int a, int b); +/** + * @brief return the largest of two floats + */ +inline const float max(const float a, const float b) +{ + return (a > b ? a : b); +} + +/** + * @brief return the largest of two integers + */ +inline const int max(const int a, const int b) +{ + return (a > b ? a : b); +} + +/** + * @brief return the largest of two longs + */ +inline const long max(const long a, const long b) +{ + return (a > b ? a : b); +} /// returns a random float /** The value returned will be in the interval [0-max] @@ -63,6 +99,14 @@ inline float absf(const float f) return ( f < 0.0f ? -f : f ); } +/// swap two float values +inline void swap(float &x, float &y) +{ + float tmp = x; + x = y; + y = tmp; +} + } // namespace math #endif // __INCLUDED_MATH_FUNCTIONS_H__ |