-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_math_8h_source.html
247 lines (247 loc) · 41.2 KB
/
_math_8h_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.3"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Gamedev Framework (gf): Math.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectlogo"><img alt="Logo" src="gf_logo.png"/></td>
<td id="projectalign">
<div id="projectname">Gamedev Framework (gf)<span id="projectnumber"> 0.21.0</span>
</div>
<div id="projectbrief">A C++17 framework for 2D games</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.3 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_6d069d519ae9d12fa11dd8e685586b60.html">gf</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">Math.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span><span class="comment"> * Gamedev Framework (gf)</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="comment"> * Copyright (C) 2016-2021 Julien Bernard</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span><span class="comment"> *</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="comment"> * This software is provided 'as-is', without any express or implied</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="comment"> * warranty. In no event will the authors be held liable for any damages</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span><span class="comment"> * arising from the use of this software.</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="comment"> *</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="comment"> * Permission is granted to anyone to use this software for any purpose,</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="comment"> * including commercial applications, and to alter it and redistribute it</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="comment"> * freely, subject to the following restrictions:</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="comment"> *</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="comment"> * 1. The origin of this software must not be misrepresented; you must not</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="comment"> * claim that you wrote the original software. If you use this software</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span><span class="comment"> * in a product, an acknowledgment in the product documentation would be</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="comment"> * appreciated but is not required.</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span><span class="comment"> * 2. Altered source versions must be plainly marked as such, and must not be</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span><span class="comment"> * misrepresented as being the original software.</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span><span class="comment"> * 3. This notice may not be removed or altered from any source distribution.</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="comment"> */</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#ifndef GF_MATH_H</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="preprocessor">#define GF_MATH_H</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span><span class="preprocessor">#include <cmath></span></div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="preprocessor">#include <limits></span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> </div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacegf.html">gf</a> {</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span><span class="preprocessor">#ifndef DOXYGEN_SHOULD_SKIP_THIS</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="keyword">inline</span> <span class="keyword">namespace </span>v1 {</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"><a class="line" href="group__core__maths.html#gab69a18ba294adfcbf6bb27e1ae61ab67"> 38</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#gab69a18ba294adfcbf6bb27e1ae61ab67">pi</a>() {</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> <span class="keywordflow">return</span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(3.141592653589793238462643383279502884197169399L);</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> }</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40"> 46</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40">Pi</a> = pi<float>();</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"><a class="line" href="group__core__maths.html#gaac3ad99d9b813b1cea8802abbfed6d80"> 52</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gaac3ad99d9b813b1cea8802abbfed6d80">Pi2</a> = <a class="code hl_variable" href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40">Pi</a> / 2;</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> </div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga00db1baabef60c722a228a812e66231b"> 58</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#ga00db1baabef60c722a228a812e66231b">Pi3</a> = <a class="code hl_variable" href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40">Pi</a> / 3;</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"><a class="line" href="group__core__maths.html#gaab6d74eaf8f5a1744b6de68ad463edf2"> 64</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gaab6d74eaf8f5a1744b6de68ad463edf2">Pi4</a> = <a class="code hl_variable" href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40">Pi</a> / 4;</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="group__core__maths.html#gaacf82852e3af9101852d60e8050fd9e1"> 70</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gaacf82852e3af9101852d60e8050fd9e1">Pi6</a> = <a class="code hl_variable" href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40">Pi</a> / 6;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga8aa2d6dc9c8fb96810fe47dff3c9b00a"> 76</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#ga8aa2d6dc9c8fb96810fe47dff3c9b00a">Sqrt2</a> = 1.41421356237309504880f;</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> </div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"><a class="line" href="group__core__maths.html#gab6ba065d81cdb7021ba7e47bea500580"> 82</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gab6ba065d81cdb7021ba7e47bea500580">InvSqrt2</a> = 1 / <a class="code hl_variable" href="group__core__maths.html#ga8aa2d6dc9c8fb96810fe47dff3c9b00a">Sqrt2</a>;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"><a class="line" href="group__core__maths.html#gad32b4a332d77de3d25eae25cfbcb3fb2"> 88</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gad32b4a332d77de3d25eae25cfbcb3fb2">Sqrt3</a> = 1.7320508075688772935f;</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> </div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno"><a class="line" href="group__core__maths.html#gab4aa74a0cbea2a97c107bc5a1dc63a64"> 94</a></span> <span class="keyword">constexpr</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="group__core__maths.html#gab4aa74a0cbea2a97c107bc5a1dc63a64">Epsilon</a> = std::numeric_limits<float>::epsilon();</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> </div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga9841a1fce2dd7019938c81d25ed8c136"> 108</a></span> <span class="keywordtype">bool</span> <a class="code hl_function" href="group__core__maths.html#ga9841a1fce2dd7019938c81d25ed8c136">almostEquals</a>(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) {</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> <span class="keywordflow">if</span> (a == b) {</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> }</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> diff = std::abs(a - b);</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> </div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="keywordflow">if</span> (a == 0 || b == 0 || diff < std::numeric_limits<T>::denorm_min()) {</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> <span class="keywordflow">return</span> diff < (epsilon * std::numeric_limits<T>::denorm_min());</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> }</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> </div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> sum = std::abs(a) + std::abs(b);</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> sum = (sum < std::numeric_limits<T>::max()) ? sum : std::numeric_limits<T>::max();</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> </div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span> <span class="keywordflow">return</span> (diff / sum) < epsilon;</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> }</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> </div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga1aa23f6b4c7a1e33f06fadf4a6c2b143"> 135</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga1aa23f6b4c7a1e33f06fadf4a6c2b143">degreesToRadians</a>(T degrees) {</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <span class="keywordflow">return</span> degrees * gf::pi<T>() / <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(180);</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> }</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> </div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga2076bbbd889489ac7f2f6e1d212f6c7c"> 149</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga2076bbbd889489ac7f2f6e1d212f6c7c">radiansToDegrees</a>(T radians) {</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> <span class="keywordflow">return</span> radians * <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(180) / gf::pi<T>();</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> }</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> </div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno"> 176</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga44b429e4f47cceab994f3b20b811d681"> 177</a></span> <span class="keyword">using</span> <a class="code hl_typedef" href="group__core__maths.html#ga44b429e4f47cceab994f3b20b811d681">Step</a> = <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> (*)(<a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>);</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno"> 178</span> </div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno"> 187</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno"> 188</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno"><a class="line" href="group__core__maths.html#gae4f9435d5873af1b503a277ddae35bd9"> 189</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#gae4f9435d5873af1b503a277ddae35bd9">linearStep</a>(T t) {</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno"> 190</span> <span class="keywordflow">return</span> t;</div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno"> 191</span> }</div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno"> 192</span> </div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno"> 208</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"><a class="line" href="group__core__maths.html#gab353056685420de64599bb422adaf701"> 210</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#gab353056685420de64599bb422adaf701">cubicStep</a>(T t) {</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> <span class="keywordflow">return</span> (-<a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(2) * t + <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(3)) * t * t;</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span> }</div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno"> 213</span> </div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno"> 231</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno"> 232</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga6f9ca6f1bc9622a4c7e68a3f956d8415"> 233</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga6f9ca6f1bc9622a4c7e68a3f956d8415">quinticStep</a>(T t) {</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno"> 234</span> <span class="keywordflow">return</span> ((<a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(6) * t - <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(15)) * t + <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(10)) * t * t * t;</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno"> 235</span> }</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno"> 236</span> </div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno"> 245</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno"> 246</span> <span class="keyword">inline</span></div>
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga0e9fce6526516ba6bee65bf802888cd3"> 247</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga0e9fce6526516ba6bee65bf802888cd3">cosineStep</a>(T t) {</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno"> 248</span> <span class="keywordflow">return</span> (<a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(1) - std::cos(gf::pi<T>() * t)) * <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(0.5);</div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno"> 249</span> }</div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno"> 250</span> </div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno"> 264</span> <span class="keyword">template</span><<span class="keyword">typename</span> T, <span class="keyword">typename</span> U></div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno"> 265</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga9cff790079bfedb8b24a26de940a051f"> 266</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga9cff790079bfedb8b24a26de940a051f">lerp</a>(T lhs, T rhs, U t) {</div>
<div class="line"><a id="l00267" name="l00267"></a><span class="lineno"> 267</span> <span class="keywordflow">return</span> (<a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626a4c614360da93c0a041b22e537de151eb">U</a>(1) - t) * lhs + t * rhs;</div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno"> 268</span> }</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno"> 269</span> </div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno"> 282</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno"> 283</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga671bdda5a52c335e68d391147c70cc16"> 284</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga671bdda5a52c335e68d391147c70cc16">clamp</a>(T val, T lo, T hi) {</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno"> 285</span> <span class="keywordflow">return</span> val < lo ? lo : (val > hi ? hi : val);</div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno"> 286</span> }</div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno"> 287</span> </div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno"> 297</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno"> 298</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga0e22be4ddd625e4c235dbf0ef2d1f43f"> 299</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga0e22be4ddd625e4c235dbf0ef2d1f43f">square</a>(T val) {</div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno"> 300</span> <span class="keywordflow">return</span> val * val;</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno"> 301</span> }</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno"> 302</span> </div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno"> 312</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00313" name="l00313"></a><span class="lineno"> 313</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00314" name="l00314"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga79f9c3327331a94c9b239d2cee745ff2"> 314</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga79f9c3327331a94c9b239d2cee745ff2">cube</a>(T val) {</div>
<div class="line"><a id="l00315" name="l00315"></a><span class="lineno"> 315</span> <span class="keywordflow">return</span> val * val * val;</div>
<div class="line"><a id="l00316" name="l00316"></a><span class="lineno"> 316</span> }</div>
<div class="line"><a id="l00317" name="l00317"></a><span class="lineno"> 317</span> </div>
<div class="line"><a id="l00332" name="l00332"></a><span class="lineno"> 332</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00333" name="l00333"></a><span class="lineno"> 333</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00334" name="l00334"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga55d7afb6ae7f894776bb0244465ac497"> 334</a></span> <span class="keywordtype">int</span> <a class="code hl_function" href="group__core__maths.html#ga55d7afb6ae7f894776bb0244465ac497">sign</a>(T val) {</div>
<div class="line"><a id="l00335" name="l00335"></a><span class="lineno"> 335</span> <span class="keywordflow">return</span> (val > <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(0)) - (val < <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a>(0));</div>
<div class="line"><a id="l00336" name="l00336"></a><span class="lineno"> 336</span> }</div>
<div class="line"><a id="l00337" name="l00337"></a><span class="lineno"> 337</span> </div>
<div class="line"><a id="l00350" name="l00350"></a><span class="lineno"> 350</span> <span class="keyword">template</span><<span class="keyword">typename</span> T></div>
<div class="line"><a id="l00351" name="l00351"></a><span class="lineno"> 351</span> <span class="keyword">constexpr</span></div>
<div class="line"><a id="l00352" name="l00352"></a><span class="lineno"><a class="line" href="group__core__maths.html#ga162af6026bb8a59762e87c918f634006"> 352</a></span> <a class="code hl_enumvalue" href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">T</a> <a class="code hl_function" href="group__core__maths.html#ga162af6026bb8a59762e87c918f634006">absdiff</a>(T lhs, T rhs) {</div>
<div class="line"><a id="l00353" name="l00353"></a><span class="lineno"> 353</span> <span class="keywordflow">return</span> lhs > rhs ? lhs - rhs : rhs - lhs;</div>
<div class="line"><a id="l00354" name="l00354"></a><span class="lineno"> 354</span> }</div>
<div class="line"><a id="l00355" name="l00355"></a><span class="lineno"> 355</span> </div>
<div class="line"><a id="l00356" name="l00356"></a><span class="lineno"> 356</span><span class="preprocessor">#ifndef DOXYGEN_SHOULD_SKIP_THIS</span></div>
<div class="line"><a id="l00357" name="l00357"></a><span class="lineno"> 357</span>}</div>
<div class="line"><a id="l00358" name="l00358"></a><span class="lineno"> 358</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00359" name="l00359"></a><span class="lineno"> 359</span>}</div>
<div class="line"><a id="l00360" name="l00360"></a><span class="lineno"> 360</span> </div>
<div class="line"><a id="l00361" name="l00361"></a><span class="lineno"> 361</span><span class="preprocessor">#endif </span><span class="comment">// GF_MATH_H</span></div>
<div class="ttc" id="agroup__core__maths_html_ga00db1baabef60c722a228a812e66231b"><div class="ttname"><a href="group__core__maths.html#ga00db1baabef60c722a228a812e66231b">gf::Pi3</a></div><div class="ttdeci">constexpr float Pi3</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:58</div></div>
<div class="ttc" id="agroup__core__maths_html_ga0e22be4ddd625e4c235dbf0ef2d1f43f"><div class="ttname"><a href="group__core__maths.html#ga0e22be4ddd625e4c235dbf0ef2d1f43f">gf::square</a></div><div class="ttdeci">constexpr T square(T val)</div><div class="ttdoc">Square function.</div><div class="ttdef"><b>Definition:</b> Math.h:299</div></div>
<div class="ttc" id="agroup__core__maths_html_ga0e9fce6526516ba6bee65bf802888cd3"><div class="ttname"><a href="group__core__maths.html#ga0e9fce6526516ba6bee65bf802888cd3">gf::cosineStep</a></div><div class="ttdeci">T cosineStep(T t)</div><div class="ttdoc">Cosine step.</div><div class="ttdef"><b>Definition:</b> Math.h:247</div></div>
<div class="ttc" id="agroup__core__maths_html_ga162af6026bb8a59762e87c918f634006"><div class="ttname"><a href="group__core__maths.html#ga162af6026bb8a59762e87c918f634006">gf::absdiff</a></div><div class="ttdeci">constexpr T absdiff(T lhs, T rhs)</div><div class="ttdoc">Absolute difference of two values.</div><div class="ttdef"><b>Definition:</b> Math.h:352</div></div>
<div class="ttc" id="agroup__core__maths_html_ga1aa23f6b4c7a1e33f06fadf4a6c2b143"><div class="ttname"><a href="group__core__maths.html#ga1aa23f6b4c7a1e33f06fadf4a6c2b143">gf::degreesToRadians</a></div><div class="ttdeci">constexpr T degreesToRadians(T degrees)</div><div class="ttdoc">Convert degrees to radians.</div><div class="ttdef"><b>Definition:</b> Math.h:135</div></div>
<div class="ttc" id="agroup__core__maths_html_ga2076bbbd889489ac7f2f6e1d212f6c7c"><div class="ttname"><a href="group__core__maths.html#ga2076bbbd889489ac7f2f6e1d212f6c7c">gf::radiansToDegrees</a></div><div class="ttdeci">constexpr T radiansToDegrees(T radians)</div><div class="ttdoc">Convert radians to degrees.</div><div class="ttdef"><b>Definition:</b> Math.h:149</div></div>
<div class="ttc" id="agroup__core__maths_html_ga44b429e4f47cceab994f3b20b811d681"><div class="ttname"><a href="group__core__maths.html#ga44b429e4f47cceab994f3b20b811d681">gf::Step</a></div><div class="ttdeci">T(*)(T) Step</div><div class="ttdoc">A step is a function with special features.</div><div class="ttdef"><b>Definition:</b> Math.h:177</div></div>
<div class="ttc" id="agroup__core__maths_html_ga55d7afb6ae7f894776bb0244465ac497"><div class="ttname"><a href="group__core__maths.html#ga55d7afb6ae7f894776bb0244465ac497">gf::sign</a></div><div class="ttdeci">constexpr int sign(T val)</div><div class="ttdoc">Sign function.</div><div class="ttdef"><b>Definition:</b> Math.h:334</div></div>
<div class="ttc" id="agroup__core__maths_html_ga671bdda5a52c335e68d391147c70cc16"><div class="ttname"><a href="group__core__maths.html#ga671bdda5a52c335e68d391147c70cc16">gf::clamp</a></div><div class="ttdeci">constexpr T clamp(T val, T lo, T hi)</div><div class="ttdoc">Clamping function.</div><div class="ttdef"><b>Definition:</b> Math.h:284</div></div>
<div class="ttc" id="agroup__core__maths_html_ga6f9ca6f1bc9622a4c7e68a3f956d8415"><div class="ttname"><a href="group__core__maths.html#ga6f9ca6f1bc9622a4c7e68a3f956d8415">gf::quinticStep</a></div><div class="ttdeci">constexpr T quinticStep(T t)</div><div class="ttdoc">Quintic step (smootherstep)</div><div class="ttdef"><b>Definition:</b> Math.h:233</div></div>
<div class="ttc" id="agroup__core__maths_html_ga79f9c3327331a94c9b239d2cee745ff2"><div class="ttname"><a href="group__core__maths.html#ga79f9c3327331a94c9b239d2cee745ff2">gf::cube</a></div><div class="ttdeci">constexpr T cube(T val)</div><div class="ttdoc">Cube function.</div><div class="ttdef"><b>Definition:</b> Math.h:314</div></div>
<div class="ttc" id="agroup__core__maths_html_ga8aa2d6dc9c8fb96810fe47dff3c9b00a"><div class="ttname"><a href="group__core__maths.html#ga8aa2d6dc9c8fb96810fe47dff3c9b00a">gf::Sqrt2</a></div><div class="ttdeci">constexpr float Sqrt2</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:76</div></div>
<div class="ttc" id="agroup__core__maths_html_ga9841a1fce2dd7019938c81d25ed8c136"><div class="ttname"><a href="group__core__maths.html#ga9841a1fce2dd7019938c81d25ed8c136">gf::almostEquals</a></div><div class="ttdeci">constexpr bool almostEquals(T a, T b, T epsilon=std::numeric_limits< T >::epsilon())</div><div class="ttdoc">Compare two floats.</div><div class="ttdef"><b>Definition:</b> Math.h:108</div></div>
<div class="ttc" id="agroup__core__maths_html_ga9cff790079bfedb8b24a26de940a051f"><div class="ttname"><a href="group__core__maths.html#ga9cff790079bfedb8b24a26de940a051f">gf::lerp</a></div><div class="ttdeci">constexpr T lerp(T lhs, T rhs, U t)</div><div class="ttdoc">Linear interpolation function.</div><div class="ttdef"><b>Definition:</b> Math.h:266</div></div>
<div class="ttc" id="agroup__core__maths_html_gaab6d74eaf8f5a1744b6de68ad463edf2"><div class="ttname"><a href="group__core__maths.html#gaab6d74eaf8f5a1744b6de68ad463edf2">gf::Pi4</a></div><div class="ttdeci">constexpr float Pi4</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:64</div></div>
<div class="ttc" id="agroup__core__maths_html_gaac3ad99d9b813b1cea8802abbfed6d80"><div class="ttname"><a href="group__core__maths.html#gaac3ad99d9b813b1cea8802abbfed6d80">gf::Pi2</a></div><div class="ttdeci">constexpr float Pi2</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:52</div></div>
<div class="ttc" id="agroup__core__maths_html_gaacf82852e3af9101852d60e8050fd9e1"><div class="ttname"><a href="group__core__maths.html#gaacf82852e3af9101852d60e8050fd9e1">gf::Pi6</a></div><div class="ttdeci">constexpr float Pi6</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:70</div></div>
<div class="ttc" id="agroup__core__maths_html_gab353056685420de64599bb422adaf701"><div class="ttname"><a href="group__core__maths.html#gab353056685420de64599bb422adaf701">gf::cubicStep</a></div><div class="ttdeci">constexpr T cubicStep(T t)</div><div class="ttdoc">Cubic step (smoothstep)</div><div class="ttdef"><b>Definition:</b> Math.h:210</div></div>
<div class="ttc" id="agroup__core__maths_html_gab4aa74a0cbea2a97c107bc5a1dc63a64"><div class="ttname"><a href="group__core__maths.html#gab4aa74a0cbea2a97c107bc5a1dc63a64">gf::Epsilon</a></div><div class="ttdeci">constexpr float Epsilon</div><div class="ttdoc">Machine epsilon.</div><div class="ttdef"><b>Definition:</b> Math.h:94</div></div>
<div class="ttc" id="agroup__core__maths_html_gab69a18ba294adfcbf6bb27e1ae61ab67"><div class="ttname"><a href="group__core__maths.html#gab69a18ba294adfcbf6bb27e1ae61ab67">gf::pi</a></div><div class="ttdeci">constexpr T pi()</div><div class="ttdoc">Templated value of .</div><div class="ttdef"><b>Definition:</b> Math.h:38</div></div>
<div class="ttc" id="agroup__core__maths_html_gab6ba065d81cdb7021ba7e47bea500580"><div class="ttname"><a href="group__core__maths.html#gab6ba065d81cdb7021ba7e47bea500580">gf::InvSqrt2</a></div><div class="ttdeci">constexpr float InvSqrt2</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:82</div></div>
<div class="ttc" id="agroup__core__maths_html_gad32b4a332d77de3d25eae25cfbcb3fb2"><div class="ttname"><a href="group__core__maths.html#gad32b4a332d77de3d25eae25cfbcb3fb2">gf::Sqrt3</a></div><div class="ttdeci">constexpr float Sqrt3</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:88</div></div>
<div class="ttc" id="agroup__core__maths_html_gae4f9435d5873af1b503a277ddae35bd9"><div class="ttname"><a href="group__core__maths.html#gae4f9435d5873af1b503a277ddae35bd9">gf::linearStep</a></div><div class="ttdeci">constexpr T linearStep(T t)</div><div class="ttdoc">Linear step.</div><div class="ttdef"><b>Definition:</b> Math.h:189</div></div>
<div class="ttc" id="agroup__core__maths_html_gafea71ec62ea0c47eb8e65dba77940b40"><div class="ttname"><a href="group__core__maths.html#gafea71ec62ea0c47eb8e65dba77940b40">gf::Pi</a></div><div class="ttdeci">constexpr float Pi</div><div class="ttdoc">The constant.</div><div class="ttdef"><b>Definition:</b> Math.h:46</div></div>
<div class="ttc" id="agroup__graphics__devices_html_gga795d7d5e2f2a4f38b16b95e0e78cb626a4c614360da93c0a041b22e537de151eb"><div class="ttname"><a href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626a4c614360da93c0a041b22e537de151eb">gf::Scancode::U</a></div><div class="ttdeci">@ U</div></div>
<div class="ttc" id="agroup__graphics__devices_html_gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3"><div class="ttname"><a href="group__graphics__devices.html#gga795d7d5e2f2a4f38b16b95e0e78cb626ab9ece18c950afbfa6b0fdbfa4ff731d3">gf::Scancode::T</a></div><div class="ttdeci">@ T</div></div>
<div class="ttc" id="anamespacegf_html"><div class="ttname"><a href="namespacegf.html">gf</a></div><div class="ttdoc">The namespace for gf classes.</div><div class="ttdef"><b>Definition:</b> Action.h:35</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3
</small></address>
</body>
</html>