📄 fix_8cpp-source.html
字号:
00747 0x028be5ec,0x02b75bab,0x02e906ce,0x0322561d,0x036532a4,0x03b43743,0x0413099b,0x0486ee3e,00748 0x0517cc0b,0x05d20dc8,0x06ca656d,0x08261355,0x0a2f982f,0x0d94caee,0x145f306a,0x28be60d9,00749 0xffffffff00750 };00751 r = TanTable3F90[n-0x3f90];00752 }00753 <span class="keywordflow">else</span>00754 {00755 <span class="comment">// result is infinity so return saturated result</span>00756 <span class="keywordflow">return</span> angle<0 ? (<a class="code" href="group__integers.html#ga5">int32</a>)-0x80000000 : (<a class="code" href="group__integers.html#ga5">int32</a>)0x7fffffff;00757 }00758 00759 <span class="keywordflow">return</span> neg ? -(<a class="code" href="group__integers.html#ga5">int32</a>)r: (<a class="code" href="group__integers.html#ga5">int32</a>)r;00760 }00761 00762 <a name="l00763"></a><a class="code" href="classFix.html#e12">00763</a> <a class="code" href="common_8h.html#a2">EXPORT</a> <a class="code" href="group__fix.html#ga2">fixangle</a> <a class="code" href="classFix.html#e12">Fix::ACos</a>(fix value)00764 {00765 <span class="keywordflow">if</span>(value<-0x10000)00766 value = -0x10000;00767 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(value>0x10000)00768 value = 0x10000;00769 <span class="keywordflow">return</span> 0x4000-<a class="code" href="classFix.html#e11">Fix::ASin</a>(value);00770 }00771 00772 <a name="l00773"></a><a class="code" href="classFix.html#e11">00773</a> <a class="code" href="common_8h.html#a2">EXPORT</a> <a class="code" href="group__fix.html#ga2">fixangle</a> <a class="code" href="classFix.html#e11">Fix::ASin</a>(fix value)00774 {00775 <a class="code" href="group__integers.html#ga6">uint</a> n = value;00776 <span class="keywordflow">if</span>(value<0)00777 n = (<a class="code" href="group__integers.html#ga6">uint</a>)-(int)n;00778 00779 <span class="comment">// calculare arc-sine by interpolation of lookup table values</span>00780 <span class="keywordtype">int</span> r;00781 <span class="keywordflow">if</span>(n<0xc000)00782 {00783 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> ASinTable0000[] =00784 {00785 0xfffeb9ff,00786 0x00000000,0x00014601,0x00028c53,0x0003d349,0x00051b37,0x00066474,0x0007af57,0x0008fc3f,00787 0x000a4b8d,0x000b9daa,0x000cf305,0x000e4c19,0x000fa967,0x00110b83,0x0012730c,0x0013e0b9,00788 0x00155555,0x0016d1cc,0x0018572d,0x0019e6b6,0x001b81e1,0x001d2a76,0x001ee2a7,0x0020ad31,00789 0x00228d9c,0x0024889000790 };00791 r = Interpolate(ASinTable0000,n,11);00792 }00793 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<0xf200)00794 {00795 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> ASinTableC000[] =00796 {00797 0x00221339,00798 0x00228d9c,0x002309a5,0x0023876b,0x00240706,0x00248890,0x00250c26,0x002591e7,0x002619f5,00799 0x0026a476,0x00273194,0x0027c17d,0x00285465,0x0028ea85,0x00298420,0x002a217e,0x002ac2f5,00800 0x002b68e6,0x002c13c1,0x002cc40b,0x002d7a5e,0x002e3777,0x002efc36,0x002fc9b5,0x0030a152,00801 0x003184d3,0x0032768f,0x003379c100802 };00803 r = Interpolate(ASinTableC000,n-0xc000,9);00804 }00805 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<0xfe00)00806 {00807 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> ASinTableF200[] =00808 {00809 0x003238a2,0x0032768f,0x0032b592,0x0032f5ba,0x00333719,00810 0x003379c1,0x0033bdc8,0x00340345,0x00344a52,0x0034930c,0x0034dd94,0x00352a10,0x003578a9,00811 0x0035c991,0x00361d01,0x0036733a,0x0036cc8b,0x00372953,0x00378a02,0x0037ef25,0x0038596e,00812 0x0038c9be,0x00394144,0x0039c19e,0x003a4d1f,0x003ae75a,0x003b965400813 };00814 r = Interpolate(ASinTableF200,n-0xF200,7);00815 }00816 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0xffe0)00817 {00818 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> ASinTableFE00[] =00819 {00820 0x003ad319,00821 0x003ae75a,0x003afbed,0x003b10d5,0x003b2617,0x003b3bb7,0x003b51ba,0x003b6827,0x003b7f02,00822 0x003b9654,0x003bae22,0x003bc677,0x003bdf5a,0x003bf8d6,0x003c12f8,0x003c2dcb,0x003c4960,00823 0x003c65c7,0x003c8314,0x003ca160,0x003cc0c5,0x003ce165,0x003d0369,0x003d2702,0x003d4c6e,00824 0x003d73ff,0x003d9e1e,0x003dcb5f,0x003dfc94,0x003e3300,0x003e70c5,0x003eba0a,0x003f198400825 };00826 r = Interpolate(ASinTableFE00,n-0xFE00,4);00827 }00828 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x10000)00829 {00830 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> ASinTableFFE1[] =00831 {00832 0x003ebf2c,0x003ec464,0x003ec9b2,0x003ecf17,0x003ed496,0x003eda2f,0x003edfe4,00833 0x003ee5b6,0x003eeba8,0x003ef1bb,0x003ef7f2,0x003efe4f,0x003f04d5,0x003f0b88,0x003f126c,00834 0x003f1984,0x003f20d5,0x003f2867,0x003f303e,0x003f3865,0x003f40e5,0x003f49c9,0x003f5323,00835 0x003f5d06,0x003f678d,0x003f72dc,0x003f7f28,0x003f8cc2,0x003f9c33,0x003fae83,0x003fc661,00836 0x00400000,00837 };00838 r = ASinTableFFE1[n-0xffe1];00839 }00840 <span class="keywordflow">else</span>00841 {00842 <span class="comment">// value out of range, return PI/2</span>00843 r = 0x00400000;00844 }00845 00846 <span class="comment">// scale result to 16 bits (from the 24 bit precision used in lookup table)</span>00847 r = (r+(1<<(8-1)))>>8;00848 00849 <span class="comment">// produce correct sign for result</span>00850 <span class="keywordflow">if</span>(value<0)00851 r = -r;00852 00853 <span class="keywordflow">return</span> r;00854 }00855 <a name="l00856"></a><a class="code" href="classFix.html#e13">00856</a> <a class="code" href="common_8h.html#a2">EXPORT</a> <a class="code" href="group__fix.html#ga2">fixangle</a> <a class="code" href="classFix.html#e13">Fix::ATan</a>(fix value)00857 {00858 <a class="code" href="group__integers.html#ga6">uint</a> n = value;00859 <span class="keywordflow">if</span>(value<0)00860 n = (<a class="code" href="group__integers.html#ga6">uint</a>)-(int)n;00861 00862 <span class="comment">// calculare arc-tangent by interpolation of lookup table values</span>00863 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> ATanTable[] = 00864 {00865 0xfffeba28,00866 0x00000000,0x000145d8,0x00028b0d,0x0003cf00,0x00051112,0x000650ad,0x00078d40,0x0008c643,00867 0x0009fb38,0x000b2bac,0x000c5734,0x000d7d75,0x000e9e1d,0x000fb8e7,0x0010cd99,0x0011dc04,00868 0x0012e405,0x0013e582,0x0014e06a,0x0015d4b7,0x0016c267,0x0017a982,0x00188a16,0x00196434,00869 0x001a37f6,0x001b0575,0x001bccd2,0x001c8e2d,0x001d49ab,0x001dff72,0x001eafa7,0x001f5a74,00870 0x00200000,0x0020a074,00871 };00872 <span class="keywordtype">int</span> r;00873 <span class="keywordflow">if</span>(n<=0x10000)00874 {00875 r = Interpolate(ATanTable,n,11);00876 }00877 <span class="keywordflow">else</span>00878 {00879 <span class="comment">// For n>1 use the identity ATAN(n) = PI/2-ATAN(1/n)</span>00880 n = (<a class="code" href="group__integers.html#ga6">uint</a>)-(int)(n>>1)/(<a class="code" href="group__integers.html#ga6">uint</a>)n+1; <span class="comment">// n = 1/n</span>00881 r = Interpolate(ATanTable,n,11);00882 r = 0x400000-r; <span class="comment">// r = PI/2-r</span>00883 }00884 00885 <span class="comment">// scale result to 16 bits (from the 24 bit precision used in lookup table)</span>00886 r = (r+(1<<(8-1)))>>8;00887 00888 <span class="keywordflow">if</span>(value<0)00889 r = -r;00890 00891 <span class="keywordflow">return</span> r;00892 }00893 00894 <a name="l00895"></a><a class="code" href="classFix.html#e14">00895</a> <a class="code" href="common_8h.html#a2">EXPORT</a> <a class="code" href="group__fix.html#ga0">fix</a> <a class="code" href="classFix.html#e14">Fix::Random</a>(uint32& seed)00896 {00897 <span class="keywordflow">return</span> seed=(seed*69069+1);00898 }00899 00900 <a name="l00901"></a><a class="code" href="classFix.html#e15">00901</a> <a class="code" href="common_8h.html#a2">EXPORT</a> <a class="code" href="group__fix.html#ga1">ufix</a> <a class="code" href="classFix.html#e14">Fix::Random</a>(uint32& seed,ufix range)00902 {00903 <span class="comment">// generate next random number</span>00904 <a class="code" href="group__fix.html#ga1">ufix</a> n = seed=(seed*69069+1);00905 00906 <span class="comment">// multiply range by random number (we won't bother with carry from low order half</span>00907 <span class="comment">// of 64bit result because we don't really need acuracy for random numbers.)</span>00908 <a class="code" href="group__fix.html#ga1">ufix</a> lo = range&0xffff;00909 <a class="code" href="group__fix.html#ga1">ufix</a> hi = range>>16;00910 <a class="code" href="group__fix.html#ga1">ufix</a> r = hi*(n&0xffff)>>16;00911 n >>= 16;00912 r += lo*n>>16;00913 r += hi*n;00914 00915 <span class="keywordflow">return</span> r;00916 }00917 00918 </pre></div><HR><ADDRESS STYLE="align: right;"><SMALL>Generated by <A HREF="http://www.doxygen.org/index.html"><IMG SRC="doxygen.png" ALT="doxygen" ALIGN="middle" BORDER="0"></A> 1.4.1</SMALL></ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -