Definition at line 100 of file fttrigon.c.
Referenced by FT_Atan2(), FT_Vector_Length(), FT_Vector_Polarize(), and FT_Vector_Rotate().
{
FT_Fixed x, y, z;
FT_Int shift;
x = vec->x;
y = vec->y;
z = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y );
shift = 0;
#if 1
if ( z >= ( 1L << 16 ) )
{
z >>= 16;
shift += 16;
}
if ( z >= ( 1L << 8 ) )
{
z >>= 8;
shift += 8;
}
if ( z >= ( 1L << 4 ) )
{
z >>= 4;
shift += 4;
}
if ( z >= ( 1L << 2 ) )
{
z >>= 2;
shift += 2;
}
if ( z >= ( 1L << 1 ) )
{
z >>= 1;
shift += 1;
}
if ( shift <= 27 )
{
shift = 27 - shift;
vec->x = x << shift;
vec->y = y << shift;
}
else
{
shift -= 27;
vec->x = x >> shift;
vec->y = y >> shift;
shift = -shift;
}
#else
if ( z < ( 1L << 27 ) )
{
do
{
shift++;
z <<= 1;
} while ( z < ( 1L << 27 ) );
vec->x = x << shift;
vec->y = y << shift;
}
else if ( z > ( 1L << 28 ) )
{
do
{
shift++;
z >>= 1;
} while ( z > ( 1L << 28 ) );
vec->x = x >> shift;
vec->y = y >> shift;
shift = -shift;
}
#endif
return shift;
}