diff --git a/core/math/fixed.c b/core/math/fixed.c index 8b3a9b57..6245f445 100644 --- a/core/math/fixed.c +++ b/core/math/fixed.c @@ -20,6 +20,7 @@ const static br_uint_16 sin_table[257]; const static br_uint_16 cos_table[257]; const static br_uint_16 arcsin_table[257]; +const static br_uint_16 arccos_table[257]; br_fixed_ls BR_PUBLIC_ENTRY BrFixedAbs(br_fixed_ls a) { @@ -112,6 +113,12 @@ br_fixed_luf BR_PUBLIC_ENTRY BrFixedASin(br_fixed_ls s) return interp(offset_input, arcsin_table); } +br_fixed_luf BR_PUBLIC_ENTRY BrFixedACos(br_fixed_ls c) +{ + br_int_16 offset_input = (br_int_16)((c + BR_ONE_LS) >> 1); + return interp(offset_input, arccos_table); +} + br_fixed_luf BR_PUBLIC_ENTRY BrFixedATan2(br_fixed_ls x, br_fixed_ls y) { float v = BrScalarToFloat(BR_ATAN2(BrFixedToScalar(x), BrFixedToScalar(y))); @@ -238,4 +245,40 @@ const static br_uint_16 arcsin_table[] = { 0x03184, 0x03276, 0x03379, 0x03493, 0x035C9, 0x03729, 0x038C9, 0x03AE7, 0x04000, }; + +const static br_uint_16 arccos_table[] = { + 0x07FFF, 0x07AE7, 0x078C9, 0x07729, 0x075C9, 0x07493, 0x07379, 0x07276, + 0x07184, 0x070A1, 0x06FC9, 0x06EFC, 0x06E37, 0x06D7A, 0x06CC4, 0x06C13, + 0x06B68, 0x06AC2, 0x06A21, 0x06984, 0x068EA, 0x06854, 0x067C1, 0x06731, + 0x066A4, 0x06619, 0x06591, 0x0650C, 0x06488, 0x06407, 0x06387, 0x06309, + 0x0628D, 0x06213, 0x0619A, 0x06123, 0x060AD, 0x06038, 0x05FC5, 0x05F53, + 0x05EE2, 0x05E73, 0x05E04, 0x05D96, 0x05D2A, 0x05CBE, 0x05C54, 0x05BEA, + 0x05B81, 0x05B19, 0x05AB2, 0x05A4C, 0x059E6, 0x05981, 0x0591D, 0x058BA, + 0x05857, 0x057F4, 0x05793, 0x05732, 0x056D1, 0x05671, 0x05612, 0x055B3, + 0x05555, 0x054F7, 0x0549A, 0x0543D, 0x053E0, 0x05384, 0x05329, 0x052CD, + 0x05273, 0x05218, 0x051BE, 0x05164, 0x0510B, 0x050B2, 0x05059, 0x05001, + 0x04FA9, 0x04F51, 0x04EFA, 0x04EA3, 0x04E4C, 0x04DF5, 0x04D9F, 0x04D48, + 0x04CF3, 0x04C9D, 0x04C47, 0x04BF2, 0x04B9D, 0x04B48, 0x04AF4, 0x04A9F, + 0x04A4B, 0x049F7, 0x049A3, 0x0494F, 0x048FC, 0x048A8, 0x04855, 0x04802, + 0x047AF, 0x0475C, 0x04709, 0x046B7, 0x04664, 0x04612, 0x045BF, 0x0456D, + 0x0451B, 0x044C9, 0x04477, 0x04425, 0x043D3, 0x04381, 0x0432F, 0x042DD, + 0x0428C, 0x0423A, 0x041E9, 0x04197, 0x04146, 0x040F4, 0x040A2, 0x04051, + 0x03FFF, 0x03FAE, 0x03F5D, 0x03F0B, 0x03EB9, 0x03E68, 0x03E16, 0x03DC5, + 0x03D73, 0x03D22, 0x03CD0, 0x03C7E, 0x03C2C, 0x03BDA, 0x03B88, 0x03B36, + 0x03AE4, 0x03A92, 0x03A40, 0x039ED, 0x0399B, 0x03948, 0x038F6, 0x038A3, + 0x03850, 0x037FD, 0x037AA, 0x03757, 0x03703, 0x036B0, 0x0365C, 0x03608, + 0x035B4, 0x03560, 0x0350B, 0x034B7, 0x03462, 0x0340D, 0x033B8, 0x03362, + 0x0330C, 0x032B7, 0x03260, 0x0320A, 0x031B3, 0x0315C, 0x03105, 0x030AE, + 0x03056, 0x02FFE, 0x02FA6, 0x02F4D, 0x02EF4, 0x02E9B, 0x02E41, 0x02DE7, + 0x02D8C, 0x02D32, 0x02CD6, 0x02C7B, 0x02C1F, 0x02BC2, 0x02B65, 0x02B08, + 0x02AAA, 0x02A4C, 0x029ED, 0x0298E, 0x0292E, 0x028CD, 0x0286C, 0x0280B, + 0x027A8, 0x02745, 0x026E2, 0x0267E, 0x02619, 0x025B3, 0x0254D, 0x024E6, + 0x0247E, 0x02415, 0x023AB, 0x02341, 0x022D5, 0x02269, 0x021FB, 0x0218C, + 0x0211D, 0x020AC, 0x0203A, 0x01FC7, 0x01F52, 0x01EDC, 0x01E65, 0x01DEC, + 0x01D72, 0x01CF6, 0x01C78, 0x01BF8, 0x01B77, 0x01AF3, 0x01A6E, 0x019E6, + 0x0195B, 0x018CE, 0x0183E, 0x017AB, 0x01715, 0x0167B, 0x015DE, 0x0153D, + 0x01497, 0x013EC, 0x0133B, 0x01285, 0x011C8, 0x01103, 0x01036, 0x00F5E, + 0x00E7B, 0x00D89, 0x00C86, 0x00B6C, 0x00A36, 0x008D6, 0x00736, 0x00518, + 0x00000, +}; // clang-format on