a00043_source.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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>func_common.hpp Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.4 -->
  11. <div id="top">
  12. <div id="titlearea">
  13. <table cellspacing="0" cellpadding="0">
  14. <tbody>
  15. <tr style="height: 56px;">
  16. <td id="projectlogo"><img alt="Logo" src="logo-mini.png"/></td>
  17. </tr>
  18. </tbody>
  19. </table>
  20. </div>
  21. <div id="navrow1" class="tabs">
  22. <ul class="tablist">
  23. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  24. <li><a href="modules.html"><span>Modules</span></a></li>
  25. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  26. <li><a href="annotated.html"><span>Classes</span></a></li>
  27. <li class="current"><a href="files.html"><span>Files</span></a></li>
  28. </ul>
  29. </div>
  30. <div id="navrow2" class="tabs2">
  31. <ul class="tablist">
  32. <li><a href="files.html"><span>File&#160;List</span></a></li>
  33. </ul>
  34. </div>
  35. <div class="header">
  36. <div class="headertitle">
  37. <div class="title">func_common.hpp</div> </div>
  38. </div>
  39. <div class="contents">
  40. <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
  41. <a name="l00002"></a>00002 <span class="comment">// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)</span>
  42. <a name="l00004"></a>00004 <span class="comment"></span><span class="comment">// Created : 2008-03-08</span>
  43. <a name="l00005"></a>00005 <span class="comment">// Updated : 2010-01-26</span>
  44. <a name="l00006"></a>00006 <span class="comment">// Licence : This source is under MIT License</span>
  45. <a name="l00007"></a>00007 <span class="comment">// File : glm/core/func_common.hpp</span>
  46. <a name="l00009"></a>00009 <span class="comment"></span>
  47. <a name="l00010"></a>00010 <span class="preprocessor">#ifndef glm_core_func_common</span>
  48. <a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define glm_core_func_common</span>
  49. <a name="l00012"></a>00012 <span class="preprocessor"></span>
  50. <a name="l00013"></a>00013 <span class="preprocessor">#include &quot;_fixes.hpp&quot;</span>
  51. <a name="l00014"></a>00014
  52. <a name="l00015"></a>00015 <span class="keyword">namespace </span>glm
  53. <a name="l00016"></a>00016 {
  54. <a name="l00017"></a><a class="code" href="a00144.html">00017</a> <span class="keyword">namespace </span>core{
  55. <a name="l00018"></a><a class="code" href="a00145.html">00018</a> <span class="keyword">namespace </span>function{
  56. <a name="l00019"></a>00019 <span class="keyword">namespace </span>common{
  57. <a name="l00020"></a>00020
  58. <a name="l00023"></a>00023
  59. <a name="l00028"></a>00028 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genFIType&gt;
  60. <a name="l00029"></a>00029 genFIType <a class="code" href="a00238.html#ga5206aa60ce61ad1d7d1b53d5028c7a2a" title="Returns x if x &gt;= 0; otherwise, it returns -x.">abs</a>(genFIType <span class="keyword">const</span> &amp; x);
  61. <a name="l00030"></a>00030
  62. <a name="l00035"></a>00035 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genFIType&gt;
  63. <a name="l00036"></a>00036 genFIType <a class="code" href="a00238.html#ga992a45e46af5dc123e688808d1bae48f" title="Returns 1.0 if x &gt; 0, 0.0 if x == 0, or -1.0 if x &lt; 0.">sign</a>(genFIType <span class="keyword">const</span> &amp; x);
  64. <a name="l00037"></a>00037
  65. <a name="l00042"></a>00042 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  66. <a name="l00043"></a>00043 genType <a class="code" href="a00238.html#ga4206a98e812c2bd4801e4d299c83f6c7" title="Returns a value equal to the nearest integer that is less then or equal to x.">floor</a>(genType <span class="keyword">const</span> &amp; x);
  67. <a name="l00044"></a>00044
  68. <a name="l00050"></a>00050 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  69. <a name="l00051"></a>00051 genType <a class="code" href="a00238.html#ga2303d814e83b34ee2d5f34fcff7fa275" title="Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolut...">trunc</a>(genType <span class="keyword">const</span> &amp; x);
  70. <a name="l00052"></a>00052
  71. <a name="l00061"></a>00061 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  72. <a name="l00062"></a>00062 genType <a class="code" href="a00238.html#gaa4cb0836cd9457ac6cedd3366333b16f" title="Returns a value equal to the nearest integer to x.">round</a>(genType <span class="keyword">const</span> &amp; x);
  73. <a name="l00063"></a>00063
  74. <a name="l00070"></a>00070 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  75. <a name="l00071"></a>00071 genType <a class="code" href="a00238.html#ga656ce625ba1dc1d137bfc7cc7b2ab50b" title="Returns a value equal to the nearest integer to x.">roundEven</a>(genType <span class="keyword">const</span> &amp; x);
  76. <a name="l00072"></a>00072
  77. <a name="l00078"></a>00078 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  78. <a name="l00079"></a>00079 genType <a class="code" href="a00238.html#ga828376ee58b02d80d91eee97c50323f8" title="Returns a value equal to the nearest integer that is greater than or equal to x.">ceil</a>(genType <span class="keyword">const</span> &amp; x);
  79. <a name="l00080"></a>00080
  80. <a name="l00085"></a>00085 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  81. <a name="l00086"></a>00086 genType <a class="code" href="a00238.html#ga67dda5fd839bc489827be9e225847a45" title="Return x - floor(x).">fract</a>(genType <span class="keyword">const</span> &amp; x);
  82. <a name="l00087"></a>00087
  83. <a name="l00093"></a>00093 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  84. <a name="l00094"></a>00094 genType <a class="code" href="a00238.html#ga73fa91f6041b135083b0dea6e88c7aba" title="Modulus.">mod</a>(
  85. <a name="l00095"></a>00095 genType <span class="keyword">const</span> &amp; x,
  86. <a name="l00096"></a>00096 genType <span class="keyword">const</span> &amp; y);
  87. <a name="l00097"></a>00097
  88. <a name="l00103"></a>00103 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  89. <a name="l00104"></a>00104 genType <a class="code" href="a00238.html#ga73fa91f6041b135083b0dea6e88c7aba" title="Modulus.">mod</a>(
  90. <a name="l00105"></a>00105 genType <span class="keyword">const</span> &amp; x,
  91. <a name="l00106"></a>00106 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; y);
  92. <a name="l00107"></a>00107
  93. <a name="l00115"></a>00115 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  94. <a name="l00116"></a>00116 genType <a class="code" href="a00238.html#ga3f3cec79cc1542950cd4cddb7ab67584" title="Returns the fractional part of x and sets i to the integer part (as a whole number floating point val...">modf</a>(
  95. <a name="l00117"></a>00117 genType <span class="keyword">const</span> &amp; x,
  96. <a name="l00118"></a>00118 genType &amp; i);
  97. <a name="l00119"></a>00119
  98. <a name="l00124"></a>00124 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  99. <a name="l00125"></a>00125 genType <a class="code" href="a00238.html#gacbc721d96bff24d97ed7989d35f27067" title="Returns y if y &lt; x; otherwise, it returns x.">min</a>(
  100. <a name="l00126"></a>00126 genType <span class="keyword">const</span> &amp; x,
  101. <a name="l00127"></a>00127 genType <span class="keyword">const</span> &amp; y);
  102. <a name="l00128"></a>00128
  103. <a name="l00129"></a>00129 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  104. <a name="l00130"></a>00130 genType <a class="code" href="a00238.html#gacbc721d96bff24d97ed7989d35f27067" title="Returns y if y &lt; x; otherwise, it returns x.">min</a>(
  105. <a name="l00131"></a>00131 genType <span class="keyword">const</span> &amp; x,
  106. <a name="l00132"></a>00132 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; y);
  107. <a name="l00133"></a>00133
  108. <a name="l00138"></a>00138 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  109. <a name="l00139"></a>00139 genType <a class="code" href="a00238.html#ga33a594380eeb7ac803c747298563d084" title="Returns y if x &lt; y; otherwise, it returns x.">max</a>(
  110. <a name="l00140"></a>00140 genType <span class="keyword">const</span> &amp; x,
  111. <a name="l00141"></a>00141 genType <span class="keyword">const</span> &amp; y);
  112. <a name="l00142"></a>00142
  113. <a name="l00143"></a>00143 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  114. <a name="l00144"></a>00144 genType <a class="code" href="a00238.html#ga33a594380eeb7ac803c747298563d084" title="Returns y if x &lt; y; otherwise, it returns x.">max</a>(
  115. <a name="l00145"></a>00145 genType <span class="keyword">const</span> &amp; x,
  116. <a name="l00146"></a>00146 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; y);
  117. <a name="l00147"></a>00147
  118. <a name="l00153"></a>00153 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  119. <a name="l00154"></a>00154 genType <a class="code" href="a00238.html#ga8d9331a9bd3aa06e1d10eb7fa0dbb9e5" title="Returns min(max(x, minVal), maxVal) for each component in x.">clamp</a>(
  120. <a name="l00155"></a>00155 genType <span class="keyword">const</span> &amp; x,
  121. <a name="l00156"></a>00156 genType <span class="keyword">const</span> &amp; minVal,
  122. <a name="l00157"></a>00157 genType <span class="keyword">const</span> &amp; maxVal);
  123. <a name="l00158"></a>00158
  124. <a name="l00159"></a>00159 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  125. <a name="l00160"></a>00160 genType <a class="code" href="a00238.html#ga8d9331a9bd3aa06e1d10eb7fa0dbb9e5" title="Returns min(max(x, minVal), maxVal) for each component in x.">clamp</a>(
  126. <a name="l00161"></a>00161 genType <span class="keyword">const</span> &amp; x,
  127. <a name="l00162"></a>00162 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; minVal,
  128. <a name="l00163"></a>00163 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; maxVal);
  129. <a name="l00164"></a>00164
  130. <a name="l00189"></a>00189 <span class="comment">// \todo Test when &#39;a&#39; is a boolean.</span>
  131. <a name="l00190"></a>00190 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genTypeT, <span class="keyword">typename</span> genTypeU&gt;
  132. <a name="l00191"></a>00191 genTypeT <a class="code" href="a00238.html#ga11288dc43a2a1833766728a3eb81ac63">mix</a>(genTypeT <span class="keyword">const</span> &amp; x, genTypeT <span class="keyword">const</span> &amp; y, genTypeU <span class="keyword">const</span> &amp; a);
  133. <a name="l00192"></a>00192
  134. <a name="l00197"></a>00197 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  135. <a name="l00198"></a>00198 genType <a class="code" href="a00238.html#gaf1c0aac0585f62db8db44e407478c434" title="Returns 0.0 if x &lt; edge, otherwise it returns 1.0.">step</a>(
  136. <a name="l00199"></a>00199 genType <span class="keyword">const</span> &amp; edge,
  137. <a name="l00200"></a>00200 genType <span class="keyword">const</span> &amp; x);
  138. <a name="l00201"></a>00201
  139. <a name="l00202"></a>00202 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  140. <a name="l00203"></a>00203 genType <a class="code" href="a00238.html#gaf1c0aac0585f62db8db44e407478c434" title="Returns 0.0 if x &lt; edge, otherwise it returns 1.0.">step</a>(
  141. <a name="l00204"></a>00204 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; edge,
  142. <a name="l00205"></a>00205 genType <span class="keyword">const</span> &amp; x);
  143. <a name="l00206"></a>00206
  144. <a name="l00219"></a>00219 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  145. <a name="l00220"></a>00220 genType <a class="code" href="a00238.html#gaec459c912160fa6d9c18acd52976bb4d" title="Returns 0.0 if x &lt;= edge0 and 1.0 if x &gt;= edge1 and performs smooth Hermite interpolation between 0 a...">smoothstep</a>(
  146. <a name="l00221"></a>00221 genType <span class="keyword">const</span> &amp; edge0,
  147. <a name="l00222"></a>00222 genType <span class="keyword">const</span> &amp; edge1,
  148. <a name="l00223"></a>00223 genType <span class="keyword">const</span> &amp; x);
  149. <a name="l00224"></a>00224
  150. <a name="l00225"></a>00225 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  151. <a name="l00226"></a>00226 genType <a class="code" href="a00238.html#gaec459c912160fa6d9c18acd52976bb4d" title="Returns 0.0 if x &lt;= edge0 and 1.0 if x &gt;= edge1 and performs smooth Hermite interpolation between 0 a...">smoothstep</a>(
  152. <a name="l00227"></a>00227 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; edge0,
  153. <a name="l00228"></a>00228 <span class="keyword">typename</span> genType::value_type <span class="keyword">const</span> &amp; edge1,
  154. <a name="l00229"></a>00229 genType <span class="keyword">const</span> &amp; x);
  155. <a name="l00230"></a>00230
  156. <a name="l00239"></a>00239 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  157. <a name="l00240"></a>00240 <span class="keyword">typename</span> genType::bool_type <a class="code" href="a00238.html#ga873db92807cc955cf98030c94a342d5a" title="Returns true if x holds a NaN (not a number) representation in the underlying implementation&#39;s set of...">isnan</a>(genType <span class="keyword">const</span> &amp; x);
  158. <a name="l00241"></a>00241
  159. <a name="l00250"></a>00250 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  160. <a name="l00251"></a>00251 <span class="keyword">typename</span> genType::bool_type <a class="code" href="a00238.html#ga7194c89cf656614f231e11c46d906465" title="Returns true if x holds a positive infinity or negative infinity representation in the underlying imp...">isinf</a>(genType <span class="keyword">const</span> &amp; x);
  161. <a name="l00252"></a>00252
  162. <a name="l00259"></a>00259 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType, <span class="keyword">typename</span> genIType&gt;
  163. <a name="l00260"></a>00260 genIType <a class="code" href="a00238.html#ga2508259e7d3093603f4c6d3c132a704c" title="Returns a signed integer value representing the encoding of a floating-point value.">floatBitsToInt</a>(genType <span class="keyword">const</span> &amp; value);
  164. <a name="l00261"></a>00261
  165. <a name="l00268"></a>00268 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType, <span class="keyword">typename</span> genUType&gt;
  166. <a name="l00269"></a>00269 genUType <a class="code" href="a00238.html#ga17f59f3a2dd5b93e32ff1057be188681" title="Returns a unsigned integer value representing the encoding of a floating-point value.">floatBitsToUint</a>(genType <span class="keyword">const</span> &amp; value);
  167. <a name="l00270"></a>00270
  168. <a name="l00279"></a>00279 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType, <span class="keyword">typename</span> genIType&gt;
  169. <a name="l00280"></a>00280 genType <a class="code" href="a00238.html#ga3b76eab7091983e936c894b1976e90be" title="Returns a floating-point value corresponding to a signed integer encoding of a floating-point value...">intBitsToFloat</a>(genIType <span class="keyword">const</span> &amp; value);
  170. <a name="l00281"></a>00281
  171. <a name="l00290"></a>00290 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType, <span class="keyword">typename</span> genUType&gt;
  172. <a name="l00291"></a>00291 genType <a class="code" href="a00238.html#ga1a38039b00f182b6b22e909ea5a87bab" title="Returns a floating-point value corresponding to a unsigned integer encoding of a floating-point value...">uintBitsToFloat</a>(genUType <span class="keyword">const</span> &amp; value);
  173. <a name="l00292"></a>00292
  174. <a name="l00297"></a>00297 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType&gt;
  175. <a name="l00298"></a>00298 genType <a class="code" href="a00238.html#gad0278428ad872e7be378c3b2ad66b0ba" title="Computes and returns a * b + c.">fma</a>(genType <span class="keyword">const</span> &amp; a, genType <span class="keyword">const</span> &amp; b, genType <span class="keyword">const</span> &amp; c);
  176. <a name="l00299"></a>00299
  177. <a name="l00312"></a>00312 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType, <span class="keyword">typename</span> genIType&gt;
  178. <a name="l00313"></a>00313 genType <a class="code" href="a00238.html#ga51135c18fa3b70b67478e546258caa64" title="Splits x into a floating-point significand in the range [0.5, 1.0) and an integral exponent of two...">frexp</a>(genType <span class="keyword">const</span> &amp; x, genIType &amp; <a class="code" href="a00238.html#gac96b81360552e233031fd06390576ebf" title="Returns the natural exponentiation of x, i.e., e^x.">exp</a>);
  179. <a name="l00314"></a>00314
  180. <a name="l00324"></a>00324 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> genType, <span class="keyword">typename</span> genIType&gt;
  181. <a name="l00325"></a>00325 genType <a class="code" href="a00238.html#gaa99c16ada9e61cca03a8a00938a3c330" title="Builds a floating-point number from x and the corresponding integral exponent of two in exp...">ldexp</a>(genType <span class="keyword">const</span> &amp; x, genIType <span class="keyword">const</span> &amp; exp);
  182. <a name="l00326"></a>00326
  183. <a name="l00328"></a>00328 }<span class="comment">//namespace common</span>
  184. <a name="l00329"></a>00329 }<span class="comment">//namespace function</span>
  185. <a name="l00330"></a>00330 }<span class="comment">//namespace core</span>
  186. <a name="l00331"></a>00331
  187. <a name="l00332"></a>00332 <span class="keyword">using namespace </span>core::function::common;
  188. <a name="l00333"></a>00333 }<span class="comment">//namespace glm</span>
  189. <a name="l00334"></a>00334
  190. <a name="l00335"></a>00335 <span class="preprocessor">#include &quot;func_common.inl&quot;</span>
  191. <a name="l00336"></a>00336
  192. <a name="l00337"></a>00337 <span class="preprocessor">#endif//glm_core_func_common</span>
  193. </pre></div></div>
  194. </div>
  195. <hr class="footer"/><address class="footer"><small>Generated by&#160;
  196. <a href="http://www.doxygen.org/index.html">
  197. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
  198. </body>
  199. </html>