Changeset 1791 for code/trunk/src/util/Math.h
- Timestamp:
- Sep 16, 2008, 3:46:25 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/Math.h
r1781 r1791 26 26 * 27 27 */ 28 29 /** 30 @file Math.h 31 @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace. 32 */ 28 33 29 34 #ifndef _Util_Math_H__ … … 68 73 69 74 //Get around Windows hackery 70 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 75 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 71 76 # ifdef max 72 77 # undef max … … 77 82 #endif 78 83 84 /** 85 @brief Returns the sign of the given value. 86 @param x The value 87 @return 1 if the value is positive or zero, -1 if the value is negative 88 */ 79 89 template <typename T> 80 90 inline T sgn(T x) … … 83 93 } 84 94 95 /** 96 @brief Returns the smaller of two values. 97 */ 85 98 template <typename T> 86 99 inline T min(T a, T b) … … 89 102 } 90 103 104 /** 105 @brief Returns the greater of two values. 106 */ 91 107 template <typename T> 92 108 inline T max(T a, T b) … … 95 111 } 96 112 113 /** 114 @brief Keeps a value between a lower and an upper limit. 115 @param x The value 116 @param min The lower limit 117 @param max The upper limit 118 */ 97 119 template <typename T> 98 120 inline T clamp(T x, T min, T max) … … 107 129 } 108 130 131 /** 132 @brief Returns the square value (x^2). 133 */ 109 134 template <typename T> 110 135 inline T square(T x) … … 113 138 } 114 139 140 /** 141 @brief Returns the cube value (x^3). 142 */ 115 143 template <typename T> 116 144 inline T cube(T x) … … 119 147 } 120 148 149 /** 150 @brief Rounds the value down. 151 */ 121 152 template <typename T> 122 153 inline int floor(T x) … … 125 156 } 126 157 158 /** 159 @brief Rounds the value up. 160 */ 127 161 template <typename T> 128 162 inline int ceil(T x) … … 132 166 } 133 167 168 /** 169 @brief Rounds the value. 170 */ 134 171 template <typename T> 135 172 inline int round(T x) … … 138 175 } 139 176 177 /** 178 @brief The modulo operation, enhanced to work properly with negative values. 179 @param x The value 180 @param max The operand 181 */ 140 182 template <typename T> 141 183 inline int mod(T x, int max) … … 147 189 } 148 190 191 /** 192 @brief Interpolates between two values for a time between 0 and 1. 193 @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1. 194 @param start The value at time = 0 195 @param end The value at time = 1 196 @return The interpolation at a given time 197 */ 149 198 template <typename T> 150 199 T interpolate(float time, const T& start, const T& end) … … 153 202 } 154 203 204 /** 205 @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again. 206 @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1. 207 @param start The value at time = 0 208 @param end The value at time = 1 209 @return The smoothed interpolation at a given time 210 */ 155 211 template <typename T> 156 212 T interpolateSmooth(float time, const T& start, const T& end) … … 159 215 } 160 216 217 /** 218 @brief Returns a random number between 0 and 1. 219 */ 161 220 inline _UtilExport float rnd() 162 221 { … … 164 223 } 165 224 225 /** 226 @brief Returns a random number between 0 and max. 227 @param max The maximum 228 */ 166 229 inline _UtilExport float rnd(float max) 167 230 { … … 169 232 } 170 233 234 /** 235 @brief Returns a random number between min and max. 236 @param min The minimum 237 @param max The maximum 238 */ 171 239 inline _UtilExport float rnd(float min, float max) 172 240 {
Note: See TracChangeset
for help on using the changeset viewer.