forked from ZhuYanzhen1/miniFOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfast__math_8c_source.html
151 lines (149 loc) · 17.2 KB
/
fast__math_8c_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
<!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.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>miniFOC: algorithm/fast_math.c 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>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.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 style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="Acme_LOGO.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">miniFOC<span id="projectnumber"> 1.0.2</span>
</div>
<div id="projectbrief">This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<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('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_99d3723365464dd656f512988bb8dbbd.html">algorithm</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">fast_math.c</div></div>
</div><!--header-->
<div class="contents">
<a href="fast__math_8c.html">Go to the documentation of this file.</a><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="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="preprocessor">#include "<a class="code" href="fast__math_8h.html">fast_math.h</a>"</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"><a class="line" href="fast__math_8c.html#a4efa9d728789fa7109f4250033e6e7b1"> 15</a></span><span class="keyword">const</span> <span class="keywordtype">float</span> <a class="code hl_variable" href="fast__math_8c.html#a4efa9d728789fa7109f4250033e6e7b1">sin_tab</a>[] = {</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> 0, 0.012296f, 0.024589f, 0.036879f, 0.049164f, 0.061441f, 0.073708f, 0.085965f, 0.098208f, 0.11044f, 0.12265f,</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> 0.13484f, 0.14702f, 0.15917f, 0.17129f, 0.18339f, 0.19547f, 0.20751f, 0.21952f, 0.2315f, 0.24345f, 0.25535f,</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> 0.26722f, 0.27905f, 0.29084f, 0.30258f, 0.31427f, 0.32592f, 0.33752f, 0.34907f, 0.36057f, 0.37201f, 0.38339f,</div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> 0.39472f, 0.40599f, 0.41719f, 0.42834f, 0.43941f, 0.45043f, 0.46137f, 0.47224f, 0.48305f, 0.49378f, 0.50443f,</div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span> 0.51501f, 0.52551f, 0.53593f, 0.54627f, 0.55653f, 0.5667f, 0.57679f, 0.58679f, 0.5967f, 0.60652f, 0.61625f,</div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> 0.62589f, 0.63543f, 0.64488f, 0.65423f, 0.66348f, 0.67263f, 0.68167f, 0.69062f, 0.69946f, 0.70819f, 0.71682f,</div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> 0.72534f, 0.73375f, 0.74205f, 0.75023f, 0.75831f, 0.76626f, 0.77411f, 0.78183f, 0.78944f, 0.79693f, 0.80429f,</div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span> 0.81154f, 0.81866f, 0.82566f, 0.83254f, 0.83928f, 0.84591f, 0.8524f, 0.85876f, 0.865f, 0.8711f, 0.87708f, 0.88292f,</div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> 0.88862f, 0.89419f, 0.89963f, 0.90493f, 0.9101f, 0.91512f, 0.92001f, 0.92476f, 0.92937f, 0.93384f, 0.93816f,</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> 0.94235f, 0.94639f, 0.95029f, 0.95405f, 0.95766f, 0.96113f, 0.96445f, 0.96763f, 0.97066f, 0.97354f, 0.97628f,</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> 0.97887f, 0.98131f, 0.9836f, 0.98574f, 0.98774f, 0.98958f, 0.99128f, 0.99282f, 0.99422f, 0.99546f, 0.99656f,</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> 0.9975f, 0.99829f, 0.99894f, 0.99943f, 0.99977f, 0.99996f, 1.0f, 0.99988f, 0.99962f, 0.9992f, 0.99863f, 0.99792f,</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> 0.99705f, 0.99603f, 0.99486f, 0.99354f, 0.99207f, 0.99045f, 0.98868f, 0.98676f, 0.98469f, 0.98247f, 0.9801f,</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> 0.97759f, 0.97493f, 0.97212f, 0.96916f, 0.96606f, 0.96281f, 0.95941f, 0.95587f, 0.95219f, 0.94836f, 0.94439f,</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> 0.94028f, 0.93602f, 0.93162f, 0.92708f, 0.9224f, 0.91758f, 0.91263f, 0.90753f, 0.9023f, 0.89693f, 0.89142f,</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> 0.88579f, 0.88001f, 0.87411f, 0.86807f, 0.8619f, 0.8556f, 0.84917f, 0.84261f, 0.83593f, 0.82911f, 0.82218f,</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> 0.81512f, 0.80793f, 0.80062f, 0.7932f, 0.78565f, 0.77798f, 0.7702f, 0.7623f, 0.75428f, 0.74615f, 0.73791f, 0.72956f,</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> 0.72109f, 0.71252f, 0.70384f, 0.69505f, 0.68616f, 0.67716f, 0.66806f, 0.65886f, 0.64956f, 0.64017f, 0.63067f,</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> 0.62108f, 0.6114f, 0.60162f, 0.59176f, 0.5818f, 0.57176f, 0.56163f, 0.55141f, 0.54111f, 0.53073f, 0.52027f,</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> 0.50973f, 0.49911f, 0.48842f, 0.47765f, 0.46682f, 0.45591f, 0.44493f, 0.43388f, 0.42277f, 0.4116f, 0.40036f,</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> 0.38906f, 0.37771f, 0.36629f, 0.35483f, 0.3433f, 0.33173f, 0.32011f, 0.30843f, 0.29671f, 0.28495f, 0.27314f,</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> 0.26129f, 0.2494f, 0.23748f, 0.22552f, 0.21352f, 0.20149f, 0.18943f, 0.17735f, 0.16523f, 0.15309f, 0.14093f,</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> 0.12875f, 0.11655f, 0.10432f, 0.092088f, 0.079838f, 0.067576f, 0.055303f, 0.043022f, 0.030735f, 0.018443f,</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> 0.0061479f, -0.0061479f, -0.018443f, -0.030735f, -0.043022f, -0.055303f, -0.067576f, -0.079838f, -0.092088f,</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> -0.10432f, -0.11655f, -0.12875f, -0.14093f, -0.15309f, -0.16523f, -0.17735f, -0.18943f, -0.20149f, -0.21352f,</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> -0.22552f, -0.23748f, -0.2494f, -0.26129f, -0.27314f, -0.28495f, -0.29671f, -0.30843f, -0.32011f, -0.33173f,</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> -0.3433f, -0.35483f, -0.36629f, -0.37771f, -0.38906f, -0.40036f, -0.4116f, -0.42277f, -0.43388f, -0.44493f,</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> -0.45591f, -0.46682f, -0.47765f, -0.48842f, -0.49911f, -0.50973f, -0.52027f, -0.53073f, -0.54111f, -0.55141f,</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> -0.56163f, -0.57176f, -0.5818f, -0.59176f, -0.60162f, -0.6114f, -0.62108f, -0.63067f, -0.64017f, -0.64956f,</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> -0.65886f, -0.66806f, -0.67716f, -0.68616f, -0.69505f, -0.70384f, -0.71252f, -0.72109f, -0.72956f, -0.73791f,</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> -0.74615f, -0.75428f, -0.7623f, -0.7702f, -0.77798f, -0.78565f, -0.7932f, -0.80062f, -0.80793f, -0.81512f,</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> -0.82218f, -0.82911f, -0.83593f, -0.84261f, -0.84917f, -0.8556f, -0.8619f, -0.86807f, -0.87411f, -0.88001f,</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> -0.88579f, -0.89142f, -0.89693f, -0.9023f, -0.90753f, -0.91263f, -0.91758f, -0.9224f, -0.92708f, -0.93162f,</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> -0.93602f, -0.94028f, -0.94439f, -0.94836f, -0.95219f, -0.95587f, -0.95941f, -0.96281f, -0.96606f, -0.96916f,</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> -0.97212f, -0.97493f, -0.97759f, -0.9801f, -0.98247f, -0.98469f, -0.98676f, -0.98868f, -0.99045f, -0.99207f,</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> -0.99354f, -0.99486f, -0.99603f, -0.99705f, -0.99792f, -0.99863f, -0.9992f, -0.99962f, -0.99988f, -1.0f, -0.99996f,</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> -0.99977f, -0.99943f, -0.99894f, -0.99829f, -0.9975f, -0.99656f, -0.99546f, -0.99422f, -0.99282f, -0.99128f,</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> -0.98958f, -0.98774f, -0.98574f, -0.9836f, -0.98131f, -0.97887f, -0.97628f, -0.97354f, -0.97066f, -0.96763f,</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> -0.96445f, -0.96113f, -0.95766f, -0.95405f, -0.95029f, -0.94639f, -0.94235f, -0.93816f, -0.93384f, -0.92937f,</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> -0.92476f, -0.92001f, -0.91512f, -0.9101f, -0.90493f, -0.89963f, -0.89419f, -0.88862f, -0.88292f, -0.87708f,</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> -0.8711f, -0.865f, -0.85876f, -0.8524f, -0.84591f, -0.83928f, -0.83254f, -0.82566f, -0.81866f, -0.81154f, -0.80429f,</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> -0.79693f, -0.78944f, -0.78183f, -0.77411f, -0.76626f, -0.75831f, -0.75023f, -0.74205f, -0.73375f, -0.72534f,</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> -0.71682f, -0.70819f, -0.69946f, -0.69062f, -0.68167f, -0.67263f, -0.66348f, -0.65423f, -0.64488f, -0.63543f,</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> -0.62589f, -0.61625f, -0.60652f, -0.5967f, -0.58679f, -0.57679f, -0.5667f, -0.55653f, -0.54627f, -0.53593f,</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> -0.52551f, -0.51501f, -0.50443f, -0.49378f, -0.48305f, -0.47224f, -0.46137f, -0.45043f, -0.43941f, -0.42834f,</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> -0.41719f, -0.40599f, -0.39472f, -0.38339f, -0.37201f, -0.36057f, -0.34907f, -0.33752f, -0.32592f, -0.31427f,</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> -0.30258f, -0.29084f, -0.27905f, -0.26722f, -0.25535f, -0.24345f, -0.2315f, -0.21952f, -0.20751f, -0.19547f,</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> -0.18339f, -0.17129f, -0.15917f, -0.14702f, -0.13484f, -0.12265f, -0.11044f, -0.098208f, -0.085965f, -0.073708f,</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> -0.061441f, -0.049164f, -0.036879f, -0.024589f, -0.012296f, 0</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span>};</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"><a class="line" href="fast__math_8c.html#a5af7fb1bc56e2917540c1322b1ddb480"> 72</a></span><span class="keywordtype">float</span> <a class="code hl_function" href="fast__math_8c.html#a5af7fb1bc56e2917540c1322b1ddb480">fast_sin</a>(<span class="keywordtype">float</span> theta) {</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="comment">/* congruence of angle theta to 2pi */</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="keywordflow">while</span> (1) {</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordflow">if</span> (theta > 6.2831854f && theta > 0)</div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> theta = theta - 6.2831854f;</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (theta < 0)</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> theta = theta + 6.2831854f;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> <span class="keywordflow">else</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> }</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="comment">/* look up the table to obtain the sine value */</span></div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> <span class="keywordflow">return</span> <a class="code hl_variable" href="fast__math_8c.html#a4efa9d728789fa7109f4250033e6e7b1">sin_tab</a>[(int) (81.4873308f * theta)];</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span>}</div>
<div class="ttc" id="afast__math_8c_html_a4efa9d728789fa7109f4250033e6e7b1"><div class="ttname"><a href="fast__math_8c.html#a4efa9d728789fa7109f4250033e6e7b1">sin_tab</a></div><div class="ttdeci">const float sin_tab[]</div><div class="ttdoc">fast sine function lookup table</div><div class="ttdef"><b>Definition:</b> <a href="fast__math_8c_source.html#l00015">fast_math.c:15</a></div></div>
<div class="ttc" id="afast__math_8c_html_a5af7fb1bc56e2917540c1322b1ddb480"><div class="ttname"><a href="fast__math_8c.html#a5af7fb1bc56e2917540c1322b1ddb480">fast_sin</a></div><div class="ttdeci">float fast_sin(float theta)</div><div class="ttdoc">fast calculation of sine</div><div class="ttdef"><b>Definition:</b> <a href="fast__math_8c_source.html#l00072">fast_math.c:72</a></div></div>
<div class="ttc" id="afast__math_8h_html"><div class="ttname"><a href="fast__math_8h.html">fast_math.h</a></div><div class="ttdoc">this is the header file of fast_math.c, the macros of fast amplitude limiting algorithm and cosine fu...</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.2
</small></address>
</body>
</html>