Changeset 3196 for code/trunk/src/util/Math.h
- Timestamp:
- Jun 20, 2009, 9:20:47 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/pch (added) merged: 3114-3118,3124-3125,3127-3131,3133,3138-3194
- Property svn:mergeinfo changed
-
code/trunk/src/util/Math.h
r2872 r3196 37 37 #include "UtilPrereqs.h" 38 38 39 #include <ostream>40 39 #include <string> 41 40 #include <cmath> 42 #include <boost/static_assert.hpp>43 41 44 42 #include <OgreMath.h> … … 46 44 #include <OgreVector3.h> 47 45 #include <OgreVector4.h> 48 #include <OgreMatrix3.h>49 #include <OgreMatrix4.h>50 46 #include <OgreQuaternion.h> 51 47 #include <OgreColourValue.h> … … 58 54 namespace orxonox 59 55 { 60 using Ogre::Radian;61 using Ogre::Degree;62 using Ogre::Vector2;63 using Ogre::Vector3;64 using Ogre::Vector4;65 using Ogre::Matrix3;66 using Ogre::Matrix4;67 using Ogre::Quaternion;68 using Ogre::ColourValue;69 70 // Also define our own transform space enum71 namespace TransformSpace72 {73 /**74 @brief75 Enumeration denoting the spaces which a transform can be relative to.76 */77 enum Enum78 {79 //! Transform is relative to the local space80 Local,81 //! Transform is relative to the space of the parent node82 Parent,83 //! Transform is relative to world space84 World85 };86 }87 88 56 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian); 89 57 _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian); … … 217 185 template <> inline orxonox::Quaternion zeroise<orxonox::Quaternion>() { return orxonox::Quaternion (0, 0, 0, 0); } 218 186 187 //! Provides zero value symbols that can be returned as reference 188 template <typename T> 189 struct NilValue 190 { 191 inline operator const T&() const 192 { 193 return value; 194 } 195 static T value; 196 }; 197 template <typename T> 198 T NilValue<T>::value = zeroise<T>(); 199 219 200 /** 220 201 @brief Interpolates between two values for a time between 0 and 1. … … 225 206 */ 226 207 template <typename T> 227 T interpolate(float time, const T& start, const T& end)208 inline T interpolate(float time, const T& start, const T& end) 228 209 { 229 210 return time * (end - start) + start; … … 238 219 */ 239 220 template <typename T> 240 T interpolateSmooth(float time, const T& start, const T& end)221 inline T interpolateSmooth(float time, const T& start, const T& end) 241 222 { 242 223 return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start; … … 248 229 inline float rnd() 249 230 { 250 return rand() / (RAND_MAX + 1.0 );231 return rand() / (RAND_MAX + 1.0f); 251 232 } 252 233 … … 275 256 inline float rndsgn() 276 257 { 277 return ((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0258 return static_cast<float>((rand() & 0x2) - 1); // rand() & 0x2 is either 2 or 0 278 259 } 279 260 … … 283 264 { 284 265 public: 285 IntVector2() : x(0), y(0) { }286 IntVector2(int _x, int _y) : x(_x), y(_y) { }287 int x;288 int y;266 IntVector2() : x(0), y(0) { } 267 IntVector2(int _x, int _y) : x(_x), y(_y) { } 268 int x; 269 int y; 289 270 }; 290 271 … … 292 273 { 293 274 public: 294 IntVector3() : x(0), y(0), z(0) { }295 IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }296 int x;297 int y;298 int z;275 IntVector3() : x(0), y(0), z(0) { } 276 IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { } 277 int x; 278 int y; 279 int z; 299 280 }; 300 281 }
Note: See TracChangeset
for help on using the changeset viewer.