From d6d9376b7f6fe81b8639c80bcf25d28cd1fa5b33 Mon Sep 17 00:00:00 2001 From: pelya Date: Wed, 29 Dec 2010 16:09:13 +0000 Subject: [PATCH] Fixed atan2i.h not included in SDL 1.3 --- .../jni/sdl-1.2/src/video/android/atan2i.h | 34 +------------------ .../jni/sdl-1.3/src/video/android/atan2i.h | 33 ++++++++++++++++++ 2 files changed, 34 insertions(+), 33 deletions(-) mode change 100644 => 120000 project/jni/sdl-1.2/src/video/android/atan2i.h create mode 100644 project/jni/sdl-1.3/src/video/android/atan2i.h diff --git a/project/jni/sdl-1.2/src/video/android/atan2i.h b/project/jni/sdl-1.2/src/video/android/atan2i.h deleted file mode 100644 index e7111a618..000000000 --- a/project/jni/sdl-1.2/src/video/android/atan2i.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __ATAN2I_H__ -#define __ATAN2I_H__ -#include - -// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits -// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif -enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0) }; - -static inline int atan2i(int y, int x) -{ - int angle; - int abs_y = abs(y); - if( abs_y == 0 ) - abs_y = 1; - if (x>=0) - { - angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y); - } - else - { - angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x); - } - if (y < 0) - return(-angle); // negate if in quad III or IV - else - return(angle); -}; - -#endif diff --git a/project/jni/sdl-1.2/src/video/android/atan2i.h b/project/jni/sdl-1.2/src/video/android/atan2i.h new file mode 120000 index 000000000..d67f9a7a7 --- /dev/null +++ b/project/jni/sdl-1.2/src/video/android/atan2i.h @@ -0,0 +1 @@ +../../../../sdl-1.3/src/video/android/atan2i.h \ No newline at end of file diff --git a/project/jni/sdl-1.3/src/video/android/atan2i.h b/project/jni/sdl-1.3/src/video/android/atan2i.h new file mode 100644 index 000000000..e7111a618 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/android/atan2i.h @@ -0,0 +1,33 @@ +#ifndef __ATAN2I_H__ +#define __ATAN2I_H__ +#include + +// Fast arctan2, returns angle in radians as integer, with fractional part in lower 16 bits +// Stolen from http://www.dspguru.com/dsp/tricks/fixed-point-atan2-with-self-normalization , precision is said to be 0.07 rads + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +enum { atan2i_coeff_1 = ((int)(M_PI*65536.0/4)), atan2i_coeff_2 = (3*atan2i_coeff_1), atan2i_PI = (int)(M_PI * 65536.0) }; + +static inline int atan2i(int y, int x) +{ + int angle; + int abs_y = abs(y); + if( abs_y == 0 ) + abs_y = 1; + if (x>=0) + { + angle = atan2i_coeff_1 - atan2i_coeff_1 * (x - abs_y) / (x + abs_y); + } + else + { + angle = atan2i_coeff_2 - atan2i_coeff_1 * (x + abs_y) / (abs_y - x); + } + if (y < 0) + return(-angle); // negate if in quad III or IV + else + return(angle); +}; + +#endif