A much stripped down version of `PV_transForm' (accompanied by `copy_pixel').
[libopano.git] / src / utils_math.c
index 09b424f..744192a 100644 (file)
@@ -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 :
  */