📄 fix_8cpp-source.html
字号:
00564 <span class="keywordflow">if</span>(angle&(1<<14))00565 n = 0x4000-n;00566 00567 <span class="comment">// calc Sin through table lookup</span>00568 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> SinTable[] =00569 {00570 -0x000c8fb3,00571 0x00000000,0x000c8fb3,0x001917a7,0x00259021,0x0031f170,0x003e33f3,0x004a5019,0x00563e6a,00572 0x0061f78b,0x006d7440,0x0078ad75,0x00839c3d,0x008e39da,0x00987fc0,0x00a26799,0x00abeb4a,00573 0x00b504f3,0x00bdaef9,0x00c5e403,0x00cd9f02,0x00d4db31,0x00db941a,0x00e1c598,0x00e76bd8,00574 0x00ec835e,0x00f10908,0x00f4fa0b,0x00f853f8,0x00fb14be,0x00fd3aac,0x00fec46d,0x00ffb10f,00575 0x01000000,0x00ffb10f,0x00ffb10f00576 };00577 <span class="keywordtype">int</span> r = Interpolate(SinTable,n,9);00578 00579 <span class="comment">// scale result to 16 bits (from the 24 bit precision used in lookup table)</span>00580 r = (r+(1<<(8-1)))>>8;00581 00582 <span class="comment">// produce correct sign for result</span>00583 <span class="keywordflow">if</span>(angle&(1<<15))00584 r = -r;00585 00586 <span class="keywordflow">return</span> r;00587 }00588 00589 <a name="l00590"></a><a class="code" href="classFix.html#e10">00590</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#e10">Fix::Tan</a>(fixangle angle)00591 {00592 <span class="comment">// n = angle in first quadrant</span>00593 <span class="keywordtype">int</span> n = angle&0x7fff;00594 <span class="keywordtype">bool</span> neg = n>0x4000;00595 <span class="keywordflow">if</span>(neg) n = 0x8000-n;00596 00597 <span class="comment">// calculate tangent by interpolation of lookup table values</span>00598 <a class="code" href="group__integers.html#ga6">uint</a> r;00599 <span class="keywordflow">if</span>(n<=0x2000)00600 {00601 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable0000[] =00602 {00603 0xffe6dcba,00604 0x00000000,0x00192346,0x00324e4f,0x004b88e7,0x0064daee,0x007e4c61,0x0097e564,0x00b1ae4d,00605 0x00cbafaf,0x00e5f267,0x01007fa7,0x011b6104,0x0136a083,0x015248ae,0x016e649f,0x018b0019,00606 0x01a8279a,0x01c5e872,0x01e450e1,0x02037033,0x022356e3,0x024416be,0x0265c311,0x028870db,00607 0x02ac3705,0x02d12ea3,0x02f7733e,0x031f232f,0x03486005,0x03734ef8,0x03a01979,0x03ceedd6,00608 0x04000000,0x04338a7400609 };00610 r = Interpolate(TanTable0000,n-0x0000,8);00611 <span class="comment">// scale result to 16 bits (from the 26 bit precision used in lookup table)</span>00612 r = (r+(1<<(10-1)))>>10;00613 }00614 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x2d80)00615 {00616 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable2000[] =00617 {00618 0x01f395da,00619 0x02000000,0x020cb920,0x0219c53a,0x02272890,0x0234e7ab,0x02430762,0x02518ce0,0x02607dac,00620 0x026fdfb2,0x027fb948,0x0290113f,0x02a0eee8,0x02b25a22,0x02c45b6c,0x02d6fbf1,0x02ea4598,00621 0x02fe431c,0x03130022,0x0328894f,0x033eec66,0x0356386c,0x036e7dc8,0x0387ce70,0x03a23e1b,00622 0x03bde277,0x03dad368,0x03f92b57,0x04190786,0x043a887600623 };00624 r = Interpolate(TanTable2000,n-0x2000,7);00625 <span class="comment">// scale result to 16 bits (from the 25 bit precision used in lookup table)</span>00626 r = (r+(1<<(9-1)))>>9;00627 }00628 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x35c0)00629 {00630 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable2D80[] =00631 {00632 0x0204737a,0x020c83c3,0x0214c89d,00633 0x021d443b,0x0225f8ef,0x022ee92e,0x02381791,0x024186d9,0x024b39ef,0x025533ea,0x025f7813,00634 0x026a09e6,0x0274ed19,0x0280259c,0x028bb7a6,0x0297a7b1,0x02a3fa88,0x02b0b54a,0x02bddd70,00635 0x02cb78da,0x02d98dd2,0x02e8231d,0x02f73fff,0x0306ec4e,0x0317307b,0x032815a6,0x0339a5ac,00636 0x034beb3d,0x035ef1f2,0x0372c665,0x03877650,0x039d10ad,0x03b3a5d7,0x03cb47bd,0x03e40a0a,00637 0x03fe026100638 };00639 r = Interpolate(TanTable2D80,n-0x2d80,6);00640 <span class="comment">// scale result to 16 bits (from the 24 bit precision used in lookup table)</span>00641 r = (r+(1<<(8-1)))>>8;00642 }00643 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x39e0)00644 {00645 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable35C0[] =00646 {00647 0x01ebc1c4,0x01f20505,0x01f86f02,00648 0x01ff0130,0x0205bd16,0x020ca44f,0x0213b88a,0x021afb90,0x02226f3e,0x022a158f,0x0231f097,00649 0x023a0288,0x02424db5,0x024ad491,0x025399b6,0x025c9fe3,0x0265ea01,0x026f7b26,0x0279569c,00650 0x02837fdc,0x028dfa9d,0x0298cace,0x02a3f4a5,0x02af7c9d,0x02bb6780,0x02c7ba6a,0x02d47ad7,00651 0x02e1aea3,0x02ef5c1b,0x02fd8a00,0x030c3f99,0x031b84b8,0x032b61d0,0x033be000,0x034d0923,00652 0x035ee7ea00653 };00654 r = Interpolate(TanTable35C0,n-0x35c0,5);00655 <span class="comment">// scale result to 16 bits (from the 23 bit precision used in lookup table)</span>00656 r = (r+(1<<(7-1)))>>7;00657 }00658 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x3c70)00659 {00660 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable39E0[] =00661 {00662 0x01a22f46,0x01a68491,0x01aaf08f,00663 0x01af73f5,0x01b40f80,0x01b8c3f6,0x01bd9224,0x01c27ae2,0x01c77f0f,0x01cc9f96,0x01d1dd6a,00664 0x01d7398d,0x01dcb509,0x01e250f7,0x01e80e7b,0x01edeec8,0x01f3f321,0x01fa1cd8,0x02006d4d,00665 0x0206e5f6,0x020d885a,0x02145612,0x021b50d0,0x02227a5a,0x0229d48f,0x02316169,0x023922fc,00666 0x02411b7b,0x02494d38,0x0251baa7,0x025a6660,0x02635323,0x026c83da,0x0275fb9a,0x027fbdac,00667 0x0289cd8b,0x02942eec,0x029ee5c0,0x02a9f63c,0x02b564da,0x02c13664,0x02cd6ff9,0x02da1711,00668 0x02e7318b00669 };00670 r = Interpolate(TanTable39E0,n-0x39e0,4);00671 <span class="comment">// scale result to 16 bits (from the 22 bit precision used in lookup table)</span>00672 r = (r+(1<<(6-1)))>>6;00673 }00674 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x3df0)00675 {00676 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable3C70[] =00677 {00678 0x0169dabd,0x016d0b89,0x01704ac0,00679 0x017398c5,0x0176f600,0x017a62d9,0x017ddfbf,0x01816d24,0x01850b7f,0x0188bb49,0x018c7d04,00680 0x01905133,0x01943860,0x0198331a,0x019c41f6,0x01a0658d,0x01a49e82,0x01a8ed7c,0x01ad5328,00681 0x01b1d03c,0x01b66576,0x01bb139b,0x01bfdb79,0x01c4bde6,0x01c9bbc2,0x01ced5f9,0x01d40d7d,00682 0x01d96350,0x01ded87c,0x01e46e1a,0x01ea254f,0x01efff4d,0x01f5fd57,0x01fc20be,0x02026ae5,00683 0x0208dd40,0x020f7955,0x021640bf,0x021d352e,0x0224586a,0x022bac51,0x023332de,0x023aee23,00684 0x0242e055,0x024b0bc4,0x025372e6,0x025c1852,0x0264fec8,0x026e2932,0x02779aa6,0x0281566b00685 };00686 r = Interpolate(TanTable3C70,n-0x3c70,3);00687 <span class="comment">// scale result to 16 bits (from the 21 bit precision used in lookup table)</span>00688 r = (r+(1<<(5-1)))>>5;00689 }00690 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x3ebc)00691 {00692 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable3DF0[] =00693 {00694 0x01396c6c,0x013bcd53,0x013e3784,0x0140ab35,0x014328a0,00695 0x0145afff,0x0148418d,0x014add89,0x014d8433,0x015035cd,0x0152f29c,0x0155bae5,0x01588ef2,00696 0x015b6f0e,0x015e5b87,0x016154ad,0x01645ad4,0x01676e52,0x016a8f7f,0x016dbeb8,0x0170fc5c,00697 0x017448cf,0x0177a477,0x017b0fbd,0x017e8b10,0x018216e2,0x0185b3aa,0x018961e2,0x018d220a,00698 0x0190f4a6,0x0194da41,0x0198d368,0x019ce0b1,0x01a102b6,0x01a53a18,0x01a9877e,0x01adeb98,00699 0x01b26719,0x01b6fac1,0x01bba753,0x01c06d9e,0x01c54e79,0x01ca4ac3,0x01cf6366,0x01d49958,00700 0x01d9ed98,0x01df6132,0x01e4f53d,0x01eaaadf,0x01f0834b,0x01f67fc3,0x01fca197,0x0202ea2c,00701 0x02095af400702 };00703 r = Interpolate(TanTable3DF0,n-0x3df0,2);00704 <span class="comment">// scale result to 16 bits (from the 20 bit precision used in lookup table)</span>00705 r = (r+(1<<(4-1)))>>4;00706 }00707 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<=0x3f90)00708 {00709 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable3EBC[] =00710 {00711 0x00ffe079,0x01017516,0x01030eb9,00712 0x0104ad7a,0x01065172,0x0107fabb,0x0109a96e,0x010b5da7,0x010d1780,0x010ed715,0x01109c84,00713 0x011267ea,0x01143965,0x01161115,0x0117ef18,0x0119d391,0x011bbea1,0x011db06b,0x011fa912,00714 0x0121a8bb,0x0123af8b,0x0125bda9,0x0127d33e,0x0129f071,0x012c156d,0x012e425e,0x0130776f,00715 0x0132b4cf,0x0134faae,0x0137493b,0x0139a0a9,0x013c012c,0x013e6af8,0x0140de45,0x01435b4b,00716 0x0145e245,0x0148736f,0x014b0f06,0x014db54c,0x01506681,0x015322eb,0x0155ead0,0x0158be78,00717 0x015b9e30,0x015e8a44,0x01618306,0x016488c8,0x01679be1,0x016abcaa,0x016deb7e,0x017128be,00718 0x017474cc,0x0177d00f,0x017b3af1,0x017eb5e0,0x0182414d,0x0185ddb0,0x01898b84,0x018d4b47,00719 0x01911d7f,0x019502b5,0x0198fb77,0x019d085b,0x01a129fc,0x01a560f9,0x01a9adfb,0x01ae11b0,00720 0x01b28ccd,0x01b72010,0x01bbcc3e,0x01c09224,0x01c5729a,0x01ca6e80,0x01cf86bf,0x01d4bc4c,00721 0x01da1028,0x01df835d,0x01e51704,0x01eacc41,0x01f0a448,0x01f6a05b,0x01fcc1cc,0x020309fc,00722 0x02097a5f,0x0210147d,0x0216d9f0,0x021dcc68,0x0224edad,0x022c3f9d,0x0233c433,0x023b7d81,00723 0x02436dbc,0x024b9734,0x0253fc5f,0x025c9fd4,0x02658453,0x026eacc6,0x02781c43,0x0281d611,00724 0x028bddad,0x029636cb,0x02a0e55c,0x02abed94,0x02b753f0,0x02c31d37,0x02cf4e89,0x02dbed5f,00725 0x02e8ff97,0x02f68b7b00726 };00727 r = Interpolate(TanTable3EBC,n-0x3ebc,1);00728 <span class="comment">// scale result to 16 bits (from the 19 bit precision used in lookup table)</span>00729 r = (r+(1<<(3-1)))>>3;00730 }00731 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(n<0x4000)00732 {00733 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__integers.html#ga5">int32</a> TanTable3F90[] =00734 {00735 0x005d1ff3,0x005df6bd,0x005ed16f,0x005fb025,0x006092fa,0x00617a0c,0x0062657b,0x00635566,00736 0x006449ed,0x00654334,0x0066415f,0x00674491,0x00684cf3,0x00695aac,0x006a6de7,0x006b86ce,00737 0x006ca58f,0x006dca59,0x006ef55e,0x007026d1,0x00715ee9,0x00729ddc,0x0073e3e5,0x00753142,00738 0x00768633,0x0077e2fa,0x007947dd,0x007ab526,0x007c2b22,0x007daa20,0x007f3276,0x0080c47c,00739 0x0082608e,0x00840710,0x0085b866,0x008774fe,0x00893d49,0x008b11bf,0x008cf2de,0x008ee12b,00740 0x0090dd33,0x0092e78b,0x009500d0,0x009729a7,0x009962c0,0x009bacd6,0x009e08af,0x00a0771d,00741 0x00a2f8fd,0x00a58f3f,0x00a83add,0x00aafce4,0x00add675,0x00b0c8c1,0x00b3d50f,0x00b6fcbe,00742 0x00ba4145,0x00bda438,0x00c12747,0x00c4cc43,0x00c89521,0x00cc83fe,0x00d09b21,0x00d4dd01,00743 0x00d94c4b,0x00ddebe4,0x00e2bef2,0x00e7c8e5,0x00ed0d7a,0x00f290c9,0x00f8574c,0x00fe65ee,00744 0x0104c218,0x010b71c1,0x01127b80,0x0119e6a4,0x0121bb49,0x012a027b,0x0132c656,0x013c122e,00745 0x0145f2c4,0x0150767c,0x015bada6,0x0167aad4,0x0174833b,0x01824f38,0x01912ae6,0x01a136df,00746 0x01b2992c,0x01c57e75,0x01da1b7f,0x01f0af1b,0x020984ae,0x0224f778,0x02437703,0x02658d16,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -