21 lines
375 B
C++
21 lines
375 B
C++
#ifndef K_MATH_MATH_H
|
|
#define K_MATH_MATH_H
|
|
|
|
#include "../Defines.h"
|
|
|
|
class Math {
|
|
|
|
public:
|
|
|
|
/** ensure val stays within [min:max] */
|
|
template <typename Scalar> static inline Scalar clamp(const Scalar min, const Scalar max, const Scalar val) {
|
|
if (unlikely(val < min)) {return min;}
|
|
if (unlikely(val > max)) {return max;}
|
|
return val;
|
|
}
|
|
|
|
};
|
|
|
|
|
|
#endif // K_MATH_MATH_H
|