MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Clamp.hpp
Go to the documentation of this file.
1 #ifndef CLAMP_H
2 #define CLAMP_H
3 
4 #include <Config.hpp>
5 
12 //#include <config.h>
13 namespace mgx {
14 namespace util {
23 template <class T> T clamp(const T& val, const T& min, const T& max)
24 {
25  if(min >= max)
26  return max;
27  else if(val < min)
28  return min;
29  else if(val > max)
30  return max;
31  else
32  return val;
33 }
34 } // namespace util
35 } // namespace mgx
36 
37 #endif