source: NonGTP/FCollada/Documentation/_f_math_8h-source.html @ 964

Revision 964, 9.5 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[964]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>FCollada: FMath/FMath.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.4.6-NO -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="modules.html"><span>Modules</span></a></li>
12    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
13    <li><a href="classes.html"><span>Classes</span></a></li>
14    <li id="current"><a href="files.html"><span>Files</span></a></li>
15    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
16  </ul></div>
17<div class="tabs">
18  <ul>
19    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
20    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
21  </ul></div>
22<h1>FMath/FMath.h</h1><a href="_f_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">/*</span>
23<a name="l00002"></a>00002 <span class="comment">    Copyright (C) 2005-2006 Feeling Software Inc.</span>
24<a name="l00003"></a>00003 <span class="comment">    MIT License: http://www.opensource.org/licenses/mit-license.php</span>
25<a name="l00004"></a>00004 <span class="comment">*/</span>
26<a name="l00005"></a>00005
27<a name="l00013"></a>00013 <span class="preprocessor">#ifndef _F_MATH_H_</span>
28<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define _F_MATH_H_</span>
29<a name="l00015"></a>00015 <span class="preprocessor"></span>
30<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;math.h&gt;</span>
31<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;algorithm&gt;</span>
32<a name="l00018"></a>00018
33<a name="l00019"></a>00019 <span class="comment">// Includes the improved vector class.</span>
34<a name="l00020"></a>00020 <span class="preprocessor">#include "<a class="code" href="_f_m_array_8h.html">FMath/FMArray.h</a>"</span>
35<a name="l00021"></a>00021
36<a name="l00022"></a>00022 <span class="comment">// Includes the common integer and floating-point definitions and functions.</span>
37<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="_f_m_float_8h.html">FMath/FMFloat.h</a>"</span>
38<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="_f_m_integer_8h.html">FMath/FMInteger.h</a>"</span>
39<a name="l00025"></a>00025
40<a name="l00031"></a><a class="code" href="namespace_f_math.html">00031</a> <span class="keyword">namespace </span>FMath
41<a name="l00032"></a>00032 {
42<a name="l00033"></a><a class="code" href="namespace_f_math.html#4c8e25df39e90e06ce866c1b509b9bec">00033</a>     <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="namespace_f_math.html#4c8e25df39e90e06ce866c1b509b9bec">Pi</a> = 3.14159; 
43<a name="l00041"></a><a class="code" href="namespace_f_math.html#3f3ff4d162ca9b81672ab8d5ce1a04ed">00041</a>     <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="namespace_f_math.html#3f3ff4d162ca9b81672ab8d5ce1a04ed">RadToDeg</a>(<span class="keywordtype">double</span> val) { <span class="keywordflow">return</span> (val * 180.0/<a class="code" href="namespace_f_math.html#4c8e25df39e90e06ce866c1b509b9bec">Pi</a>); }
44<a name="l00042"></a>00042
45<a name="l00049"></a><a class="code" href="namespace_f_math.html#126a39f30047703acd42ac277e688959">00049</a>     <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="namespace_f_math.html#3f3ff4d162ca9b81672ab8d5ce1a04ed">RadToDeg</a>(<span class="keywordtype">float</span> val) { <span class="keywordflow">return</span> (val * 180.0f/(<span class="keywordtype">float</span>)<a class="code" href="namespace_f_math.html#4c8e25df39e90e06ce866c1b509b9bec">Pi</a>); }
46<a name="l00050"></a>00050
47<a name="l00057"></a><a class="code" href="namespace_f_math.html#85780db77107aa93459019cd8cb8e89b">00057</a>     <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="namespace_f_math.html#85780db77107aa93459019cd8cb8e89b">DegToRad</a>(<span class="keywordtype">double</span> val) { <span class="keywordflow">return</span> (val * <a class="code" href="namespace_f_math.html#4c8e25df39e90e06ce866c1b509b9bec">Pi</a>/180.0); }
48<a name="l00058"></a>00058
49<a name="l00065"></a><a class="code" href="namespace_f_math.html#0d5dc4a5370d82235d4e62cdd510c31c">00065</a>     <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="namespace_f_math.html#85780db77107aa93459019cd8cb8e89b">DegToRad</a>(<span class="keywordtype">float</span> val) { <span class="keywordflow">return</span> (val * (<span class="keywordtype">float</span>)<a class="code" href="namespace_f_math.html#4c8e25df39e90e06ce866c1b509b9bec">Pi</a>/180.0f); }
50<a name="l00066"></a>00066
51<a name="l00073"></a>00073 <span class="preprocessor">#ifdef WIN32</span>
52<a name="l00074"></a>00074 <span class="preprocessor"></span>    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="namespace_f_math.html#f07527201a796f5c30c8bc10db7a8178">IsNotANumber</a>(<span class="keywordtype">float</span> f) { <span class="keywordflow">return</span> _isnan(f); }
53<a name="l00075"></a>00075 <span class="preprocessor">#elif __PPU__</span>
54<a name="l00076"></a>00076 <span class="preprocessor"></span>    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="namespace_f_math.html#f07527201a796f5c30c8bc10db7a8178">IsNotANumber</a>(<span class="keywordtype">float</span> f) { <span class="keywordflow">return</span> !isfinite(f); }
55<a name="l00077"></a>00077 <span class="preprocessor">#else // Linux and Mac</span>
56<a name="l00078"></a><a class="code" href="namespace_f_math.html#f07527201a796f5c30c8bc10db7a8178">00078</a> <span class="preprocessor"></span>    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="namespace_f_math.html#f07527201a796f5c30c8bc10db7a8178">IsNotANumber</a>(<span class="keywordtype">float</span> f) { <span class="keywordflow">return</span> !finite(f); }
57<a name="l00079"></a>00079 <span class="preprocessor">#endif</span>
58<a name="l00080"></a>00080 <span class="preprocessor"></span>
59<a name="l00087"></a><a class="code" href="namespace_f_math.html#1190dc2de051037cbb426f9c9aee8046">00087</a>     <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="namespace_f_math.html#1190dc2de051037cbb426f9c9aee8046">Sign</a>(<span class="keywordtype">double</span> val) { <span class="keywordflow">return</span> (val &gt;= 0.0) ? 1.0 : -1.0; }
60<a name="l00088"></a>00088
61<a name="l00095"></a><a class="code" href="namespace_f_math.html#48ee0aea01eb950825b923755f4576d2">00095</a>     <span class="keyword">inline</span> <span class="keywordtype">float</span> <a class="code" href="namespace_f_math.html#1190dc2de051037cbb426f9c9aee8046">Sign</a>(<span class="keywordtype">float</span> val) { <span class="keywordflow">return</span> (val &gt;= 0.0f) ? 1.0f : -1.0f; }
62<a name="l00096"></a>00096
63<a name="l00103"></a><a class="code" href="namespace_f_math.html#eeb82e7ca4d7ea1d2fe9483f8aae575c">00103</a>     <span class="keyword">inline</span> int32 <a class="code" href="namespace_f_math.html#1190dc2de051037cbb426f9c9aee8046">Sign</a>(int32 val) { <span class="keywordflow">return</span> (val &gt;= 0) ? 1 : -1; }
64<a name="l00104"></a>00104
65<a name="l00118"></a>00118 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
66<a name="l00119"></a><a class="code" href="namespace_f_math.html#2bc2e21ab0bc13dbf6b669eb1d9b253c">00119</a>     <span class="keyword">inline</span> T <a class="code" href="namespace_f_math.html#2bc2e21ab0bc13dbf6b669eb1d9b253c">Clamp</a>(T val, T mn, T mx) { <span class="keywordflow">return</span> <a class="code" href="_f_utils_8h.html#ffe776513b24d84b39af8ab0930fef7f">std::max</a>(<a class="code" href="_f_utils_8h.html#c6afabdc09a49a433ee19d8a9486056d">std::min</a>(val, mx), mn); }
67<a name="l00120"></a>00120 };
68<a name="l00121"></a>00121
69<a name="l00122"></a>00122 <span class="comment">// Include commonly used mathematical classes</span>
70<a name="l00123"></a>00123 <span class="preprocessor">#include "<a class="code" href="_f_m_vector2_8h.html">FMath/FMVector2.h</a>"</span>
71<a name="l00124"></a>00124 <span class="preprocessor">#include "<a class="code" href="_f_m_vector3_8h.html">FMath/FMVector3.h</a>"</span>
72<a name="l00125"></a>00125 <span class="preprocessor">#include "<a class="code" href="_f_m_vector4_8h.html">FMath/FMVector4.h</a>"</span>
73<a name="l00126"></a>00126 <span class="preprocessor">#include "<a class="code" href="_f_m_color_8h.html">FMath/FMColor.h</a>"</span>
74<a name="l00127"></a>00127 <span class="preprocessor">#include "<a class="code" href="_f_m_matrix33_8h.html">FMath/FMMatrix33.h</a>"</span>
75<a name="l00128"></a>00128 <span class="preprocessor">#include "<a class="code" href="_f_m_matrix44_8h.html">FMath/FMMatrix44.h</a>"</span>
76<a name="l00129"></a>00129
77<a name="l00130"></a>00130 <span class="preprocessor">#endif // _F_MATH_H_</span>
78</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 12 16:44:39 2006 for FCollada by&nbsp;
79<a href="http://www.doxygen.org/index.html">
80<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6-NO </small></address>
81</body>
82</html>
Note: See TracBrowser for help on using the repository browser.