CBounds.hpp

Go to the documentation of this file.
00001 #ifndef __CBounds__
00002 #define __CBounds__
00003 
00004 #include "../Basics/CCountedObject.hpp"
00005 
00006 //  ===========================================================================
00007 
00008 namespace Exponent
00009 {
00010     namespace MathTools
00011     {
00029         class CBounds
00030         {
00031         public:
00032 
00033 //  ===========================================================================
00034 
00042             static FORCEINLINE double ensureRange(double value, const double min, const double max)
00043             {
00044                 if (value > max)
00045                 {
00046                     return max;
00047                 }
00048                 else if (value < min)
00049                 {
00050                     return min;
00051                 }
00052                 return value;
00053             }
00054 
00062             static FORCEINLINE long ensureRange(const long value, const long min, const long max)
00063             {
00064                 if (value > max)
00065                 {
00066                     return max;
00067                 }
00068                 else if (value < min)
00069                 {
00070                     return min;
00071                 }
00072                 return value;
00073             }
00074 
00082             static FORCEINLINE void clampRange(double &value, const double min, const double max)
00083             {
00084                 if (value > max)
00085                 {
00086                     value = max;
00087                 }
00088                 else if (value < min)
00089                 {
00090                     value = min;
00091                 }
00092             }
00093 
00099             static FORCEINLINE double rangeCheck(const double value)
00100             {
00101                 return ensureRange(value, 0.0, 1.0);
00102             }
00103 
00104         };
00105     }
00106 }
00107 #endif  // End of CBounds.hpp

Infinity API - CBounds.hpp Source File generated on 7 Mar 2007