<ahref="Math_8cpp.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="preprocessor">#include "<aclass="code"href="Math_8h.html">Math.h</a>"</span></div>
<divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment">// Checks if the random number generator is initialized. Does nothing if it is, initializes if it isn't.</span></div>
<divclass="line"><aname="l00008"></a><spanclass="lineno"><aclass="line"href="Math_8cpp.html#ac0cae806d3e9a3772f7388dd53cfc370"> 8</a></span> <spanclass="preprocessor">#define MAKE_SURE_RNG_IS_INITIALIZED if (!isRngInitialized) InitRng();</span></div>
<divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment">// Generate enough truly random values to populate the entire state of the mersenne twister</span></div>
<divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="comment">// Seed the mersenne twister with these values</span></div>
<divclass="line"><aname="l00028"></a><spanclass="lineno"> 28</span> <spanclass="comment">// Will return a random double between 0 and 1</span></div>
<divclass="line"><aname="l00049"></a><spanclass="lineno"> 49</span> <spanclass="comment">// Since this is supposed to return a random value anyways,</span></div>
<divclass="line"><aname="l00050"></a><spanclass="lineno"> 50</span> <spanclass="comment">// we can let the random uint overflow without any problems.</span></div>
<divclass="line"><aname="l00054"></a><spanclass="lineno"> 54</span> <spanclass="comment">// Will return a random double within a range </span></div>
<divclass="line"><aname="l00055"></a><spanclass="lineno"> 55</span> <spanclass="comment">// These bounds are INCLUSIVE!</span></div>
<divclass="line"><aname="l00061"></a><spanclass="lineno"> 61</span> <spanclass="comment">// Will return a random integer within a range. This is faster than '(int)RandomRange(x,y)'</span></div>
<divclass="line"><aname="l00062"></a><spanclass="lineno"> 62</span> <spanclass="comment">// These bounds are INCLUSIVE!</span></div>
<divclass="line"><aname="l00081"></a><spanclass="lineno"> 81</span> <spanclass="keywordflow">throw</span> std::logic_error(<spanclass="stringliteral">"Divide by zero"</span>);</div>
<divclass="line"><aname="l00089"></a><spanclass="lineno"> 89</span> <spanclass="comment">// -> operator% works for a > 0 && b > 0</span></div>
<divclass="ttc"id="aclassEule_1_1Math_html_a60bffec38a861b7701fc90bd6f1a11d6"><divclass="ttname"><ahref="classEule_1_1Math.html#a60bffec38a861b7701fc90bd6f1a11d6">Eule::Math::RandomChance</a></div><divclass="ttdeci">static bool RandomChance(const double chance)</div><divclass="ttdoc">Will 'roll' a dice, returning true percent of the time.</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00073">Math.cpp:73</a></div></div>
<divclass="ttc"id="aConstants_8h_html_a299aabc5fc8285cbf99025330a3d0d0d"><divclass="ttname"><ahref="Constants_8h.html#a299aabc5fc8285cbf99025330a3d0d0d">PI</a></div><divclass="ttdeci">static constexpr double PI</div><divclass="ttdoc">Pi up to 50 decimal places.</div><divclass="ttdef"><b>Definition:</b><ahref="Constants_8h_source.html#l00006">Constants.h:6</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_a48ca8451f9803ce35d2a35cfb83d8ae9"><divclass="ttname"><ahref="classEule_1_1Math.html#a48ca8451f9803ce35d2a35cfb83d8ae9">Eule::Math::RandomRange</a></div><divclass="ttdeci">static double RandomRange(const double min, const double max)</div><divclass="ttdoc">Will return a random double within a range These bounds are INCLUSIVE!</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00056">Math.cpp:56</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_a9d17091e986de45e9bbee484e2d56430"><divclass="ttname"><ahref="classEule_1_1Math.html#a9d17091e986de45e9bbee484e2d56430">Eule::Math::Mod</a></div><divclass="ttdeci">static int Mod(const int numerator, const int denominator)</div><divclass="ttdoc">Will compute the actual modulo of a fraction.</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00078">Math.cpp:78</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_ab8d66e39e794d89594c50690ccc92c60"><divclass="ttname"><ahref="classEule_1_1Math.html#ab8d66e39e794d89594c50690ccc92c60">Eule::Math::RandomInt</a></div><divclass="ttdeci">static unsigned int RandomInt()</div><divclass="ttdoc">Will return a random integer.</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00045">Math.cpp:45</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_adfc55be8cb68aba351374f045f29a2ad"><divclass="ttname"><ahref="classEule_1_1Math.html#adfc55be8cb68aba351374f045f29a2ad">Eule::Math::RandomIntRange</a></div><divclass="ttdeci">static int RandomIntRange(const int max, const int min)</div><divclass="ttdoc">Will return a random integer within a range.</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00063">Math.cpp:63</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_a6aa6d6c804f995a089779219e5136e4f"><divclass="ttname"><ahref="classEule_1_1Math.html#a6aa6d6c804f995a089779219e5136e4f">Eule::Math::Random</a></div><divclass="ttdeci">static double Random()</div><divclass="ttdoc">Will return a random double between 0 and 1</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00029">Math.cpp:29</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_ad38d9a50e08cd02bb35161cc3bd77b26"><divclass="ttname"><ahref="classEule_1_1Math.html#ad38d9a50e08cd02bb35161cc3bd77b26">Eule::Math::RandomUint</a></div><divclass="ttdeci">static unsigned int RandomUint()</div><divclass="ttdoc">Will return a random unsigned integer.</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00037">Math.cpp:37</a></div></div>
<divclass="ttc"id="aclassEule_1_1Math_html_a1b0fb72c51751470f7f819b20a5b3b3f"><divclass="ttname"><ahref="classEule_1_1Math.html#a1b0fb72c51751470f7f819b20a5b3b3f">Eule::Math::Oscillate</a></div><divclass="ttdeci">static double Oscillate(const double a, const double b, const double counter, const double speed)</div><divclass="ttdoc">Kind of like , but it oscillates over instead of , by a given speed.</div><divclass="ttdef"><b>Definition:</b><ahref="Math_8cpp_source.html#l00068">Math.cpp:68</a></div></div>