5 #include "Math/Constants.h"
6 #include "Math/fixed.hpp"
7 #include "Computer/ThermalLocator.hpp"
15 return exp((-0.2/ThermalLocator::TLOCATOR_NMAX
)*pow((double)x
, 1.5));
21 return DEG_TO_RAD
* ((double)x
* 360) / 4096;
25 main(int argc
, char **argv
)
30 puts("#ifdef FIXED_MATH");
31 puts("const int SINETABLE[4096] = {");
32 for (unsigned i
= 0; i
< 4096; i
++)
34 (int)(sin(INT_TO_DEG(i
)) * (double)fixed::resolution
));
36 puts("const fixed SINETABLE[4096] = {");
37 for (unsigned i
= 0; i
< 4096; i
++)
38 printf(" fixed(%.20e),\n", sin(INT_TO_DEG(i
)));
42 puts("#ifdef FIXED_MATH");
43 puts("const int COSTABLE[4096] = {");
44 for (unsigned i
= 0; i
< 4096; i
++)
46 (int)(cos(INT_TO_DEG(i
)) * (double)fixed::resolution
));
48 puts("const fixed COSTABLE[4096] = {");
49 for (unsigned i
= 0; i
< 4096; i
++)
50 printf(" fixed(%.20e),\n", cos(INT_TO_DEG(i
)));
54 puts("const short ISINETABLE[4096] = {");
55 for (unsigned i
= 0; i
< 4096; i
++)
56 printf(" %d,\n", (int)lround(sin(INT_TO_DEG(i
)) * 1024));
59 puts("const short ICOSTABLE[4096] = {");
60 for (unsigned i
= 0; i
< 4096; i
++)
61 printf(" %d,\n", (int)lround(cos(INT_TO_DEG(i
)) * 1024));
64 puts("#ifdef FIXED_MATH");
65 puts("const fixed::value_t INVCOSINETABLE[4096] = {");
66 for (unsigned i
= 0; i
< 4096; i
++) {
67 double x
= cos(INT_TO_DEG(i
));
68 if ((x
>= 0) && (x
< 1.0e-8))
71 if ((x
< 0) && (x
> -1.0e-8))
74 #if defined(HAVE_MSVCRT) && !defined(__CYGWIN__)
75 // Due to non-standard behavior of the microsoft implementation
76 // this hack is needed to compile on windows machines
81 (long long)((double)fixed::resolution
/ x
));
84 puts("const fixed INVCOSINETABLE[4096] = {");
85 for (unsigned i
= 0; i
< 4096; i
++) {
86 double x
= cos(INT_TO_DEG(i
));
87 if ((x
>= 0) && (x
< 1.0e-8))
90 if ((x
< 0) && (x
> -1.0e-8))
93 printf(" fixed(%.20e),\n", 1.0 / x
);
98 printf("#define THERMALRECENCY_SIZE %d\n", ThermalLocator::TLOCATOR_NMAX
);
99 puts("#ifdef FIXED_MATH");
100 printf("const unsigned THERMALRECENCY[] = {\n");
101 for (unsigned i
= 0; i
< ThermalLocator::TLOCATOR_NMAX
; i
++)
102 printf(" %u,\n", (unsigned)(thermal_fn(i
) * (double)fixed::resolution
));
104 printf("const fixed THERMALRECENCY[%d] = {", ThermalLocator::TLOCATOR_NMAX
);
105 for (unsigned i
= 0; i
< ThermalLocator::TLOCATOR_NMAX
; i
++)
106 printf(" fixed(%.20e),\n", thermal_fn(i
));