diff options
author | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-01-13 19:47:58 +1000 |
commit | f9158592e1478b2013afc7041d9ed041cf2d2f4a (patch) | |
tree | b16e389d7988700e21b4c9741044cefa536dcbae /libraries/irrlicht-1.8.1/doc/html/irr_math_8h_source.html | |
parent | Libraries readme updated with change markers and more of the Irrlicht changes. (diff) | |
download | SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.zip SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.gz SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.bz2 SledjHamr-f9158592e1478b2013afc7041d9ed041cf2d2f4a.tar.xz |
Update Irrlicht to 1.8.1. Include actual change markers this time. lol
Diffstat (limited to 'libraries/irrlicht-1.8.1/doc/html/irr_math_8h_source.html')
-rw-r--r-- | libraries/irrlicht-1.8.1/doc/html/irr_math_8h_source.html | 802 |
1 files changed, 802 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/doc/html/irr_math_8h_source.html b/libraries/irrlicht-1.8.1/doc/html/irr_math_8h_source.html new file mode 100644 index 0000000..1c15008 --- /dev/null +++ b/libraries/irrlicht-1.8.1/doc/html/irr_math_8h_source.html | |||
@@ -0,0 +1,802 @@ | |||
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
2 | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | ||
5 | <title>Irrlicht 3D Engine: irrMath.h Source File</title> | ||
6 | |||
7 | <link href="tabs.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> | ||
9 | <link href="navtree.css" rel="stylesheet" type="text/css"/> | ||
10 | <script type="text/javascript" src="jquery.js"></script> | ||
11 | <script type="text/javascript" src="resize.js"></script> | ||
12 | <script type="text/javascript" src="navtree.js"></script> | ||
13 | <script type="text/javascript"> | ||
14 | $(document).ready(initResizable); | ||
15 | </script> | ||
16 | <link href="search/search.css" rel="stylesheet" type="text/css"/> | ||
17 | <script type="text/javascript" src="search/search.js"></script> | ||
18 | <script type="text/javascript"> | ||
19 | $(document).ready(function() { searchBox.OnSelectItem(0); }); | ||
20 | </script> | ||
21 | |||
22 | </head> | ||
23 | <body> | ||
24 | <div id="top"><!-- do not remove this div! --> | ||
25 | |||
26 | |||
27 | <div id="titlearea"> | ||
28 | <table cellspacing="0" cellpadding="0"> | ||
29 | <tbody> | ||
30 | <tr style="height: 56px;"> | ||
31 | |||
32 | <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td> | ||
33 | |||
34 | |||
35 | <td style="padding-left: 0.5em;"> | ||
36 | <div id="projectname">Irrlicht 3D Engine | ||
37 | |||
38 | </div> | ||
39 | |||
40 | </td> | ||
41 | |||
42 | |||
43 | |||
44 | |||
45 | <td> <div id="MSearchBox" class="MSearchBoxInactive"> | ||
46 | <span class="left"> | ||
47 | <img id="MSearchSelect" src="search/mag_sel.png" | ||
48 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
49 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
50 | alt=""/> | ||
51 | <input type="text" id="MSearchField" value="Search" accesskey="S" | ||
52 | onfocus="searchBox.OnSearchFieldFocus(true)" | ||
53 | onblur="searchBox.OnSearchFieldFocus(false)" | ||
54 | onkeyup="searchBox.OnSearchFieldChange(event)"/> | ||
55 | </span><span class="right"> | ||
56 | <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> | ||
57 | </span> | ||
58 | </div> | ||
59 | </td> | ||
60 | |||
61 | |||
62 | </tr> | ||
63 | </tbody> | ||
64 | </table> | ||
65 | </div> | ||
66 | |||
67 | <!-- Generated by Doxygen 1.7.5.1 --> | ||
68 | <script type="text/javascript"> | ||
69 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); | ||
70 | </script> | ||
71 | <script type="text/javascript" src="dynsections.js"></script> | ||
72 | </div> | ||
73 | <div id="side-nav" class="ui-resizable side-nav-resizable"> | ||
74 | <div id="nav-tree"> | ||
75 | <div id="nav-tree-contents"> | ||
76 | </div> | ||
77 | </div> | ||
78 | <div id="splitbar" style="-moz-user-select:none;" | ||
79 | class="ui-resizable-handle"> | ||
80 | </div> | ||
81 | </div> | ||
82 | <script type="text/javascript"> | ||
83 | initNavTree('irr_math_8h.html',''); | ||
84 | </script> | ||
85 | <div id="doc-content"> | ||
86 | <div class="header"> | ||
87 | <div class="headertitle"> | ||
88 | <div class="title">irrMath.h</div> </div> | ||
89 | </div> | ||
90 | <div class="contents"> | ||
91 | <a href="irr_math_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (C) 2002-2012 Nikolaus Gebhardt</span> | ||
92 | <a name="l00002"></a>00002 <span class="comment">// This file is part of the "Irrlicht Engine".</span> | ||
93 | <a name="l00003"></a>00003 <span class="comment">// For conditions of distribution and use, see copyright notice in irrlicht.h</span> | ||
94 | <a name="l00004"></a>00004 | ||
95 | <a name="l00005"></a>00005 <span class="preprocessor">#ifndef __IRR_MATH_H_INCLUDED__</span> | ||
96 | <a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define __IRR_MATH_H_INCLUDED__</span> | ||
97 | <a name="l00007"></a>00007 <span class="preprocessor"></span> | ||
98 | <a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="_irr_compile_config_8h.html">IrrCompileConfig.h</a>"</span> | ||
99 | <a name="l00009"></a>00009 <span class="preprocessor">#include "<a class="code" href="irr_types_8h.html">irrTypes.h</a>"</span> | ||
100 | <a name="l00010"></a>00010 <span class="preprocessor">#include <math.h></span> | ||
101 | <a name="l00011"></a>00011 <span class="preprocessor">#include <float.h></span> | ||
102 | <a name="l00012"></a>00012 <span class="preprocessor">#include <stdlib.h></span> <span class="comment">// for abs() etc.</span> | ||
103 | <a name="l00013"></a>00013 <span class="preprocessor">#include <limits.h></span> <span class="comment">// For INT_MAX / UINT_MAX</span> | ||
104 | <a name="l00014"></a>00014 | ||
105 | <a name="l00015"></a>00015 <span class="preprocessor">#if defined(_IRR_SOLARIS_PLATFORM_) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) || defined (_WIN32_WCE)</span> | ||
106 | <a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor"> #define sqrtf(X) (irr::f32)sqrt((irr::f64)(X))</span> | ||
107 | <a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor"> #define sinf(X) (irr::f32)sin((irr::f64)(X))</span> | ||
108 | <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor"> #define cosf(X) (irr::f32)cos((irr::f64)(X))</span> | ||
109 | <a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor"> #define asinf(X) (irr::f32)asin((irr::f64)(X))</span> | ||
110 | <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor"> #define acosf(X) (irr::f32)acos((irr::f64)(X))</span> | ||
111 | <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor"> #define atan2f(X,Y) (irr::f32)atan2((irr::f64)(X),(irr::f64)(Y))</span> | ||
112 | <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor"> #define ceilf(X) (irr::f32)ceil((irr::f64)(X))</span> | ||
113 | <a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor"> #define floorf(X) (irr::f32)floor((irr::f64)(X))</span> | ||
114 | <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor"> #define powf(X,Y) (irr::f32)pow((irr::f64)(X),(irr::f64)(Y))</span> | ||
115 | <a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor"> #define fmodf(X,Y) (irr::f32)fmod((irr::f64)(X),(irr::f64)(Y))</span> | ||
116 | <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor"> #define fabsf(X) (irr::f32)fabs((irr::f64)(X))</span> | ||
117 | <a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor"> #define logf(X) (irr::f32)log((irr::f64)(X))</span> | ||
118 | <a name="l00028"></a>00028 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
119 | <a name="l00029"></a>00029 <span class="preprocessor"></span> | ||
120 | <a name="l00030"></a>00030 <span class="preprocessor">#ifndef FLT_MAX</span> | ||
121 | <a name="l00031"></a><a class="code" href="irr_math_8h.html#a7fbf1534f9e0f0bfdb86fb928902474c">00031</a> <span class="preprocessor"></span><span class="preprocessor">#define FLT_MAX 3.402823466E+38F</span> | ||
122 | <a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
123 | <a name="l00033"></a>00033 <span class="preprocessor"></span> | ||
124 | <a name="l00034"></a>00034 <span class="preprocessor">#ifndef FLT_MIN</span> | ||
125 | <a name="l00035"></a><a class="code" href="irr_math_8h.html#a890322b63a2fab56b8ff916c08368df6">00035</a> <span class="preprocessor"></span><span class="preprocessor">#define FLT_MIN 1.17549435e-38F</span> | ||
126 | <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
127 | <a name="l00037"></a>00037 <span class="preprocessor"></span> | ||
128 | <a name="l00038"></a>00038 <span class="keyword">namespace </span>irr | ||
129 | <a name="l00039"></a>00039 { | ||
130 | <a name="l00040"></a>00040 <span class="keyword">namespace </span>core | ||
131 | <a name="l00041"></a>00041 { | ||
132 | <a name="l00042"></a>00042 | ||
133 | <a name="l00044"></a>00044 | ||
134 | <a name="l00045"></a><a class="code" href="namespaceirr_1_1core.html#aac9f99b6a999bdf25fec402c59e8342a">00045</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#aac9f99b6a999bdf25fec402c59e8342a" title="Rounding error constant often used when comparing f32 values.">ROUNDING_ERROR_S32</a> = 0; | ||
135 | <a name="l00046"></a>00046 <span class="preprocessor">#ifdef __IRR_HAS_S64</span> | ||
136 | <a name="l00047"></a><a class="code" href="namespaceirr_1_1core.html#acc1ea39594c72f97ff196e97c14ed6f3">00047</a> <span class="preprocessor"></span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> <a class="code" href="namespaceirr_1_1core.html#acc1ea39594c72f97ff196e97c14ed6f3">ROUNDING_ERROR_S64</a> = 0; | ||
137 | <a name="l00048"></a>00048 <span class="preprocessor">#endif</span> | ||
138 | <a name="l00049"></a><a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">00049</a> <span class="preprocessor"></span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a> = 0.000001f; | ||
139 | <a name="l00050"></a><a class="code" href="namespaceirr_1_1core.html#a7b314c22d6804639cbcbce5231724f0b">00050</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#a7b314c22d6804639cbcbce5231724f0b">ROUNDING_ERROR_f64</a> = 0.00000001; | ||
140 | <a name="l00051"></a>00051 | ||
141 | <a name="l00052"></a>00052 <span class="preprocessor">#ifdef PI // make sure we don't collide with a define</span> | ||
142 | <a name="l00053"></a>00053 <span class="preprocessor"></span><span class="preprocessor">#undef PI</span> | ||
143 | <a name="l00054"></a>00054 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
144 | <a name="l00055"></a>00055 <span class="preprocessor"></span> | ||
145 | <a name="l00056"></a><a class="code" href="namespaceirr_1_1core.html#a26d877e2caf3e6f31c298a0417a0707e">00056</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a26d877e2caf3e6f31c298a0417a0707e" title="Constant for PI.">PI</a> = 3.14159265359f; | ||
146 | <a name="l00057"></a>00057 | ||
147 | <a name="l00059"></a><a class="code" href="namespaceirr_1_1core.html#ac97bfaa5b44703e61c23c91b88f3ec3a">00059</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#ac97bfaa5b44703e61c23c91b88f3ec3a" title="Constant for reciprocal of PI.">RECIPROCAL_PI</a> = 1.0f/<a class="code" href="namespaceirr_1_1core.html#a26d877e2caf3e6f31c298a0417a0707e" title="Constant for PI.">PI</a>; | ||
148 | <a name="l00060"></a>00060 | ||
149 | <a name="l00062"></a><a class="code" href="namespaceirr_1_1core.html#abeab884c4376c5740f6d916356e9baa3">00062</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#abeab884c4376c5740f6d916356e9baa3" title="Constant for half of PI.">HALF_PI</a> = <a class="code" href="namespaceirr_1_1core.html#a26d877e2caf3e6f31c298a0417a0707e" title="Constant for PI.">PI</a>/2.0f; | ||
150 | <a name="l00063"></a>00063 | ||
151 | <a name="l00064"></a>00064 <span class="preprocessor">#ifdef PI64 // make sure we don't collide with a define</span> | ||
152 | <a name="l00065"></a>00065 <span class="preprocessor"></span><span class="preprocessor">#undef PI64</span> | ||
153 | <a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
154 | <a name="l00067"></a>00067 <span class="preprocessor"></span> | ||
155 | <a name="l00068"></a><a class="code" href="namespaceirr_1_1core.html#a166af519140dc00cbd88684e835086f8">00068</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#a166af519140dc00cbd88684e835086f8" title="Constant for 64bit PI.">PI64</a> = 3.1415926535897932384626433832795028841971693993751; | ||
156 | <a name="l00069"></a>00069 | ||
157 | <a name="l00071"></a><a class="code" href="namespaceirr_1_1core.html#ad3a2ddd6d772edb4d663d73fae5434e3">00071</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#ad3a2ddd6d772edb4d663d73fae5434e3" title="Constant for 64bit reciprocal of PI.">RECIPROCAL_PI64</a> = 1.0/<a class="code" href="namespaceirr_1_1core.html#a166af519140dc00cbd88684e835086f8" title="Constant for 64bit PI.">PI64</a>; | ||
158 | <a name="l00072"></a>00072 | ||
159 | <a name="l00074"></a><a class="code" href="namespaceirr_1_1core.html#a4b91e69e51a2e374aec940cba3869028">00074</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a4b91e69e51a2e374aec940cba3869028" title="32bit Constant for converting from degrees to radians">DEGTORAD</a> = <a class="code" href="namespaceirr_1_1core.html#a26d877e2caf3e6f31c298a0417a0707e" title="Constant for PI.">PI</a> / 180.0f; | ||
160 | <a name="l00075"></a>00075 | ||
161 | <a name="l00077"></a><a class="code" href="namespaceirr_1_1core.html#ae3a530e0ef661960b7af89f07d817bd5">00077</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#ae3a530e0ef661960b7af89f07d817bd5" title="32bit constant for converting from radians to degrees (formally known as GRAD_PI)">RADTODEG</a> = 180.0f / <a class="code" href="namespaceirr_1_1core.html#a26d877e2caf3e6f31c298a0417a0707e" title="Constant for PI.">PI</a>; | ||
162 | <a name="l00078"></a>00078 | ||
163 | <a name="l00080"></a><a class="code" href="namespaceirr_1_1core.html#a8e21b5969c8292857f7c9c5dcfd61c35">00080</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#a8e21b5969c8292857f7c9c5dcfd61c35" title="64bit constant for converting from degrees to radians (formally known as GRAD_PI2)">DEGTORAD64</a> = <a class="code" href="namespaceirr_1_1core.html#a166af519140dc00cbd88684e835086f8" title="Constant for 64bit PI.">PI64</a> / 180.0; | ||
164 | <a name="l00081"></a>00081 | ||
165 | <a name="l00083"></a><a class="code" href="namespaceirr_1_1core.html#ae7afeb48af12f5f5130cd179a644ec58">00083</a> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#ae7afeb48af12f5f5130cd179a644ec58" title="64bit constant for converting from radians to degrees">RADTODEG64</a> = 180.0 / <a class="code" href="namespaceirr_1_1core.html#a166af519140dc00cbd88684e835086f8" title="Constant for 64bit PI.">PI64</a>; | ||
166 | <a name="l00084"></a>00084 | ||
167 | <a name="l00086"></a>00086 | ||
168 | <a name="l00089"></a><a class="code" href="namespaceirr_1_1core.html#a8deb22ad77fb8ead3f6683bbf9ad3f67">00089</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a8deb22ad77fb8ead3f6683bbf9ad3f67" title="Utility function to convert a radian value to degrees.">radToDeg</a>(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> radians) | ||
169 | <a name="l00090"></a>00090 { | ||
170 | <a name="l00091"></a>00091 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#ae3a530e0ef661960b7af89f07d817bd5" title="32bit constant for converting from radians to degrees (formally known as GRAD_PI)">RADTODEG</a> * radians; | ||
171 | <a name="l00092"></a>00092 } | ||
172 | <a name="l00093"></a>00093 | ||
173 | <a name="l00095"></a>00095 | ||
174 | <a name="l00098"></a><a class="code" href="namespaceirr_1_1core.html#aab39939b1518daee0967c368a3bf924a">00098</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#a8deb22ad77fb8ead3f6683bbf9ad3f67" title="Utility function to convert a radian value to degrees.">radToDeg</a>(<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> radians) | ||
175 | <a name="l00099"></a>00099 { | ||
176 | <a name="l00100"></a>00100 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#ae7afeb48af12f5f5130cd179a644ec58" title="64bit constant for converting from radians to degrees">RADTODEG64</a> * radians; | ||
177 | <a name="l00101"></a>00101 } | ||
178 | <a name="l00102"></a>00102 | ||
179 | <a name="l00104"></a>00104 | ||
180 | <a name="l00107"></a><a class="code" href="namespaceirr_1_1core.html#ad58b3d0e755a4f25ad19d5f5d4fb0280">00107</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#ad58b3d0e755a4f25ad19d5f5d4fb0280" title="Utility function to convert a degrees value to radians.">degToRad</a>(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> degrees) | ||
181 | <a name="l00108"></a>00108 { | ||
182 | <a name="l00109"></a>00109 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a4b91e69e51a2e374aec940cba3869028" title="32bit Constant for converting from degrees to radians">DEGTORAD</a> * degrees; | ||
183 | <a name="l00110"></a>00110 } | ||
184 | <a name="l00111"></a>00111 | ||
185 | <a name="l00113"></a>00113 | ||
186 | <a name="l00116"></a><a class="code" href="namespaceirr_1_1core.html#a2def535b4f391ceb86ec0497cbb4bf80">00116</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#ad58b3d0e755a4f25ad19d5f5d4fb0280" title="Utility function to convert a degrees value to radians.">degToRad</a>(<a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> degrees) | ||
187 | <a name="l00117"></a>00117 { | ||
188 | <a name="l00118"></a>00118 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a8e21b5969c8292857f7c9c5dcfd61c35" title="64bit constant for converting from degrees to radians (formally known as GRAD_PI2)">DEGTORAD64</a> * degrees; | ||
189 | <a name="l00119"></a>00119 } | ||
190 | <a name="l00120"></a>00120 | ||
191 | <a name="l00122"></a>00122 <span class="keyword">template</span><<span class="keyword">class</span> T> | ||
192 | <a name="l00123"></a><a class="code" href="namespaceirr_1_1core.html#a9d34bfdbbe9c136b01ae04974572bc11">00123</a> <span class="keyword">inline</span> <span class="keyword">const</span> T& <a class="code" href="namespaceirr_1_1core.html#a9d34bfdbbe9c136b01ae04974572bc11" title="returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)">min_</a>(<span class="keyword">const</span> T& a, <span class="keyword">const</span> T& b) | ||
193 | <a name="l00124"></a>00124 { | ||
194 | <a name="l00125"></a>00125 <span class="keywordflow">return</span> a < b ? a : b; | ||
195 | <a name="l00126"></a>00126 } | ||
196 | <a name="l00127"></a>00127 | ||
197 | <a name="l00129"></a>00129 <span class="keyword">template</span><<span class="keyword">class</span> T> | ||
198 | <a name="l00130"></a><a class="code" href="namespaceirr_1_1core.html#a620f62b5ab8b484c16c0236ca7d65d33">00130</a> <span class="keyword">inline</span> <span class="keyword">const</span> T& <a class="code" href="namespaceirr_1_1core.html#a9d34bfdbbe9c136b01ae04974572bc11" title="returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)">min_</a>(<span class="keyword">const</span> T& a, <span class="keyword">const</span> T& b, <span class="keyword">const</span> T& c) | ||
199 | <a name="l00131"></a>00131 { | ||
200 | <a name="l00132"></a>00132 <span class="keywordflow">return</span> a < b ? <a class="code" href="namespaceirr_1_1core.html#a9d34bfdbbe9c136b01ae04974572bc11" title="returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)">min_</a>(a, c) : <a class="code" href="namespaceirr_1_1core.html#a9d34bfdbbe9c136b01ae04974572bc11" title="returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)">min_</a>(b, c); | ||
201 | <a name="l00133"></a>00133 } | ||
202 | <a name="l00134"></a>00134 | ||
203 | <a name="l00136"></a>00136 <span class="keyword">template</span><<span class="keyword">class</span> T> | ||
204 | <a name="l00137"></a><a class="code" href="namespaceirr_1_1core.html#afca1ce7ac54e0c31a9047947f4c7319b">00137</a> <span class="keyword">inline</span> <span class="keyword">const</span> T& <a class="code" href="namespaceirr_1_1core.html#afca1ce7ac54e0c31a9047947f4c7319b" title="returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)">max_</a>(<span class="keyword">const</span> T& a, <span class="keyword">const</span> T& b) | ||
205 | <a name="l00138"></a>00138 { | ||
206 | <a name="l00139"></a>00139 <span class="keywordflow">return</span> a < b ? b : a; | ||
207 | <a name="l00140"></a>00140 } | ||
208 | <a name="l00141"></a>00141 | ||
209 | <a name="l00143"></a>00143 <span class="keyword">template</span><<span class="keyword">class</span> T> | ||
210 | <a name="l00144"></a><a class="code" href="namespaceirr_1_1core.html#ae279a231923e0c251ebfd171f03e689c">00144</a> <span class="keyword">inline</span> <span class="keyword">const</span> T& <a class="code" href="namespaceirr_1_1core.html#afca1ce7ac54e0c31a9047947f4c7319b" title="returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)">max_</a>(<span class="keyword">const</span> T& a, <span class="keyword">const</span> T& b, <span class="keyword">const</span> T& c) | ||
211 | <a name="l00145"></a>00145 { | ||
212 | <a name="l00146"></a>00146 <span class="keywordflow">return</span> a < b ? <a class="code" href="namespaceirr_1_1core.html#afca1ce7ac54e0c31a9047947f4c7319b" title="returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)">max_</a>(b, c) : <a class="code" href="namespaceirr_1_1core.html#afca1ce7ac54e0c31a9047947f4c7319b" title="returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)">max_</a>(a, c); | ||
213 | <a name="l00147"></a>00147 } | ||
214 | <a name="l00148"></a>00148 | ||
215 | <a name="l00150"></a>00150 <span class="keyword">template</span><<span class="keyword">class</span> T> | ||
216 | <a name="l00151"></a><a class="code" href="namespaceirr_1_1core.html#a2cab2ba5899c9262ca29501ea7551c91">00151</a> <span class="keyword">inline</span> T <a class="code" href="namespaceirr_1_1core.html#a2cab2ba5899c9262ca29501ea7551c91" title="returns abs of two values. Own implementation to get rid of STL (VS6 problems)">abs_</a>(<span class="keyword">const</span> T& a) | ||
217 | <a name="l00152"></a>00152 { | ||
218 | <a name="l00153"></a>00153 <span class="keywordflow">return</span> a < (T)0 ? -a : a; | ||
219 | <a name="l00154"></a>00154 } | ||
220 | <a name="l00155"></a>00155 | ||
221 | <a name="l00158"></a>00158 <span class="keyword">template</span><<span class="keyword">class</span> T> | ||
222 | <a name="l00159"></a><a class="code" href="namespaceirr_1_1core.html#ae2e6a5729b911d26565b508e8b8dae91">00159</a> <span class="keyword">inline</span> T <a class="code" href="namespaceirr_1_1core.html#ae2e6a5729b911d26565b508e8b8dae91">lerp</a>(<span class="keyword">const</span> T& a, <span class="keyword">const</span> T& b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> t) | ||
223 | <a name="l00160"></a>00160 { | ||
224 | <a name="l00161"></a>00161 <span class="keywordflow">return</span> (T)(a*(1.f-t)) + (b*t); | ||
225 | <a name="l00162"></a>00162 } | ||
226 | <a name="l00163"></a>00163 | ||
227 | <a name="l00165"></a>00165 <span class="keyword">template</span> <<span class="keyword">class</span> T> | ||
228 | <a name="l00166"></a><a class="code" href="namespaceirr_1_1core.html#a6162f685b68f629e77336081d3316969">00166</a> <span class="keyword">inline</span> <span class="keyword">const</span> T <a class="code" href="namespaceirr_1_1core.html#a6162f685b68f629e77336081d3316969" title="clamps a value between low and high">clamp</a> (<span class="keyword">const</span> T& value, <span class="keyword">const</span> T& low, <span class="keyword">const</span> T& high) | ||
229 | <a name="l00167"></a>00167 { | ||
230 | <a name="l00168"></a>00168 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a9d34bfdbbe9c136b01ae04974572bc11" title="returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)">min_</a> (<a class="code" href="namespaceirr_1_1core.html#afca1ce7ac54e0c31a9047947f4c7319b" title="returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)">max_</a>(value,low), high); | ||
231 | <a name="l00169"></a>00169 } | ||
232 | <a name="l00170"></a>00170 | ||
233 | <a name="l00172"></a>00172 <span class="comment">// Note: We use the same trick as boost and use two template arguments to</span> | ||
234 | <a name="l00173"></a>00173 <span class="comment">// avoid ambiguity when swapping objects of an Irrlicht type that has not</span> | ||
235 | <a name="l00174"></a>00174 <span class="comment">// it's own swap overload. Otherwise we get conflicts with some compilers</span> | ||
236 | <a name="l00175"></a>00175 <span class="comment">// in combination with stl.</span> | ||
237 | <a name="l00176"></a>00176 <span class="keyword">template</span> <<span class="keyword">class</span> T1, <span class="keyword">class</span> T2> | ||
238 | <a name="l00177"></a><a class="code" href="namespaceirr_1_1core.html#ab565e5d5112b21ff9b96a0ca0c9b89ad">00177</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespaceirr_1_1core.html#ab565e5d5112b21ff9b96a0ca0c9b89ad" title="swaps the content of the passed parameters">swap</a>(T1& a, T2& b) | ||
239 | <a name="l00178"></a>00178 { | ||
240 | <a name="l00179"></a>00179 T1 c(a); | ||
241 | <a name="l00180"></a>00180 a = b; | ||
242 | <a name="l00181"></a>00181 b = c; | ||
243 | <a name="l00182"></a>00182 } | ||
244 | <a name="l00183"></a>00183 | ||
245 | <a name="l00185"></a><a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3">00185</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#a7b314c22d6804639cbcbce5231724f0b">ROUNDING_ERROR_f64</a>) | ||
246 | <a name="l00186"></a>00186 { | ||
247 | <a name="l00187"></a>00187 <span class="keywordflow">return</span> (a + tolerance >= b) && (a - tolerance <= b); | ||
248 | <a name="l00188"></a>00188 } | ||
249 | <a name="l00189"></a>00189 | ||
250 | <a name="l00191"></a><a class="code" href="namespaceirr_1_1core.html#ae9c63fd2065e6afd30b4537166706ddf">00191</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) | ||
251 | <a name="l00192"></a>00192 { | ||
252 | <a name="l00193"></a>00193 <span class="keywordflow">return</span> (a + tolerance >= b) && (a - tolerance <= b); | ||
253 | <a name="l00194"></a>00194 } | ||
254 | <a name="l00195"></a>00195 | ||
255 | <a name="l00196"></a><a class="code" href="unionirr_1_1core_1_1_float_int_union32.html">00196</a> <span class="keyword">union </span><a class="code" href="unionirr_1_1core_1_1_float_int_union32.html">FloatIntUnion32</a> | ||
256 | <a name="l00197"></a>00197 { | ||
257 | <a name="l00198"></a><a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a8bb52272b7efd87afba959ae50365d24">00198</a> <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a8bb52272b7efd87afba959ae50365d24">FloatIntUnion32</a>(<span class="keywordtype">float</span> f1 = 0.0<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a6be8ea1e57c1fa1824799c470d08af98">f</a>) : <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a6be8ea1e57c1fa1824799c470d08af98">f</a>(f1) {} | ||
258 | <a name="l00199"></a>00199 <span class="comment">// Portable sign-extraction</span> | ||
259 | <a name="l00200"></a><a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a24af76290e16126c533f6b76391372b3">00200</a> <span class="keywordtype">bool</span> <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a24af76290e16126c533f6b76391372b3">sign</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> (<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">i</a> >> 31) != 0; } | ||
260 | <a name="l00201"></a>00201 | ||
261 | <a name="l00202"></a><a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">00202</a> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">irr::s32</a> <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">i</a>; | ||
262 | <a name="l00203"></a><a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a6be8ea1e57c1fa1824799c470d08af98">00203</a> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">irr::f32</a> <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a6be8ea1e57c1fa1824799c470d08af98">f</a>; | ||
263 | <a name="l00204"></a>00204 }; | ||
264 | <a name="l00205"></a>00205 | ||
265 | <a name="l00207"></a>00207 <span class="comment">//\result true when numbers have a ULP <= maxUlpDiff AND have the same sign.</span> | ||
266 | <a name="l00208"></a><a class="code" href="namespaceirr_1_1core.html#a730a85283e04b33debcf3b755e5b7603">00208</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#a730a85283e04b33debcf3b755e5b7603" title="We compare the difference in ULP's (spacing between floating-point numbers, aka ULP=1 means there exi...">equalsByUlp</a>(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> a, <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> b, <span class="keywordtype">int</span> maxUlpDiff) | ||
267 | <a name="l00209"></a>00209 { | ||
268 | <a name="l00210"></a>00210 <span class="comment">// Based on the ideas and code from Bruce Dawson on</span> | ||
269 | <a name="l00211"></a>00211 <span class="comment">// http://www.altdevblogaday.com/2012/02/22/comparing-floating-point-numbers-2012-edition/</span> | ||
270 | <a name="l00212"></a>00212 <span class="comment">// When floats are interpreted as integers the two nearest possible float numbers differ just</span> | ||
271 | <a name="l00213"></a>00213 <span class="comment">// by one integer number. Also works the other way round, an integer of 1 interpreted as float</span> | ||
272 | <a name="l00214"></a>00214 <span class="comment">// is for example the smallest possible float number.</span> | ||
273 | <a name="l00215"></a>00215 | ||
274 | <a name="l00216"></a>00216 <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html">FloatIntUnion32</a> fa(a); | ||
275 | <a name="l00217"></a>00217 <a class="code" href="unionirr_1_1core_1_1_float_int_union32.html">FloatIntUnion32</a> fb(b); | ||
276 | <a name="l00218"></a>00218 | ||
277 | <a name="l00219"></a>00219 <span class="comment">// Different signs, we could maybe get difference to 0, but so close to 0 using epsilons is better.</span> | ||
278 | <a name="l00220"></a>00220 <span class="keywordflow">if</span> ( fa.<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a24af76290e16126c533f6b76391372b3">sign</a>() != fb.<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a24af76290e16126c533f6b76391372b3">sign</a>() ) | ||
279 | <a name="l00221"></a>00221 { | ||
280 | <a name="l00222"></a>00222 <span class="comment">// Check for equality to make sure +0==-0</span> | ||
281 | <a name="l00223"></a>00223 <span class="keywordflow">if</span> (fa.<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">i</a> == fb.<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">i</a>) | ||
282 | <a name="l00224"></a>00224 <span class="keywordflow">return</span> <span class="keyword">true</span>; | ||
283 | <a name="l00225"></a>00225 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
284 | <a name="l00226"></a>00226 } | ||
285 | <a name="l00227"></a>00227 | ||
286 | <a name="l00228"></a>00228 <span class="comment">// Find the difference in ULPs.</span> | ||
287 | <a name="l00229"></a>00229 <span class="keywordtype">int</span> ulpsDiff = <a class="code" href="namespaceirr_1_1core.html#a2cab2ba5899c9262ca29501ea7551c91" title="returns abs of two values. Own implementation to get rid of STL (VS6 problems)">abs_</a>(fa.<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">i</a>- fb.<a class="code" href="unionirr_1_1core_1_1_float_int_union32.html#a79c3131fd06e80a7ca80b9c0201c60fb">i</a>); | ||
288 | <a name="l00230"></a>00230 <span class="keywordflow">if</span> (ulpsDiff <= maxUlpDiff) | ||
289 | <a name="l00231"></a>00231 <span class="keywordflow">return</span> <span class="keyword">true</span>; | ||
290 | <a name="l00232"></a>00232 | ||
291 | <a name="l00233"></a>00233 <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
292 | <a name="l00234"></a>00234 } | ||
293 | <a name="l00235"></a>00235 | ||
294 | <a name="l00236"></a>00236 <span class="preprocessor">#if 0</span> | ||
295 | <a name="l00237"></a>00237 <span class="preprocessor"></span> | ||
296 | <a name="l00238"></a>00238 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> b) | ||
297 | <a name="l00239"></a>00239 { | ||
298 | <a name="l00240"></a>00240 <span class="keywordflow">return</span> (a == b); | ||
299 | <a name="l00241"></a>00241 } | ||
300 | <a name="l00242"></a>00242 | ||
301 | <a name="l00244"></a>00244 <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> b) | ||
302 | <a name="l00245"></a>00245 { | ||
303 | <a name="l00246"></a>00246 <span class="keywordflow">return</span> (a == b); | ||
304 | <a name="l00247"></a>00247 } | ||
305 | <a name="l00248"></a>00248 <span class="preprocessor">#endif</span> | ||
306 | <a name="l00249"></a>00249 <span class="preprocessor"></span> | ||
307 | <a name="l00250"></a><a class="code" href="namespaceirr_1_1core.html#afe4784d5bf091acce7777c40c4010ff8">00250</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#aac9f99b6a999bdf25fec402c59e8342a" title="Rounding error constant often used when comparing f32 values.">ROUNDING_ERROR_S32</a>) | ||
308 | <a name="l00251"></a>00251 { | ||
309 | <a name="l00252"></a>00252 <span class="keywordflow">return</span> (a + tolerance >= b) && (a - tolerance <= b); | ||
310 | <a name="l00253"></a>00253 } | ||
311 | <a name="l00254"></a>00254 | ||
312 | <a name="l00256"></a><a class="code" href="namespaceirr_1_1core.html#a9a54aa08fdc2119258ad8dfa44f8dadf">00256</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#aac9f99b6a999bdf25fec402c59e8342a" title="Rounding error constant often used when comparing f32 values.">ROUNDING_ERROR_S32</a>) | ||
313 | <a name="l00257"></a>00257 { | ||
314 | <a name="l00258"></a>00258 <span class="keywordflow">return</span> (a + tolerance >= b) && (a - tolerance <= b); | ||
315 | <a name="l00259"></a>00259 } | ||
316 | <a name="l00260"></a>00260 | ||
317 | <a name="l00261"></a>00261 <span class="preprocessor">#ifdef __IRR_HAS_S64</span> | ||
318 | <a name="l00262"></a>00262 <span class="preprocessor"></span> | ||
319 | <a name="l00263"></a><a class="code" href="namespaceirr_1_1core.html#a7928ce8e86ff93d918b0c144efab7b47">00263</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#abf9b9b140cc365908ea4c8c47451e4e3" title="returns if a equals b, taking possible rounding errors into account">equals</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#acc1ea39594c72f97ff196e97c14ed6f3">ROUNDING_ERROR_S64</a>) | ||
320 | <a name="l00264"></a>00264 { | ||
321 | <a name="l00265"></a>00265 <span class="keywordflow">return</span> (a + tolerance >= b) && (a - tolerance <= b); | ||
322 | <a name="l00266"></a>00266 } | ||
323 | <a name="l00267"></a>00267 <span class="preprocessor">#endif</span> | ||
324 | <a name="l00268"></a>00268 <span class="preprocessor"></span> | ||
325 | <a name="l00270"></a><a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2">00270</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">iszero</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#a7b314c22d6804639cbcbce5231724f0b">ROUNDING_ERROR_f64</a>) | ||
326 | <a name="l00271"></a>00271 { | ||
327 | <a name="l00272"></a>00272 <span class="keywordflow">return</span> fabs(a) <= tolerance; | ||
328 | <a name="l00273"></a>00273 } | ||
329 | <a name="l00274"></a>00274 | ||
330 | <a name="l00276"></a><a class="code" href="namespaceirr_1_1core.html#aaf94a81169679083a48f9f9e6dced684">00276</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">iszero</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) | ||
331 | <a name="l00277"></a>00277 { | ||
332 | <a name="l00278"></a>00278 <span class="keywordflow">return</span> fabsf(a) <= tolerance; | ||
333 | <a name="l00279"></a>00279 } | ||
334 | <a name="l00280"></a>00280 | ||
335 | <a name="l00282"></a><a class="code" href="namespaceirr_1_1core.html#a6e179d6dd92b81607f0539329dc2410a">00282</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#a6e179d6dd92b81607f0539329dc2410a" title="returns if a equals not zero, taking rounding errors into account">isnotzero</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> tolerance = <a class="code" href="namespaceirr_1_1core.html#a9514dd34463a30102ef8836915cf9c4c">ROUNDING_ERROR_f32</a>) | ||
336 | <a name="l00283"></a>00283 { | ||
337 | <a name="l00284"></a>00284 <span class="keywordflow">return</span> fabsf(a) > tolerance; | ||
338 | <a name="l00285"></a>00285 } | ||
339 | <a name="l00286"></a>00286 | ||
340 | <a name="l00288"></a><a class="code" href="namespaceirr_1_1core.html#a3842b13dc7bd40f068cc8f7fd91bcfa5">00288</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">iszero</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> tolerance = 0) | ||
341 | <a name="l00289"></a>00289 { | ||
342 | <a name="l00290"></a>00290 <span class="keywordflow">return</span> ( a & 0x7ffffff ) <= tolerance; | ||
343 | <a name="l00291"></a>00291 } | ||
344 | <a name="l00292"></a>00292 | ||
345 | <a name="l00294"></a><a class="code" href="namespaceirr_1_1core.html#afa64d4495f986ec0fa840e61cba45c68">00294</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">iszero</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> tolerance = 0) | ||
346 | <a name="l00295"></a>00295 { | ||
347 | <a name="l00296"></a>00296 <span class="keywordflow">return</span> a <= tolerance; | ||
348 | <a name="l00297"></a>00297 } | ||
349 | <a name="l00298"></a>00298 | ||
350 | <a name="l00299"></a>00299 <span class="preprocessor">#ifdef __IRR_HAS_S64</span> | ||
351 | <a name="l00300"></a>00300 <span class="preprocessor"></span> | ||
352 | <a name="l00301"></a><a class="code" href="namespaceirr_1_1core.html#a418bebacbef432fcf909e8f3d9b8368d">00301</a> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="namespaceirr_1_1core.html#afc24e6ba26469ec7ca7001ed272dc3b2" title="returns if a equals zero, taking rounding errors into account">iszero</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> tolerance = 0) | ||
353 | <a name="l00302"></a>00302 { | ||
354 | <a name="l00303"></a>00303 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#a2cab2ba5899c9262ca29501ea7551c91" title="returns abs of two values. Own implementation to get rid of STL (VS6 problems)">abs_</a>(a) <= tolerance; | ||
355 | <a name="l00304"></a>00304 } | ||
356 | <a name="l00305"></a>00305 <span class="preprocessor">#endif</span> | ||
357 | <a name="l00306"></a>00306 <span class="preprocessor"></span> | ||
358 | <a name="l00307"></a><a class="code" href="namespaceirr_1_1core.html#aa0d9ebcfeca532643e76cf58b98daca1">00307</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#aa0d9ebcfeca532643e76cf58b98daca1">s32_min</a>(<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> a, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> b) | ||
359 | <a name="l00308"></a>00308 { | ||
360 | <a name="l00309"></a>00309 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> mask = (a - b) >> 31; | ||
361 | <a name="l00310"></a>00310 <span class="keywordflow">return</span> (a & mask) | (b & ~mask); | ||
362 | <a name="l00311"></a>00311 } | ||
363 | <a name="l00312"></a>00312 | ||
364 | <a name="l00313"></a><a class="code" href="namespaceirr_1_1core.html#a3adbc0ee7f78051eb2a35511fe90bd2d">00313</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#a3adbc0ee7f78051eb2a35511fe90bd2d">s32_max</a>(<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> a, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> b) | ||
365 | <a name="l00314"></a>00314 { | ||
366 | <a name="l00315"></a>00315 <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> mask = (a - b) >> 31; | ||
367 | <a name="l00316"></a>00316 <span class="keywordflow">return</span> (b & mask) | (a & ~mask); | ||
368 | <a name="l00317"></a>00317 } | ||
369 | <a name="l00318"></a>00318 | ||
370 | <a name="l00319"></a><a class="code" href="namespaceirr_1_1core.html#aa7828c932a36c62a67fd0f2b972d8b21">00319</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#aa7828c932a36c62a67fd0f2b972d8b21">s32_clamp</a> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> value, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> low, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> high) | ||
371 | <a name="l00320"></a>00320 { | ||
372 | <a name="l00321"></a>00321 <span class="keywordflow">return</span> <a class="code" href="namespaceirr_1_1core.html#aa0d9ebcfeca532643e76cf58b98daca1">s32_min</a>(<a class="code" href="namespaceirr_1_1core.html#a3adbc0ee7f78051eb2a35511fe90bd2d">s32_max</a>(value,low), high); | ||
373 | <a name="l00322"></a>00322 } | ||
374 | <a name="l00323"></a>00323 | ||
375 | <a name="l00324"></a>00324 <span class="comment">/*</span> | ||
376 | <a name="l00325"></a>00325 <span class="comment"> float IEEE-754 bit represenation</span> | ||
377 | <a name="l00326"></a>00326 <span class="comment"></span> | ||
378 | <a name="l00327"></a>00327 <span class="comment"> 0 0x00000000</span> | ||
379 | <a name="l00328"></a>00328 <span class="comment"> 1.0 0x3f800000</span> | ||
380 | <a name="l00329"></a>00329 <span class="comment"> 0.5 0x3f000000</span> | ||
381 | <a name="l00330"></a>00330 <span class="comment"> 3 0x40400000</span> | ||
382 | <a name="l00331"></a>00331 <span class="comment"> +inf 0x7f800000</span> | ||
383 | <a name="l00332"></a>00332 <span class="comment"> -inf 0xff800000</span> | ||
384 | <a name="l00333"></a>00333 <span class="comment"> +NaN 0x7fc00000 or 0x7ff00000</span> | ||
385 | <a name="l00334"></a>00334 <span class="comment"> in general: number = (sign ? -1:1) * 2^(exponent) * 1.(mantissa bits)</span> | ||
386 | <a name="l00335"></a>00335 <span class="comment"> */</span> | ||
387 | <a name="l00336"></a>00336 | ||
388 | <a name="l00337"></a><a class="code" href="unionirr_1_1core_1_1inttofloat.html#a87651356c7436ac7755e85189412f75a">00337</a> <span class="keyword">typedef</span> <span class="keyword">union </span>{ <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="unionirr_1_1core_1_1inttofloat.html#a87651356c7436ac7755e85189412f75a">u</a>; <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> s; <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> f; } <a class="code" href="unionirr_1_1core_1_1inttofloat.html">inttofloat</a>; | ||
389 | <a name="l00338"></a>00338 | ||
390 | <a name="l00339"></a><a class="code" href="irr_math_8h.html#afc4f1a86cb2a79c560b29ee5edd0f94d">00339</a> <span class="preprocessor"> #define F32_AS_S32(f) (*((s32 *) &(f)))</span> | ||
391 | <a name="l00340"></a><a class="code" href="irr_math_8h.html#afdeb4b30296d2b1dccec72427bdb39f2">00340</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_AS_U32(f) (*((u32 *) &(f)))</span> | ||
392 | <a name="l00341"></a><a class="code" href="irr_math_8h.html#ab5498fea750901e87dfeca4e27425f16">00341</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_AS_U32_POINTER(f) ( ((u32 *) &(f)))</span> | ||
393 | <a name="l00342"></a>00342 <span class="preprocessor"></span> | ||
394 | <a name="l00343"></a><a class="code" href="irr_math_8h.html#aff2ace8fbd4b2ee6833ae0ed8dd9469a">00343</a> <span class="preprocessor"> #define F32_VALUE_0 0x00000000</span> | ||
395 | <a name="l00344"></a><a class="code" href="irr_math_8h.html#a93465b810662025b38f42244b100fc2e">00344</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_VALUE_1 0x3f800000</span> | ||
396 | <a name="l00345"></a><a class="code" href="irr_math_8h.html#a58566d4b084b3c9740b3215cf7a607bb">00345</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_SIGN_BIT 0x80000000U</span> | ||
397 | <a name="l00346"></a><a class="code" href="irr_math_8h.html#a94abc82f2a2794c8331c9dad9a06958b">00346</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_EXPON_MANTISSA 0x7FFFFFFFU</span> | ||
398 | <a name="l00347"></a>00347 <span class="preprocessor"></span> | ||
399 | <a name="l00350"></a>00350 <span class="preprocessor">#ifdef IRRLICHT_FAST_MATH</span> | ||
400 | <a name="l00351"></a>00351 <span class="preprocessor"></span><span class="preprocessor"> #define IR(x) ((u32&)(x))</span> | ||
401 | <a name="l00352"></a>00352 <span class="preprocessor"></span><span class="preprocessor">#else</span> | ||
402 | <a name="l00353"></a><a class="code" href="namespaceirr_1_1core.html#aff42ea2c4d80cb7b45b71d1f63c6a226">00353</a> <span class="preprocessor"></span> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="namespaceirr_1_1core.html#aff42ea2c4d80cb7b45b71d1f63c6a226">IR</a>(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> x) {<a class="code" href="unionirr_1_1core_1_1inttofloat.html">inttofloat</a> tmp; tmp.<a class="code" href="unionirr_1_1core_1_1inttofloat.html#ab0dd36fa35cbb368602fa0d18b2d9788">f</a>=x; <span class="keywordflow">return</span> tmp.<a class="code" href="unionirr_1_1core_1_1inttofloat.html#a87651356c7436ac7755e85189412f75a">u</a>;} | ||
403 | <a name="l00354"></a>00354 <span class="preprocessor">#endif</span> | ||
404 | <a name="l00355"></a>00355 <span class="preprocessor"></span> | ||
405 | <a name="l00357"></a><a class="code" href="irr_math_8h.html#aa854d8430e0acc31adb1ddb3647f6534">00357</a> <span class="preprocessor"> #define AIR(x) (IR(x)&0x7fffffff)</span> | ||
406 | <a name="l00358"></a>00358 <span class="preprocessor"></span> | ||
407 | <a name="l00360"></a>00360 <span class="preprocessor">#ifdef IRRLICHT_FAST_MATH</span> | ||
408 | <a name="l00361"></a>00361 <span class="preprocessor"></span><span class="preprocessor"> #define FR(x) ((f32&)(x))</span> | ||
409 | <a name="l00362"></a>00362 <span class="preprocessor"></span><span class="preprocessor">#else</span> | ||
410 | <a name="l00363"></a><a class="code" href="namespaceirr_1_1core.html#ae0940bd4032e5f10cf83b460f73571a3">00363</a> <span class="preprocessor"></span> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#ae0940bd4032e5f10cf83b460f73571a3" title="Floating-point representation of an integer value.">FR</a>(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> x) {<a class="code" href="unionirr_1_1core_1_1inttofloat.html">inttofloat</a> tmp; tmp.<a class="code" href="unionirr_1_1core_1_1inttofloat.html#a87651356c7436ac7755e85189412f75a">u</a>=x; <span class="keywordflow">return</span> tmp.<a class="code" href="unionirr_1_1core_1_1inttofloat.html#ab0dd36fa35cbb368602fa0d18b2d9788">f</a>;} | ||
411 | <a name="l00364"></a><a class="code" href="namespaceirr_1_1core.html#a10bf7ddf910b7feac9a36fd141a9f5ba">00364</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#ae0940bd4032e5f10cf83b460f73571a3" title="Floating-point representation of an integer value.">FR</a>(<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> x) {<a class="code" href="unionirr_1_1core_1_1inttofloat.html">inttofloat</a> tmp; tmp.<a class="code" href="unionirr_1_1core_1_1inttofloat.html#a1adc8b3417ac325bd9695c0cbb6c043e">s</a>=x; <span class="keywordflow">return</span> tmp.<a class="code" href="unionirr_1_1core_1_1inttofloat.html#ab0dd36fa35cbb368602fa0d18b2d9788">f</a>;} | ||
412 | <a name="l00365"></a>00365 <span class="preprocessor">#endif</span> | ||
413 | <a name="l00366"></a>00366 <span class="preprocessor"></span> | ||
414 | <a name="l00368"></a><a class="code" href="irr_math_8h.html#a3ec4980c07f6b510c61230356e014d24">00368</a> <span class="preprocessor"> #define IEEE_1_0 0x3f800000</span> | ||
415 | <a name="l00369"></a>00369 <span class="preprocessor"></span> | ||
416 | <a name="l00370"></a><a class="code" href="irr_math_8h.html#a2b311316554140ac181c31d86f4f3786">00370</a> <span class="preprocessor"> #define IEEE_255_0 0x437f0000</span> | ||
417 | <a name="l00371"></a>00371 <span class="preprocessor"></span> | ||
418 | <a name="l00372"></a>00372 <span class="preprocessor">#ifdef IRRLICHT_FAST_MATH</span> | ||
419 | <a name="l00373"></a>00373 <span class="preprocessor"></span><span class="preprocessor"> #define F32_LOWER_0(f) (F32_AS_U32(f) > F32_SIGN_BIT)</span> | ||
420 | <a name="l00374"></a>00374 <span class="preprocessor"></span><span class="preprocessor"> #define F32_LOWER_EQUAL_0(f) (F32_AS_S32(f) <= F32_VALUE_0)</span> | ||
421 | <a name="l00375"></a>00375 <span class="preprocessor"></span><span class="preprocessor"> #define F32_GREATER_0(f) (F32_AS_S32(f) > F32_VALUE_0)</span> | ||
422 | <a name="l00376"></a>00376 <span class="preprocessor"></span><span class="preprocessor"> #define F32_GREATER_EQUAL_0(f) (F32_AS_U32(f) <= F32_SIGN_BIT)</span> | ||
423 | <a name="l00377"></a>00377 <span class="preprocessor"></span><span class="preprocessor"> #define F32_EQUAL_1(f) (F32_AS_U32(f) == F32_VALUE_1)</span> | ||
424 | <a name="l00378"></a>00378 <span class="preprocessor"></span><span class="preprocessor"> #define F32_EQUAL_0(f) ( (F32_AS_U32(f) & F32_EXPON_MANTISSA ) == F32_VALUE_0)</span> | ||
425 | <a name="l00379"></a>00379 <span class="preprocessor"></span> | ||
426 | <a name="l00380"></a>00380 <span class="comment">// only same sign</span> | ||
427 | <a name="l00381"></a>00381 <span class="preprocessor"> #define F32_A_GREATER_B(a,b) (F32_AS_S32((a)) > F32_AS_S32((b)))</span> | ||
428 | <a name="l00382"></a>00382 <span class="preprocessor"></span> | ||
429 | <a name="l00383"></a>00383 <span class="preprocessor">#else</span> | ||
430 | <a name="l00384"></a>00384 <span class="preprocessor"></span> | ||
431 | <a name="l00385"></a><a class="code" href="irr_math_8h.html#aa86a7d03858f88ebbf9e36592583ced6">00385</a> <span class="preprocessor"> #define F32_LOWER_0(n) ((n) < 0.0f)</span> | ||
432 | <a name="l00386"></a><a class="code" href="irr_math_8h.html#a26bc42a9cc1fc775bc588052c32ff9a0">00386</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_LOWER_EQUAL_0(n) ((n) <= 0.0f)</span> | ||
433 | <a name="l00387"></a><a class="code" href="irr_math_8h.html#a2fdc9e94ce29e1866ddf64e5903d43a1">00387</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_GREATER_0(n) ((n) > 0.0f)</span> | ||
434 | <a name="l00388"></a><a class="code" href="irr_math_8h.html#a407afe61680cc405bbe04922d36423af">00388</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_GREATER_EQUAL_0(n) ((n) >= 0.0f)</span> | ||
435 | <a name="l00389"></a><a class="code" href="irr_math_8h.html#ae907baf637203996fb3187581c2def80">00389</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_EQUAL_1(n) ((n) == 1.0f)</span> | ||
436 | <a name="l00390"></a><a class="code" href="irr_math_8h.html#a3c82a09fb606a67c19514b534d364d6c">00390</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_EQUAL_0(n) ((n) == 0.0f)</span> | ||
437 | <a name="l00391"></a><a class="code" href="irr_math_8h.html#ab4092d1d22af18e03372117e347b633c">00391</a> <span class="preprocessor"></span><span class="preprocessor"> #define F32_A_GREATER_B(a,b) ((a) > (b))</span> | ||
438 | <a name="l00392"></a>00392 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
439 | <a name="l00393"></a>00393 <span class="preprocessor"></span> | ||
440 | <a name="l00394"></a>00394 | ||
441 | <a name="l00395"></a>00395 <span class="preprocessor">#ifndef REALINLINE</span> | ||
442 | <a name="l00396"></a>00396 <span class="preprocessor"></span><span class="preprocessor"> #ifdef _MSC_VER</span> | ||
443 | <a name="l00397"></a>00397 <span class="preprocessor"></span><span class="preprocessor"> #define REALINLINE __forceinline</span> | ||
444 | <a name="l00398"></a>00398 <span class="preprocessor"></span><span class="preprocessor"> #else</span> | ||
445 | <a name="l00399"></a><a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">00399</a> <span class="preprocessor"></span><span class="preprocessor"> #define REALINLINE inline</span> | ||
446 | <a name="l00400"></a>00400 <span class="preprocessor"></span><span class="preprocessor"> #endif</span> | ||
447 | <a name="l00401"></a>00401 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
448 | <a name="l00402"></a>00402 <span class="preprocessor"></span> | ||
449 | <a name="l00403"></a>00403 <span class="preprocessor">#if defined(__BORLANDC__) || defined (__BCPLUSPLUS__)</span> | ||
450 | <a name="l00404"></a>00404 <span class="preprocessor"></span> | ||
451 | <a name="l00405"></a>00405 <span class="comment">// 8-bit bools in borland builder</span> | ||
452 | <a name="l00406"></a>00406 | ||
453 | <a name="l00408"></a>00408 <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="namespaceirr_1_1core.html#ad6426246733e5dc16713f43352d85cdb" title="conditional set based on mask and arithmetic shift">if_c_a_else_b</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> condition, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> b ) | ||
454 | <a name="l00409"></a>00409 { | ||
455 | <a name="l00410"></a>00410 <span class="keywordflow">return</span> ( ( -condition >> 7 ) & ( a ^ b ) ) ^ b; | ||
456 | <a name="l00411"></a>00411 } | ||
457 | <a name="l00412"></a>00412 | ||
458 | <a name="l00414"></a>00414 <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="namespaceirr_1_1core.html#af19c13d0084052f12357308c0cd83005" title="conditional set based on mask and arithmetic shift">if_c_a_else_0</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a9395eaea339bcb546b319e9c96bf7410" title="8 bit character variable.">c8</a> condition, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a ) | ||
459 | <a name="l00415"></a>00415 { | ||
460 | <a name="l00416"></a>00416 <span class="keywordflow">return</span> ( -condition >> 31 ) & a; | ||
461 | <a name="l00417"></a>00417 } | ||
462 | <a name="l00418"></a>00418 <span class="preprocessor">#else</span> | ||
463 | <a name="l00419"></a>00419 <span class="preprocessor"></span> | ||
464 | <a name="l00421"></a><a class="code" href="namespaceirr_1_1core.html#ad6426246733e5dc16713f43352d85cdb">00421</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="namespaceirr_1_1core.html#ad6426246733e5dc16713f43352d85cdb" title="conditional set based on mask and arithmetic shift">if_c_a_else_b</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> condition, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> b ) | ||
465 | <a name="l00422"></a>00422 { | ||
466 | <a name="l00423"></a>00423 <span class="keywordflow">return</span> ( ( -condition >> 31 ) & ( a ^ b ) ) ^ b; | ||
467 | <a name="l00424"></a>00424 } | ||
468 | <a name="l00425"></a>00425 | ||
469 | <a name="l00427"></a><a class="code" href="namespaceirr_1_1core.html#af1ec8eb919fdb81c259920cce4004329">00427</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> <a class="code" href="namespaceirr_1_1core.html#ad6426246733e5dc16713f43352d85cdb" title="conditional set based on mask and arithmetic shift">if_c_a_else_b</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a43ace0af066371ac0862bac3f7314220" title="16 bit signed variable.">s16</a> condition, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ae9f8ec82692ad3b83c21f555bfa70bcc" title="16 bit unsigned variable.">u16</a> b ) | ||
470 | <a name="l00428"></a>00428 { | ||
471 | <a name="l00429"></a>00429 <span class="keywordflow">return</span> ( ( -condition >> 15 ) & ( a ^ b ) ) ^ b; | ||
472 | <a name="l00430"></a>00430 } | ||
473 | <a name="l00431"></a>00431 | ||
474 | <a name="l00433"></a><a class="code" href="namespaceirr_1_1core.html#af19c13d0084052f12357308c0cd83005">00433</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> <a class="code" href="namespaceirr_1_1core.html#af19c13d0084052f12357308c0cd83005" title="conditional set based on mask and arithmetic shift">if_c_a_else_0</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> condition, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> a ) | ||
475 | <a name="l00434"></a>00434 { | ||
476 | <a name="l00435"></a>00435 <span class="keywordflow">return</span> ( -condition >> 31 ) & a; | ||
477 | <a name="l00436"></a>00436 } | ||
478 | <a name="l00437"></a>00437 <span class="preprocessor">#endif</span> | ||
479 | <a name="l00438"></a>00438 <span class="preprocessor"></span> | ||
480 | <a name="l00439"></a>00439 <span class="comment">/*</span> | ||
481 | <a name="l00440"></a>00440 <span class="comment"> if (condition) state |= m; else state &= ~m;</span> | ||
482 | <a name="l00441"></a>00441 <span class="comment"> */</span> | ||
483 | <a name="l00442"></a><a class="code" href="namespaceirr_1_1core.html#a628051738e8873b91b064e6014024f41">00442</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <span class="keywordtype">void</span> <a class="code" href="namespaceirr_1_1core.html#a628051738e8873b91b064e6014024f41">setbit_cond</a> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> &state, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> condition, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> mask ) | ||
484 | <a name="l00443"></a>00443 { | ||
485 | <a name="l00444"></a>00444 <span class="comment">// 0, or any postive to mask</span> | ||
486 | <a name="l00445"></a>00445 <span class="comment">//s32 conmask = -condition >> 31;</span> | ||
487 | <a name="l00446"></a>00446 state ^= ( ( -condition >> 31 ) ^ state ) & mask; | ||
488 | <a name="l00447"></a>00447 } | ||
489 | <a name="l00448"></a>00448 | ||
490 | <a name="l00449"></a><a class="code" href="namespaceirr_1_1core.html#a894a901069c34298987761c5f3d74f1f">00449</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a894a901069c34298987761c5f3d74f1f">round_</a>( <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> x ) | ||
491 | <a name="l00450"></a>00450 { | ||
492 | <a name="l00451"></a>00451 <span class="keywordflow">return</span> floorf( x + 0.5f ); | ||
493 | <a name="l00452"></a>00452 } | ||
494 | <a name="l00453"></a>00453 | ||
495 | <a name="l00454"></a><a class="code" href="namespaceirr_1_1core.html#ab4c17ceae6e2b96383e842eabb9596ab">00454</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <span class="keywordtype">void</span> <a class="code" href="namespaceirr_1_1core.html#ab4c17ceae6e2b96383e842eabb9596ab">clearFPUException</a> () | ||
496 | <a name="l00455"></a>00455 { | ||
497 | <a name="l00456"></a>00456 <span class="preprocessor">#ifdef IRRLICHT_FAST_MATH</span> | ||
498 | <a name="l00457"></a>00457 <span class="preprocessor"></span> <span class="keywordflow">return</span>; | ||
499 | <a name="l00458"></a>00458 <span class="preprocessor">#ifdef feclearexcept</span> | ||
500 | <a name="l00459"></a>00459 <span class="preprocessor"></span> feclearexcept(FE_ALL_EXCEPT); | ||
501 | <a name="l00460"></a>00460 <span class="preprocessor">#elif defined(_MSC_VER)</span> | ||
502 | <a name="l00461"></a>00461 <span class="preprocessor"></span> __asm fnclex; | ||
503 | <a name="l00462"></a>00462 <span class="preprocessor">#elif defined(__GNUC__) && defined(__x86__)</span> | ||
504 | <a name="l00463"></a>00463 <span class="preprocessor"></span> __asm__ __volatile__ (<span class="stringliteral">"fclex \n\t"</span>); | ||
505 | <a name="l00464"></a>00464 <span class="preprocessor">#else</span> | ||
506 | <a name="l00465"></a>00465 <span class="preprocessor"></span><span class="preprocessor"># warn clearFPUException not supported.</span> | ||
507 | <a name="l00466"></a>00466 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
508 | <a name="l00467"></a>00467 <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
509 | <a name="l00468"></a>00468 <span class="preprocessor"></span> } | ||
510 | <a name="l00469"></a>00469 | ||
511 | <a name="l00470"></a>00470 <span class="comment">// calculate: sqrt ( x )</span> | ||
512 | <a name="l00471"></a><a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">00471</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> f) | ||
513 | <a name="l00472"></a>00472 { | ||
514 | <a name="l00473"></a>00473 <span class="keywordflow">return</span> sqrtf(f); | ||
515 | <a name="l00474"></a>00474 } | ||
516 | <a name="l00475"></a>00475 | ||
517 | <a name="l00476"></a>00476 <span class="comment">// calculate: sqrt ( x )</span> | ||
518 | <a name="l00477"></a><a class="code" href="namespaceirr_1_1core.html#ad4378f076bf251c05e543ce888da8f48">00477</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> f) | ||
519 | <a name="l00478"></a>00478 { | ||
520 | <a name="l00479"></a>00479 <span class="keywordflow">return</span> sqrt(f); | ||
521 | <a name="l00480"></a>00480 } | ||
522 | <a name="l00481"></a>00481 | ||
523 | <a name="l00482"></a>00482 <span class="comment">// calculate: sqrt ( x )</span> | ||
524 | <a name="l00483"></a><a class="code" href="namespaceirr_1_1core.html#a6943186698de9d2ff47ce03fbe025230">00483</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> f) | ||
525 | <a name="l00484"></a>00484 { | ||
526 | <a name="l00485"></a>00485 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a><span class="keyword">></span>(<a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">squareroot</a>(static_cast<f32>(f))); | ||
527 | <a name="l00486"></a>00486 } | ||
528 | <a name="l00487"></a>00487 | ||
529 | <a name="l00488"></a>00488 <span class="preprocessor">#ifdef __IRR_HAS_S64</span> | ||
530 | <a name="l00489"></a>00489 <span class="preprocessor"></span> <span class="comment">// calculate: sqrt ( x )</span> | ||
531 | <a name="l00490"></a><a class="code" href="namespaceirr_1_1core.html#a9a79fc4c36183e75d70c740b2b9f1865">00490</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> <a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a> f) | ||
532 | <a name="l00491"></a>00491 { | ||
533 | <a name="l00492"></a>00492 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><a class="code" href="namespaceirr.html#abf54bd535f8d4dd996270e68c3ad8c08" title="64 bit signed variable.">s64</a><span class="keyword">></span>(<a class="code" href="namespaceirr_1_1core.html#af2f378cc34a19f5da6fe1d4961646d1d">squareroot</a>(static_cast<f64>(f))); | ||
534 | <a name="l00493"></a>00493 } | ||
535 | <a name="l00494"></a>00494 <span class="preprocessor">#endif</span> | ||
536 | <a name="l00495"></a>00495 <span class="preprocessor"></span> | ||
537 | <a name="l00496"></a>00496 <span class="comment">// calculate: 1 / sqrt ( x )</span> | ||
538 | <a name="l00497"></a><a class="code" href="namespaceirr_1_1core.html#adaef309f12c2a3386e94610e24f2bfa7">00497</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#adaef309f12c2a3386e94610e24f2bfa7">reciprocal_squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> x) | ||
539 | <a name="l00498"></a>00498 { | ||
540 | <a name="l00499"></a>00499 <span class="keywordflow">return</span> 1.0 / sqrt(x); | ||
541 | <a name="l00500"></a>00500 } | ||
542 | <a name="l00501"></a>00501 | ||
543 | <a name="l00502"></a>00502 <span class="comment">// calculate: 1 / sqrtf ( x )</span> | ||
544 | <a name="l00503"></a><a class="code" href="namespaceirr_1_1core.html#a42eb747bb19d6ca2cb9d8977eb402c72">00503</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#adaef309f12c2a3386e94610e24f2bfa7">reciprocal_squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> f) | ||
545 | <a name="l00504"></a>00504 { | ||
546 | <a name="l00505"></a>00505 <span class="preprocessor">#if defined ( IRRLICHT_FAST_MATH )</span> | ||
547 | <a name="l00506"></a>00506 <span class="preprocessor"></span><span class="preprocessor"> #if defined(_MSC_VER)</span> | ||
548 | <a name="l00507"></a>00507 <span class="preprocessor"></span> <span class="comment">// SSE reciprocal square root estimate, accurate to 12 significant</span> | ||
549 | <a name="l00508"></a>00508 <span class="comment">// bits of the mantissa</span> | ||
550 | <a name="l00509"></a>00509 <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> recsqrt; | ||
551 | <a name="l00510"></a>00510 __asm rsqrtss xmm0, f <span class="comment">// xmm0 = rsqrtss(f)</span> | ||
552 | <a name="l00511"></a>00511 __asm movss recsqrt, xmm0 <span class="comment">// return xmm0</span> | ||
553 | <a name="l00512"></a>00512 <span class="keywordflow">return</span> recsqrt; | ||
554 | <a name="l00513"></a>00513 | ||
555 | <a name="l00514"></a>00514 <span class="comment">/*</span> | ||
556 | <a name="l00515"></a>00515 <span class="comment"> // comes from Nvidia</span> | ||
557 | <a name="l00516"></a>00516 <span class="comment"> u32 tmp = (u32(IEEE_1_0 << 1) + IEEE_1_0 - *(u32*)&x) >> 1;</span> | ||
558 | <a name="l00517"></a>00517 <span class="comment"> f32 y = *(f32*)&tmp;</span> | ||
559 | <a name="l00518"></a>00518 <span class="comment"> return y * (1.47f - 0.47f * x * y * y);</span> | ||
560 | <a name="l00519"></a>00519 <span class="comment">*/</span> | ||
561 | <a name="l00520"></a>00520 <span class="preprocessor"> #else</span> | ||
562 | <a name="l00521"></a>00521 <span class="preprocessor"></span> <span class="keywordflow">return</span> 1.f / sqrtf(f); | ||
563 | <a name="l00522"></a>00522 <span class="preprocessor"> #endif</span> | ||
564 | <a name="l00523"></a>00523 <span class="preprocessor"></span><span class="preprocessor">#else // no fast math</span> | ||
565 | <a name="l00524"></a>00524 <span class="preprocessor"></span> <span class="keywordflow">return</span> 1.f / sqrtf(f); | ||
566 | <a name="l00525"></a>00525 <span class="preprocessor">#endif</span> | ||
567 | <a name="l00526"></a>00526 <span class="preprocessor"></span> } | ||
568 | <a name="l00527"></a>00527 | ||
569 | <a name="l00528"></a>00528 <span class="comment">// calculate: 1 / sqrtf( x )</span> | ||
570 | <a name="l00529"></a><a class="code" href="namespaceirr_1_1core.html#a21c37238a7754b48ff18c486202a1e4b">00529</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#adaef309f12c2a3386e94610e24f2bfa7">reciprocal_squareroot</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> x) | ||
571 | <a name="l00530"></a>00530 { | ||
572 | <a name="l00531"></a>00531 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a><span class="keyword">></span>(<a class="code" href="namespaceirr_1_1core.html#adaef309f12c2a3386e94610e24f2bfa7">reciprocal_squareroot</a>(static_cast<f32>(x))); | ||
573 | <a name="l00532"></a>00532 } | ||
574 | <a name="l00533"></a>00533 | ||
575 | <a name="l00534"></a>00534 <span class="comment">// calculate: 1 / x</span> | ||
576 | <a name="l00535"></a><a class="code" href="namespaceirr_1_1core.html#aa01390f49052dfe07e16ee6c5233f4eb">00535</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#aa01390f49052dfe07e16ee6c5233f4eb">reciprocal</a>( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> f ) | ||
577 | <a name="l00536"></a>00536 { | ||
578 | <a name="l00537"></a>00537 <span class="preprocessor">#if defined (IRRLICHT_FAST_MATH)</span> | ||
579 | <a name="l00538"></a>00538 <span class="preprocessor"></span> | ||
580 | <a name="l00539"></a>00539 <span class="comment">// SSE Newton-Raphson reciprocal estimate, accurate to 23 significant</span> | ||
581 | <a name="l00540"></a>00540 <span class="comment">// bi ts of the mantissa</span> | ||
582 | <a name="l00541"></a>00541 <span class="comment">// One Newtown-Raphson Iteration:</span> | ||
583 | <a name="l00542"></a>00542 <span class="comment">// f(i+1) = 2 * rcpss(f) - f * rcpss(f) * rcpss(f)</span> | ||
584 | <a name="l00543"></a>00543 <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> rec; | ||
585 | <a name="l00544"></a>00544 __asm rcpss xmm0, f <span class="comment">// xmm0 = rcpss(f)</span> | ||
586 | <a name="l00545"></a>00545 __asm movss xmm1, f <span class="comment">// xmm1 = f</span> | ||
587 | <a name="l00546"></a>00546 __asm mulss xmm1, xmm0 <span class="comment">// xmm1 = f * rcpss(f)</span> | ||
588 | <a name="l00547"></a>00547 __asm mulss xmm1, xmm0 <span class="comment">// xmm2 = f * rcpss(f) * rcpss(f)</span> | ||
589 | <a name="l00548"></a>00548 __asm addss xmm0, xmm0 <span class="comment">// xmm0 = 2 * rcpss(f)</span> | ||
590 | <a name="l00549"></a>00549 __asm subss xmm0, xmm1 <span class="comment">// xmm0 = 2 * rcpss(f)</span> | ||
591 | <a name="l00550"></a>00550 <span class="comment">// - f * rcpss(f) * rcpss(f)</span> | ||
592 | <a name="l00551"></a>00551 __asm movss rec, xmm0 <span class="comment">// return xmm0</span> | ||
593 | <a name="l00552"></a>00552 <span class="keywordflow">return</span> rec; | ||
594 | <a name="l00553"></a>00553 | ||
595 | <a name="l00554"></a>00554 | ||
596 | <a name="l00556"></a>00556 <span class="comment">// instead set f to a high value to get a return value near zero..</span> | ||
597 | <a name="l00557"></a>00557 <span class="comment">// -1000000000000.f.. is use minus to stay negative..</span> | ||
598 | <a name="l00558"></a>00558 <span class="comment">// must test's here (plane.normal dot anything ) checks on <= 0.f</span> | ||
599 | <a name="l00559"></a>00559 <span class="comment">//u32 x = (-(AIR(f) != 0 ) >> 31 ) & ( IR(f) ^ 0xd368d4a5 ) ^ 0xd368d4a5;</span> | ||
600 | <a name="l00560"></a>00560 <span class="comment">//return 1.f / FR ( x );</span> | ||
601 | <a name="l00561"></a>00561 | ||
602 | <a name="l00562"></a>00562 <span class="preprocessor">#else // no fast math</span> | ||
603 | <a name="l00563"></a>00563 <span class="preprocessor"></span> <span class="keywordflow">return</span> 1.f / f; | ||
604 | <a name="l00564"></a>00564 <span class="preprocessor">#endif</span> | ||
605 | <a name="l00565"></a>00565 <span class="preprocessor"></span> } | ||
606 | <a name="l00566"></a>00566 | ||
607 | <a name="l00567"></a>00567 <span class="comment">// calculate: 1 / x</span> | ||
608 | <a name="l00568"></a><a class="code" href="namespaceirr_1_1core.html#ac4402e2ec5b151212168736b8cfdd587">00568</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> <a class="code" href="namespaceirr_1_1core.html#aa01390f49052dfe07e16ee6c5233f4eb">reciprocal</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a1325b02603ad449f92c68fc640af9b28" title="64 bit floating point variable.">f64</a> f ) | ||
609 | <a name="l00569"></a>00569 { | ||
610 | <a name="l00570"></a>00570 <span class="keywordflow">return</span> 1.0 / f; | ||
611 | <a name="l00571"></a>00571 } | ||
612 | <a name="l00572"></a>00572 | ||
613 | <a name="l00573"></a>00573 | ||
614 | <a name="l00574"></a>00574 <span class="comment">// calculate: 1 / x, low precision allowed</span> | ||
615 | <a name="l00575"></a><a class="code" href="namespaceirr_1_1core.html#ab5de17006aac4618e43d5f816ffc97c9">00575</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#ab5de17006aac4618e43d5f816ffc97c9">reciprocal_approxim</a> ( <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> f ) | ||
616 | <a name="l00576"></a>00576 { | ||
617 | <a name="l00577"></a>00577 <span class="preprocessor">#if defined( IRRLICHT_FAST_MATH)</span> | ||
618 | <a name="l00578"></a>00578 <span class="preprocessor"></span> | ||
619 | <a name="l00579"></a>00579 <span class="comment">// SSE Newton-Raphson reciprocal estimate, accurate to 23 significant</span> | ||
620 | <a name="l00580"></a>00580 <span class="comment">// bi ts of the mantissa</span> | ||
621 | <a name="l00581"></a>00581 <span class="comment">// One Newtown-Raphson Iteration:</span> | ||
622 | <a name="l00582"></a>00582 <span class="comment">// f(i+1) = 2 * rcpss(f) - f * rcpss(f) * rcpss(f)</span> | ||
623 | <a name="l00583"></a>00583 <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> rec; | ||
624 | <a name="l00584"></a>00584 __asm rcpss xmm0, f <span class="comment">// xmm0 = rcpss(f)</span> | ||
625 | <a name="l00585"></a>00585 __asm movss xmm1, f <span class="comment">// xmm1 = f</span> | ||
626 | <a name="l00586"></a>00586 __asm mulss xmm1, xmm0 <span class="comment">// xmm1 = f * rcpss(f)</span> | ||
627 | <a name="l00587"></a>00587 __asm mulss xmm1, xmm0 <span class="comment">// xmm2 = f * rcpss(f) * rcpss(f)</span> | ||
628 | <a name="l00588"></a>00588 __asm addss xmm0, xmm0 <span class="comment">// xmm0 = 2 * rcpss(f)</span> | ||
629 | <a name="l00589"></a>00589 __asm subss xmm0, xmm1 <span class="comment">// xmm0 = 2 * rcpss(f)</span> | ||
630 | <a name="l00590"></a>00590 <span class="comment">// - f * rcpss(f) * rcpss(f)</span> | ||
631 | <a name="l00591"></a>00591 __asm movss rec, xmm0 <span class="comment">// return xmm0</span> | ||
632 | <a name="l00592"></a>00592 <span class="keywordflow">return</span> rec; | ||
633 | <a name="l00593"></a>00593 | ||
634 | <a name="l00594"></a>00594 | ||
635 | <a name="l00595"></a>00595 <span class="comment">/*</span> | ||
636 | <a name="l00596"></a>00596 <span class="comment"> // SSE reciprocal estimate, accurate to 12 significant bits of</span> | ||
637 | <a name="l00597"></a>00597 <span class="comment"> f32 rec;</span> | ||
638 | <a name="l00598"></a>00598 <span class="comment"> __asm rcpss xmm0, f // xmm0 = rcpss(f)</span> | ||
639 | <a name="l00599"></a>00599 <span class="comment"> __asm movss rec , xmm0 // return xmm0</span> | ||
640 | <a name="l00600"></a>00600 <span class="comment"> return rec;</span> | ||
641 | <a name="l00601"></a>00601 <span class="comment">*/</span> | ||
642 | <a name="l00602"></a>00602 <span class="comment">/*</span> | ||
643 | <a name="l00603"></a>00603 <span class="comment"> register u32 x = 0x7F000000 - IR ( p );</span> | ||
644 | <a name="l00604"></a>00604 <span class="comment"> const f32 r = FR ( x );</span> | ||
645 | <a name="l00605"></a>00605 <span class="comment"> return r * (2.0f - p * r);</span> | ||
646 | <a name="l00606"></a>00606 <span class="comment">*/</span> | ||
647 | <a name="l00607"></a>00607 <span class="preprocessor">#else // no fast math</span> | ||
648 | <a name="l00608"></a>00608 <span class="preprocessor"></span> <span class="keywordflow">return</span> 1.f / f; | ||
649 | <a name="l00609"></a>00609 <span class="preprocessor">#endif</span> | ||
650 | <a name="l00610"></a>00610 <span class="preprocessor"></span> } | ||
651 | <a name="l00611"></a>00611 | ||
652 | <a name="l00612"></a>00612 | ||
653 | <a name="l00613"></a><a class="code" href="namespaceirr_1_1core.html#ac230a392b15e3d27c6e2a07a6925a8c4">00613</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#ac230a392b15e3d27c6e2a07a6925a8c4">floor32</a>(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> x) | ||
654 | <a name="l00614"></a>00614 { | ||
655 | <a name="l00615"></a>00615 <span class="preprocessor">#ifdef IRRLICHT_FAST_MATH</span> | ||
656 | <a name="l00616"></a>00616 <span class="preprocessor"></span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> h = 0.5f; | ||
657 | <a name="l00617"></a>00617 | ||
658 | <a name="l00618"></a>00618 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> t; | ||
659 | <a name="l00619"></a>00619 | ||
660 | <a name="l00620"></a>00620 <span class="preprocessor">#if defined(_MSC_VER)</span> | ||
661 | <a name="l00621"></a>00621 <span class="preprocessor"></span> __asm | ||
662 | <a name="l00622"></a>00622 { | ||
663 | <a name="l00623"></a>00623 fld x | ||
664 | <a name="l00624"></a>00624 fsub h | ||
665 | <a name="l00625"></a>00625 fistp t | ||
666 | <a name="l00626"></a>00626 } | ||
667 | <a name="l00627"></a>00627 <span class="preprocessor">#elif defined(__GNUC__)</span> | ||
668 | <a name="l00628"></a>00628 <span class="preprocessor"></span> __asm__ __volatile__ ( | ||
669 | <a name="l00629"></a>00629 <span class="stringliteral">"fsub %2 \n\t"</span> | ||
670 | <a name="l00630"></a>00630 <span class="stringliteral">"fistpl %0"</span> | ||
671 | <a name="l00631"></a>00631 : <span class="stringliteral">"=m"</span> (t) | ||
672 | <a name="l00632"></a>00632 : <span class="stringliteral">"t"</span> (x), <span class="stringliteral">"f"</span> (h) | ||
673 | <a name="l00633"></a>00633 : <span class="stringliteral">"st"</span> | ||
674 | <a name="l00634"></a>00634 ); | ||
675 | <a name="l00635"></a>00635 <span class="preprocessor">#else</span> | ||
676 | <a name="l00636"></a>00636 <span class="preprocessor"></span><span class="preprocessor"># warn IRRLICHT_FAST_MATH not supported.</span> | ||
677 | <a name="l00637"></a>00637 <span class="preprocessor"></span> <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) floorf ( x ); | ||
678 | <a name="l00638"></a>00638 <span class="preprocessor">#endif</span> | ||
679 | <a name="l00639"></a>00639 <span class="preprocessor"></span> <span class="keywordflow">return</span> t; | ||
680 | <a name="l00640"></a>00640 <span class="preprocessor">#else // no fast math</span> | ||
681 | <a name="l00641"></a>00641 <span class="preprocessor"></span> <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) floorf ( x ); | ||
682 | <a name="l00642"></a>00642 <span class="preprocessor">#endif</span> | ||
683 | <a name="l00643"></a>00643 <span class="preprocessor"></span> } | ||
684 | <a name="l00644"></a>00644 | ||
685 | <a name="l00645"></a>00645 | ||
686 | <a name="l00646"></a><a class="code" href="namespaceirr_1_1core.html#a0fb8b4d0f177af411fdd4bd94b6779ce">00646</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#a0fb8b4d0f177af411fdd4bd94b6779ce">ceil32</a> ( <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> x ) | ||
687 | <a name="l00647"></a>00647 { | ||
688 | <a name="l00648"></a>00648 <span class="preprocessor">#ifdef IRRLICHT_FAST_MATH</span> | ||
689 | <a name="l00649"></a>00649 <span class="preprocessor"></span> <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> h = 0.5f; | ||
690 | <a name="l00650"></a>00650 | ||
691 | <a name="l00651"></a>00651 <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> t; | ||
692 | <a name="l00652"></a>00652 | ||
693 | <a name="l00653"></a>00653 <span class="preprocessor">#if defined(_MSC_VER)</span> | ||
694 | <a name="l00654"></a>00654 <span class="preprocessor"></span> __asm | ||
695 | <a name="l00655"></a>00655 { | ||
696 | <a name="l00656"></a>00656 fld x | ||
697 | <a name="l00657"></a>00657 fadd h | ||
698 | <a name="l00658"></a>00658 fistp t | ||
699 | <a name="l00659"></a>00659 } | ||
700 | <a name="l00660"></a>00660 <span class="preprocessor">#elif defined(__GNUC__)</span> | ||
701 | <a name="l00661"></a>00661 <span class="preprocessor"></span> __asm__ __volatile__ ( | ||
702 | <a name="l00662"></a>00662 <span class="stringliteral">"fadd %2 \n\t"</span> | ||
703 | <a name="l00663"></a>00663 <span class="stringliteral">"fistpl %0 \n\t"</span> | ||
704 | <a name="l00664"></a>00664 : <span class="stringliteral">"=m"</span>(t) | ||
705 | <a name="l00665"></a>00665 : <span class="stringliteral">"t"</span>(x), <span class="stringliteral">"f"</span>(h) | ||
706 | <a name="l00666"></a>00666 : <span class="stringliteral">"st"</span> | ||
707 | <a name="l00667"></a>00667 ); | ||
708 | <a name="l00668"></a>00668 <span class="preprocessor">#else</span> | ||
709 | <a name="l00669"></a>00669 <span class="preprocessor"></span><span class="preprocessor"># warn IRRLICHT_FAST_MATH not supported.</span> | ||
710 | <a name="l00670"></a>00670 <span class="preprocessor"></span> <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) ceilf ( x ); | ||
711 | <a name="l00671"></a>00671 <span class="preprocessor">#endif</span> | ||
712 | <a name="l00672"></a>00672 <span class="preprocessor"></span> <span class="keywordflow">return</span> t; | ||
713 | <a name="l00673"></a>00673 <span class="preprocessor">#else // not fast math</span> | ||
714 | <a name="l00674"></a>00674 <span class="preprocessor"></span> <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) ceilf ( x ); | ||
715 | <a name="l00675"></a>00675 <span class="preprocessor">#endif</span> | ||
716 | <a name="l00676"></a>00676 <span class="preprocessor"></span> } | ||
717 | <a name="l00677"></a>00677 | ||
718 | <a name="l00678"></a>00678 | ||
719 | <a name="l00679"></a>00679 | ||
720 | <a name="l00680"></a><a class="code" href="namespaceirr_1_1core.html#ae46f57f03e9033c57c180fbe83b04cf2">00680</a> <a class="code" href="irr_math_8h.html#a3695e51e0a187a6c49684ba3206b0d0a">REALINLINE</a> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> <a class="code" href="namespaceirr_1_1core.html#ae46f57f03e9033c57c180fbe83b04cf2">round32</a>(<a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> x) | ||
721 | <a name="l00681"></a>00681 { | ||
722 | <a name="l00682"></a>00682 <span class="preprocessor">#if defined(IRRLICHT_FAST_MATH)</span> | ||
723 | <a name="l00683"></a>00683 <span class="preprocessor"></span> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> t; | ||
724 | <a name="l00684"></a>00684 | ||
725 | <a name="l00685"></a>00685 <span class="preprocessor">#if defined(_MSC_VER)</span> | ||
726 | <a name="l00686"></a>00686 <span class="preprocessor"></span> __asm | ||
727 | <a name="l00687"></a>00687 { | ||
728 | <a name="l00688"></a>00688 fld x | ||
729 | <a name="l00689"></a>00689 fistp t | ||
730 | <a name="l00690"></a>00690 } | ||
731 | <a name="l00691"></a>00691 <span class="preprocessor">#elif defined(__GNUC__)</span> | ||
732 | <a name="l00692"></a>00692 <span class="preprocessor"></span> __asm__ __volatile__ ( | ||
733 | <a name="l00693"></a>00693 <span class="stringliteral">"fistpl %0 \n\t"</span> | ||
734 | <a name="l00694"></a>00694 : <span class="stringliteral">"=m"</span>(t) | ||
735 | <a name="l00695"></a>00695 : <span class="stringliteral">"t"</span>(x) | ||
736 | <a name="l00696"></a>00696 : <span class="stringliteral">"st"</span> | ||
737 | <a name="l00697"></a>00697 ); | ||
738 | <a name="l00698"></a>00698 <span class="preprocessor">#else</span> | ||
739 | <a name="l00699"></a>00699 <span class="preprocessor"></span><span class="preprocessor"># warn IRRLICHT_FAST_MATH not supported.</span> | ||
740 | <a name="l00700"></a>00700 <span class="preprocessor"></span> <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) <a class="code" href="namespaceirr_1_1core.html#a894a901069c34298987761c5f3d74f1f">round_</a>(x); | ||
741 | <a name="l00701"></a>00701 <span class="preprocessor">#endif</span> | ||
742 | <a name="l00702"></a>00702 <span class="preprocessor"></span> <span class="keywordflow">return</span> t; | ||
743 | <a name="l00703"></a>00703 <span class="preprocessor">#else // no fast math</span> | ||
744 | <a name="l00704"></a>00704 <span class="preprocessor"></span> <span class="keywordflow">return</span> (<a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a>) <a class="code" href="namespaceirr_1_1core.html#a894a901069c34298987761c5f3d74f1f">round_</a>(x); | ||
745 | <a name="l00705"></a>00705 <span class="preprocessor">#endif</span> | ||
746 | <a name="l00706"></a>00706 <span class="preprocessor"></span> } | ||
747 | <a name="l00707"></a>00707 | ||
748 | <a name="l00708"></a><a class="code" href="namespaceirr_1_1core.html#a944684da42c3118ebe85ec9c3f77c331">00708</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a944684da42c3118ebe85ec9c3f77c331">f32_max3</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> c) | ||
749 | <a name="l00709"></a>00709 { | ||
750 | <a name="l00710"></a>00710 <span class="keywordflow">return</span> a > b ? (a > c ? a : c) : (b > c ? b : c); | ||
751 | <a name="l00711"></a>00711 } | ||
752 | <a name="l00712"></a>00712 | ||
753 | <a name="l00713"></a><a class="code" href="namespaceirr_1_1core.html#a8d7bec533c867b22d0e870236ecf4bad">00713</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#a8d7bec533c867b22d0e870236ecf4bad">f32_min3</a>(<span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> a, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> b, <span class="keyword">const</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> c) | ||
754 | <a name="l00714"></a>00714 { | ||
755 | <a name="l00715"></a>00715 <span class="keywordflow">return</span> a < b ? (a < c ? a : c) : (b < c ? b : c); | ||
756 | <a name="l00716"></a>00716 } | ||
757 | <a name="l00717"></a>00717 | ||
758 | <a name="l00718"></a><a class="code" href="namespaceirr_1_1core.html#adf530866e57502da85e6a1f0c23932a2">00718</a> <span class="keyword">inline</span> <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> <a class="code" href="namespaceirr_1_1core.html#adf530866e57502da85e6a1f0c23932a2">fract</a> ( <a class="code" href="namespaceirr.html#a0277be98d67dc26ff93b1a6a1d086b07" title="32 bit floating point variable.">f32</a> x ) | ||
759 | <a name="l00719"></a>00719 { | ||
760 | <a name="l00720"></a>00720 <span class="keywordflow">return</span> x - floorf ( x ); | ||
761 | <a name="l00721"></a>00721 } | ||
762 | <a name="l00722"></a>00722 | ||
763 | <a name="l00723"></a>00723 } <span class="comment">// end namespace core</span> | ||
764 | <a name="l00724"></a>00724 } <span class="comment">// end namespace irr</span> | ||
765 | <a name="l00725"></a>00725 | ||
766 | <a name="l00726"></a>00726 <span class="preprocessor">#ifndef IRRLICHT_FAST_MATH</span> | ||
767 | <a name="l00727"></a>00727 <span class="preprocessor"></span> <span class="keyword">using</span> <a class="code" href="namespaceirr_1_1core.html#aff42ea2c4d80cb7b45b71d1f63c6a226">irr::core::IR</a>; | ||
768 | <a name="l00728"></a>00728 <span class="keyword">using</span> <a class="code" href="namespaceirr_1_1core.html#ae0940bd4032e5f10cf83b460f73571a3" title="Floating-point representation of an integer value.">irr::core::FR</a>; | ||
769 | <a name="l00729"></a>00729 <span class="preprocessor">#endif</span> | ||
770 | <a name="l00730"></a>00730 <span class="preprocessor"></span> | ||
771 | <a name="l00731"></a>00731 <span class="preprocessor">#endif</span> | ||
772 | <a name="l00732"></a>00732 <span class="preprocessor"></span> | ||
773 | </pre></div></div> | ||
774 | </div> | ||
775 | <div id="nav-path" class="navpath"> | ||
776 | <ul> | ||
777 | <li class="navelem"><a class="el" href="irr_math_8h.html">irrMath.h</a> </li> | ||
778 | <!-- window showing the filter options --> | ||
779 | <div id="MSearchSelectWindow" | ||
780 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
781 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
782 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | ||
783 | <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</a></div> | ||
784 | |||
785 | <!-- iframe showing the search results (closed by default) --> | ||
786 | <div id="MSearchResultsWindow"> | ||
787 | <iframe src="javascript:void(0)" frameborder="0" | ||
788 | name="MSearchResults" id="MSearchResults"> | ||
789 | </iframe> | ||
790 | </div> | ||
791 | |||
792 | |||
793 | <li class="footer"> | ||
794 | <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht | ||
795 | Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Sun Nov 17 2013 20:18:40 for Irrlicht 3D Engine by | ||
796 | <a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li> | ||
797 | </ul> | ||
798 | </div> | ||
799 | |||
800 | |||
801 | </body> | ||
802 | </html> | ||