Changeset 7401 for code/trunk/src/libraries/util/Math.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/util/Math.h
r7184 r7401 28 28 29 29 /** 30 @defgroup Math Mathematical functions 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup Math 31 37 @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace. 32 38 */ … … 62 68 namespace math 63 69 { 64 const float pi = 3.14159265f; 65 const float pi_2 = 1.57079633f; 66 const float pi_4 = 7.85398163e-1f; 67 const float e = 2.71828183f; 68 const float sqrt2 = 1.41421356f; 69 const float sqrt2_2 = 7.07106781e-1f; 70 71 const double pi_d = 3.14159265358979324; 72 const double pi_2_d = 1.57079632679489662; 73 const double pi_4_d = 7.85398163397448310e-1; 74 const double e_d = 2.71828182845904524; 75 const double sqrt2_d = 1.41421356237309505; 76 const double sqrt2_2_d = 7.07106781186547524e-1; 70 const float pi = 3.14159265f; ///< PI 71 const float pi_2 = 1.57079633f; ///< PI / 2 72 const float pi_4 = 7.85398163e-1f; ///< PI / 4 73 const float e = 2.71828183f; ///< e 74 const float sqrt2 = 1.41421356f; ///< sqrt(2) 75 const float sqrt2_2 = 7.07106781e-1f; ///< sqrt(2) / 2 76 77 const double pi_d = 3.14159265358979324; ///< PI (double) 78 const double pi_2_d = 1.57079632679489662; ///< PI / 2 (double) 79 const double pi_4_d = 7.85398163397448310e-1; ///< PI / 4 (double) 80 const double e_d = 2.71828182845904524; ///< e (double) 81 const double sqrt2_d = 1.41421356237309505; ///< sqrt(2) (double) 82 const double sqrt2_2_d = 7.07106781186547524e-1; ///< sqrt(2) / 2 (double) 77 83 } 78 84 … … 101 107 102 108 /** 103 @brief Keeps a value between a lower and an upper limit. 109 @brief Keeps a value between a lower and an upper limit. Values beyond these limits are limited to either @a min or @a max. 104 110 @param x The value 105 111 @param min The lower limit … … 119 125 120 126 /** 121 @brief Returns the square value (x^2).127 @brief Returns the squared value (x^2). 122 128 */ 123 129 template <typename T> … … 128 134 129 135 /** 130 @brief Returns the cube value (x^3).136 @brief Returns the cubed value (x^3). 131 137 */ 132 138 template <typename T> … … 137 143 138 144 /** 139 @brief Rounds the value .145 @brief Rounds the value to the nearest integer. 140 146 */ 141 147 template <typename T> … … 149 155 @param x The value 150 156 @param max The operand 157 158 The built in modulo operator % yields a strange behavior with negative values. 159 This function corrects this - the result is guaranteed to lie always between 160 zero and (max-1). 161 162 Example: 163 @code 164 int var = 11 % 10; // 1 165 int var = -1 % 10; // -1 166 167 int var = mod(11, 10); // 1 168 int var = mod(-1, 10); // 9 169 @endcode 151 170 */ 152 171 template <typename T> … … 159 178 } 160 179 180 /** 181 @brief Returns a "zero" value for the given type. 182 @note This is the default template of the zeroise() function. The template is spezialized for each supported type. 183 184 The exact return value of the function depends on the type. For @c int this is 0, 185 for @c float it's 0.0f. For a @c std::string the function returns "" and for 186 @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>. 187 */ 161 188 template <typename T> 162 189 inline T zeroise() … … 192 219 template <> inline orxonox::Quaternion zeroise<orxonox::Quaternion>() { return orxonox::Quaternion (0, 0, 0, 0); } 193 220 194 //! Provides zero value symbols that can be returned as reference 221 /** 222 @brief Provides zero value symbols that can be returned as reference 223 @see zeroise() 224 */ 195 225 template <typename T> 196 226 struct NilValue … … 207 237 /** 208 238 @brief Interpolates between two values for a time between 0 and 1. 209 @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 iftime is between 0 and 1.210 @param start The value at time = 0211 @param end The value at time = 1212 @return The interpolat ionat a given time239 @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1. 240 @param start The value at @a time = 0 241 @param end The value at @a time = 1 242 @return The interpolated value at a given time 213 243 */ 214 244 template <typename T> … … 220 250 /** 221 251 @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again. 222 @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 iftime is between 0 and 1.223 @param start The value at time = 0224 @param end The value at time = 1225 @return The smoothed interpolationat a given time252 @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1. 253 @param start The value at @a time = 0 254 @param end The value at @a time = 1 255 @return The interpolated value at a given time 226 256 */ 227 257 template <typename T> … … 232 262 233 263 /** 234 @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.264 @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>. 235 265 */ 236 266 inline float rnd() … … 240 270 241 271 /** 242 @brief Returns a random number between 0 and almost max: 0 <= rnd < max.272 @brief Returns a random number between 0 and almost @a max: <tt>0 <= rnd < max</tt>. 243 273 @param max The maximum 244 274 */ … … 249 279 250 280 /** 251 @brief Returns a random number between min and almost max: min <= rnd < max.281 @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>. 252 282 @param min The minimum 253 283 @param max The maximum … … 268 298 _UtilExport unsigned long getUniqueNumber(); 269 299 300 /** 301 @brief A Vector class containing two integers @a x and @a y. 302 */ 270 303 class IntVector2 271 304 { … … 277 310 }; 278 311 312 /** 313 @brief A Vector class containing three integers @a x, @a y, and @a z. 314 */ 279 315 class IntVector3 280 316 {
Note: See TracChangeset
for help on using the changeset viewer.