Alchemy
Loading...
Searching...
No Matches

math_table.c

Go to the documentation of this file.
2#include "types.h"
3#include "system.h"
4
5/// A quarter-wave sine table, scaled by 65536.
6// clang-format off
7const u16 gMath_SinQuarter[256] = {
8 0, 402, 804, 1206, 1608, 2010, 2412, 2814,
9 3216, 3617, 4019, 4420, 4821, 5222, 5623, 6023,
10 6424, 6824, 7224, 7623, 8022, 8421, 8820, 9218,
11 9616, 10014, 10411, 10808, 11204, 11600, 11996, 12391,
12 12785, 13180, 13573, 13966, 14359, 14751, 15143, 15534,
13 15924, 16314, 16703, 17091, 17479, 17867, 18253, 18639,
14 19024, 19409, 19792, 20175, 20557, 20939, 21320, 21699,
15 22078, 22457, 22834, 23210, 23586, 23961, 24335, 24708,
16 25080, 25451, 25821, 26190, 26558, 26925, 27291, 27656,
17 28020, 28383, 28745, 29106, 29466, 29824, 30182, 30538,
18 30893, 31248, 31600, 31952, 32303, 32652, 33000, 33347,
19 33692, 34037, 34380, 34721, 35062, 35401, 35738, 36075,
20 36410, 36744, 37076, 37407, 37736, 38064, 38391, 38716,
21 39040, 39362, 39683, 40002, 40320, 40636, 40951, 41264,
22 41576, 41886, 42194, 42501, 42806, 43110, 43412, 43713,
23 44011, 44308, 44604, 44898, 45190, 45480, 45769, 46056,
24 46341, 46624, 46906, 47186, 47464, 47741, 48015, 48288,
25 48559, 48828, 49095, 49361, 49624, 49886, 50146, 50404,
26 50660, 50914, 51166, 51417, 51665, 51911, 52156, 52398,
27 52639, 52878, 53114, 53349, 53581, 53812, 54040, 54267,
28 54491, 54714, 54934, 55152, 55368, 55582, 55794, 56004,
29 56212, 56418, 56621, 56823, 57022, 57219, 57414, 57607,
30 57798, 57986, 58172, 58356, 58538, 58718, 58896, 59071,
31 59244, 59415, 59583, 59750, 59914, 60075, 60235, 60392,
32 60547, 60700, 60851, 60999, 61145, 61288, 61429, 61568,
33 61705, 61839, 61971, 62101, 62228, 62353, 62476, 62596,
34 62714, 62830, 62943, 63054, 63162, 63268, 63372, 63473,
35 63572, 63668, 63763, 63854, 63944, 64031, 64115, 64197,
36 64277, 64354, 64429, 64501, 64571, 64639, 64704, 64766,
37 64827, 64884, 64940, 64993, 65043, 65091, 65137, 65180,
38 65220, 65259, 65294, 65328, 65358, 65387, 65413, 65436,
39 65457, 65476, 65492, 65505, 65516, 65525, 65531, 65535,
40};
41
42/// floor(i * 2π)
44 0, 6, 12, 18, 25, 31, 37, 43,
45};
46
47/// The sine at 0, 90, 180 and 270 degrees, in Q16.
49 0, 65536, 0, -65536,
50};
51
52/// Tangents scaled by 256: index i is tan(i * 45 / 128 degrees),
53/// so index 128 is tan(45 degrees).
54/// ArcTan2 starts its binary search at index 127.
55const u16 gMath_TanTable[258] = {
56 0, 1, 3, 4, 6, 7, 9, 11,
57 12, 14, 15, 17, 18, 20, 22, 23,
58 25, 26, 28, 30, 31, 33, 34, 36,
59 38, 39, 41, 42, 44, 46, 47, 49,
60 50, 52, 54, 55, 57, 59, 60, 62,
61 64, 65, 67, 69, 70, 72, 74, 76,
62 77, 79, 81, 82, 84, 86, 88, 89,
63 91, 93, 95, 97, 98, 100, 102, 104,
64 106, 108, 109, 111, 113, 115, 117, 119,
65 121, 123, 125, 127, 129, 131, 133, 135,
66 137, 139, 141, 143, 145, 147, 149, 151,
67 153, 155, 158, 160, 162, 164, 166, 169,
68 171, 173, 175, 178, 180, 182, 185, 187,
69 190, 192, 195, 197, 200, 202, 205, 207,
70 210, 213, 215, 218, 221, 224, 226, 229,
71 232, 235, 238, 241, 244, 247, 250, 253,
72 256, 259, 262, 266, 269, 272, 276, 279,
73 283, 286, 290, 293, 297, 301, 304, 308,
74 312, 316, 320, 324, 328, 333, 337, 341,
75 346, 350, 355, 359, 364, 369, 374, 379,
76 384, 389, 394, 400, 405, 411, 416, 422,
77 428, 434, 440, 447, 453, 460, 466, 473,
78 480, 487, 495, 502, 510, 518, 526, 534,
79 543, 552, 561, 570, 580, 589, 599, 610,
80 620, 631, 643, 654, 666, 679, 692, 705,
81 719, 733, 748, 763, 779, 795, 813, 830,
82 849, 868, 888, 909, 931, 954, 978, 1003,
83 1029, 1057, 1086, 1117, 1150, 1184, 1220, 1259,
84 1299, 1343, 1389, 1439, 1492, 1549, 1611, 1677,
85 1749, 1827, 1913, 2007, 2110, 2224, 2351, 2494,
86 2654, 2836, 3045, 3287, 3571, 3907, 4313, 4813,
87 5444, 6264, 7374, 8962, 11421, 15736, 25290, 64362,
88 65535, 0,
89};
90// clang-format on
const s32 gMath_QuadrantSin[4]
The sine at 0, 90, 180 and 270 degrees, in Q16.
Definition math_table.c:48
const u16 gMath_TanTable[258]
Tangents scaled by 256: index i is tan(i * 45 / 128 degrees), so index 128 is tan(45 degrees).
Definition math_table.c:55
const u16 gMath_TwoPiSteps[8]
floor(i * 2π)
Definition math_table.c:43
const u16 gMath_SinQuarter[256]
A quarter-wave sine table, scaled by 65536.
Definition math_table.c:7
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned short u16
Definition types.h:13