nuclear@25: #include nuclear@26: #include "fixedp.h" nuclear@25: nuclear@25: const fixed fixed_zero = 0; nuclear@25: const fixed fixed_one = fixedi(1); nuclear@25: const fixed fixed_half = fixedf(0.5); nuclear@25: const fixed fixed_tenth = fixedf(0.1); nuclear@25: const fixed fixed_255 = fixedi(255); nuclear@25: nuclear@25: #ifndef DBG_USE_FLOAT nuclear@25: nuclear@25: #define PI 3.1415927 nuclear@25: #define TWO_PI 6.2831853 nuclear@25: nuclear@25: #define LUT_SIZE 256 nuclear@25: nuclear@25: static fixed sin_lut[LUT_SIZE], cos_lut[LUT_SIZE]; nuclear@25: static int initialized; nuclear@25: nuclear@25: static void precalc_lut(void) nuclear@25: { nuclear@25: int i; nuclear@25: nuclear@25: for(i=0; i= 0 ? sin_lut[a] : -sin_lut[-a]; nuclear@25: } nuclear@25: nuclear@25: fixed fixed_cos(fixed angle) { nuclear@25: int a; nuclear@25: nuclear@25: if(!initialized) precalc_lut(); nuclear@25: a = FIXED_INT_PART(fixed_div(angle, fix_two_pi) * 255) % 256; nuclear@25: return a >= 0 ? cos_lut[a] : cos_lut[-a]; nuclear@25: } nuclear@25: nuclear@25: #endif