Changeset 10742
- Timestamp:
- Nov 1, 2015, 2:52:04 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/util/Math.h
r9939 r10742 73 73 namespace math 74 74 { 75 const float twoPi = 6.283185482025146484375f; ///< PI * 276 const float pi = 3.1415927410125732421875f; ///< PI77 const float pi_2 = 1.57079637050628662109375f; ///< PI / 278 const float pi_4 = 0.785398185253143310546875f; ///< PI / 479 const float e = 2.718281269073486328125f; ///< e80 const float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2)81 const float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 275 constexpr float twoPi = 6.283185482025146484375f; ///< PI * 2 76 constexpr float pi = 3.1415927410125732421875f; ///< PI 77 constexpr float pi_2 = 1.57079637050628662109375f; ///< PI / 2 78 constexpr float pi_4 = 0.785398185253143310546875f; ///< PI / 4 79 constexpr float e = 2.718281269073486328125f; ///< e 80 constexpr float sqrt2 = 1.41421353816986083984375f; ///< sqrt(2) 81 constexpr float sqrt2_2 = 0.707106769084930419921875f; ///< sqrt(2) / 2 82 82 } 83 83 … … 104 104 */ 105 105 template <typename T> 106 inline T sgn(T x)106 constexpr inline T sgn(T x) 107 107 { 108 108 return (x >= 0) ? (T)1 : (T)-1; … … 116 116 */ 117 117 template <typename T> 118 inline T clamp(T x, T min, T max) 119 { 120 if (x < min) 121 return min; 122 123 if (x > max) 124 return max; 125 126 return x; 118 constexpr inline T clamp(T x, T min, T max) 119 { 120 return x < min ? min : (x > max ? max : x); 127 121 } 128 122 … … 131 125 */ 132 126 template <typename T> 133 inline T square(T x)127 constexpr inline T square(T x) 134 128 { 135 129 return x*x; … … 140 134 */ 141 135 template <typename T> 142 inline T cube(T x)136 constexpr inline T cube(T x) 143 137 { 144 138 return x*x*x;
Note: See TracChangeset
for help on using the changeset viewer.