Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 167 vs 168 for /trunk/Source Code/Core/Math/Headers/MathHelper.h

Diff revisions: vs.
  @@ -40,6 +40,7 @@
40 40 #define M_PI2 9.869604401089358618834490999876f // PI ^ 2
41 41 #define M_PIDIV180 0.01745329251994329576923690768488f // PI / 180
42 42 #define M_180DIVPI 57.295779513082320876798154814105f // 180 / PI
43 + #define M_PIDIV360 0.00872664625997164788461845384244f // PI / 180 / 2 - PI / 360
43 44
44 45 #define DegToRad(a) (a)*=M_PIDIV180
45 46 #define RadToDeg(a) (a)*=M_180DIVPI
  @@ -58,13 +59,36 @@
58 59 #define MsToSec(a) (a)*=0.001f
59 60 #define SecToMs(a) (a)*=1000.0f
60 61
62 + const F32 INV_RAND_MAX = 1.0 / (RAND_MAX + 1);
63 + inline F32 random(F32 max=1.0) { return max * rand() * INV_RAND_MAX; }
64 + inline F32 random(F32 min, F32 max) { return min + (max - min) * INV_RAND_MAX * rand(); }
65 + inline I32 random(I32 max=RAND_MAX) { return rand()%(max+1); }
66 + inline bool bitCompare(U32 bitMask, U32 bit) {return ((bitMask & bit) == bit);}
67 +
68 + // bit manipulation
69 + #define ToBit(posn) (1 << posn)
70 + #define BitSet(arg,posn) (arg |= 1 << posn)
71 + #define BitClr(arg,posn) (arg &= ~(1 << (posn)))
72 + #define BitTst(arg,posn) ((arg & 1 << (posn)) != 0)
73 +
74 + #define BitDiff(arg1,arg2) (arg1 ^ arg2)
75 + #define BitCmp(arg1,arg2,posn) ((arg1<<posn) == (arg2<<posn))
76 +
77 + // bitmask manipulation
78 + #define BitMaskSet(arg,mask) ((arg) |= (mask))
79 + #define BitMaskClear(arg,mask) ((arg) &= (~(mask)))
80 + #define BitMaskFlip(arg,mask) ((arg) ^= (mask))
81 + #define BitMaskCheck(arg,mask) ((arg) & (mask))
82 +
83 + template <typename T>
84 + class mat4;
85 + template <typename T>
86 + class vec3;
87 + template <typename T>
88 + class Quaternion;
89 +
61 90 namespace Util {
62 - template <typename T>
63 - class mat4;
64 - template <typename T>
65 - class vec3;
66 - template <typename T>
67 - class Quaternion;
91 +
68 92
69 93 inline void replaceStringInPlace(std::string& subject, const std::string& search, const std::string& replace) {
70 94 size_t pos = 0;
  @@ -141,10 +165,10 @@
141 165 }
142 166 namespace Mat4{
143 167 // ----------------------------------------------------------------------------------------
144 - template <typename T>
145 - void decompose (const mat4<T>& matrix, vec3<T>& scale, Quaternion<T>& rotation, vec3<T>& position);
146 - template <typename T>
147 - void decomposeNoScaling(const mat4<T>& matrix, Quaternion<T>& rotation, vec3<T>& position);
168 + template<class Type>
169 + void decompose (const mat4<Type>& matrix, vec3<Type>& scale, Quaternion<Type>& rotation, vec3<Type>& position);
170 + template<class Type>
171 + void decomposeNoScaling(const mat4<Type>& matrix, Quaternion<Type>& rotation, vec3<Type>& position);
148 172 }
149 173 }
150 174