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("const short ISINETABLE[4096] = {");
43 for (unsigned i
= 0; i
< 4096; i
++)
44 printf(" %d,\n", (int)lround(sin(INT_TO_DEG(i
)) * 1024));
47 puts("#ifdef FIXED_MATH");
48 puts("const fixed::value_t INVCOSINETABLE[4096] = {");
49 for (unsigned i
= 0; i
< 4096; i
++) {
50 double x
= cos(INT_TO_DEG(i
));
51 if ((x
>= 0) && (x
< 1.0e-8))
54 if ((x
< 0) && (x
> -1.0e-8))
57 #if defined(HAVE_MSVCRT) && !defined(__CYGWIN__)
58 // Due to non-standard behavior of the microsoft implementation
59 // this hack is needed to compile on windows machines
64 (long long)((double)fixed::resolution
/ x
));
67 puts("const fixed INVCOSINETABLE[4096] = {");
68 for (unsigned i
= 0; i
< 4096; i
++) {
69 double x
= cos(INT_TO_DEG(i
));
70 if ((x
>= 0) && (x
< 1.0e-8))
73 if ((x
< 0) && (x
> -1.0e-8))
76 printf(" fixed(%.20e),\n", 1.0 / x
);
81 printf("#define THERMALRECENCY_SIZE %d\n", ThermalLocator::TLOCATOR_NMAX
);
82 puts("#ifdef FIXED_MATH");
83 printf("const unsigned THERMALRECENCY[] = {\n");
84 for (unsigned i
= 0; i
< ThermalLocator::TLOCATOR_NMAX
; i
++)
85 printf(" %u,\n", (unsigned)(thermal_fn(i
) * (double)fixed::resolution
));
87 printf("const fixed THERMALRECENCY[%d] = {", ThermalLocator::TLOCATOR_NMAX
);
88 for (unsigned i
= 0; i
< ThermalLocator::TLOCATOR_NMAX
; i
++)
89 printf(" fixed(%.20e),\n", thermal_fn(i
));