X-Git-Url: https://git.octo.it/?p=libopano.git;a=blobdiff_plain;f=src%2Futils_math.c;fp=src%2Futils_math.c;h=744192a7ad1a7534bd0f46f72c6804c9660a2f21;hp=09b424fedcf2def1a887e1e088b5557a128ea460;hb=f021ce36e37def0e39914e92c8ad2ba49c847c6f;hpb=0d448cc6928c5e448bc6b42dfb39fc4c193d4733 diff --git a/src/utils_math.c b/src/utils_math.c index 09b424f..744192a 100644 --- a/src/utils_math.c +++ b/src/utils_math.c @@ -28,7 +28,6 @@ #define ATAN_TABLE_SIZE 4096 #define SQRT_TABLE_SIZE 4096 -static int *atan_table = NULL; static int *sqrt_table = NULL; static int setup_sqrt_table (void) @@ -79,63 +78,6 @@ int utils_sqrt2 (int x1, int x2) return (ret); } /* int utils_sqrt2 */ -static int setup_atan_table (void) -{ - int i; - double z; - - atan_table = (int *) malloc (ATAN_TABLE_SIZE * sizeof (int)); - if (atan_table == NULL) - return (-1); - - for (i = 0; i < (ATAN_TABLE_SIZE - 1); i++) - { - z = ((double) i) / ((double) (ATAN_TABLE_SIZE - 1)); - atan_table[i] = atan ( z / (1.0 - z ) ) * ATAN_TABLE_SIZE * 256; - } - atan_table[ATAN_TABLE_SIZE - 1] = M_PI_4 * ATAN_TABLE_SIZE * 256; - - return 0; -} /* int setup_atan_table */ - -int utils_atan2 (int y, int x) -{ - if (atan_table == NULL) - if (setup_atan_table () != 0) - return (-1); - - // return atan2(y,x) * 256*ATAN_TABLE_SIZE; - if( x > 0 ) - { - if( y > 0 ) - { - return atan_table[(int)( ATAN_TABLE_SIZE * y / ( x + y ))]; - } - else - { - return -atan_table[ (int)(ATAN_TABLE_SIZE * (-y) / ( x - y ))]; - } - } - - if( x == 0 ) - { - if( y > 0 ) - return (int)(256*ATAN_TABLE_SIZE * M_PI_2); - else - return -(int)(256*ATAN_TABLE_SIZE * M_PI_2); - } - - if( y < 0 ) - { - return atan_table[(int)( ATAN_TABLE_SIZE * y / ( x + y ))] - (int)(M_PI*256*ATAN_TABLE_SIZE); - } - else - { - return -atan_table[ (int)(ATAN_TABLE_SIZE * (-y) / ( x - y ))] + (int)(M_PI*256*ATAN_TABLE_SIZE); - } - -} - /* * vim: set tabstop=8 softtabstop=2 shiftwidth=2 : */