[base] Clean up trigonometric core. * src/base/fttrrigon.c (ft_trig_pseudo_polarize): Align algorithm with `ft_trig_pseudo_rotate'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/ChangeLog b/ChangeLog
index a112602..a6198eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-12-19 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [base] Clean up trigonometric core.
+
+ * src/base/fttrrigon.c (ft_trig_pseudo_polarize): Align algorithm
+ with `ft_trig_pseudo_rotate'.
+
2012-12-18 Infinality <infinality@infinality.net>
[truetype] Minor performance enhancement.
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index a638f8c..4aeb565 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -260,9 +260,9 @@
static void
ft_trig_pseudo_polarize( FT_Vector* vec )
{
- FT_Fixed theta;
- FT_Fixed yi, i;
- FT_Fixed x, y;
+ FT_Angle theta;
+ FT_Int i;
+ FT_Fixed x, y, xtemp;
const FT_Fixed *arctanptr;
@@ -283,41 +283,38 @@
arctanptr = ft_trig_arctan_table;
- if ( y < 0 )
+ if ( y > 0 )
{
- /* Rotate positive */
- yi = y + ( x << 1 );
- x = x - ( y << 1 );
- y = yi;
- theta -= *arctanptr++; /* Subtract angle */
+ xtemp = x + ( y << 1 );
+ y = y - ( x << 1 );
+ x = xtemp;
+ theta += *arctanptr++;
}
else
{
- /* Rotate negative */
- yi = y - ( x << 1 );
- x = x + ( y << 1 );
- y = yi;
- theta += *arctanptr++; /* Add angle */
+ xtemp = x - ( y << 1 );
+ y = y + ( x << 1 );
+ x = xtemp;
+ theta -= *arctanptr++;
}
+ /* Subsequent pseudorotations, with right shifts */
i = 0;
do
{
- if ( y < 0 )
+ if ( y > 0 )
{
- /* Rotate positive */
- yi = y + ( x >> i );
- x = x - ( y >> i );
- y = yi;
- theta -= *arctanptr++;
+ xtemp = x + ( y >> i );
+ y = y - ( x >> i );
+ x = xtemp;
+ theta += *arctanptr++;
}
else
{
- /* Rotate negative */
- yi = y - ( x >> i );
- x = x + ( y >> i );
- y = yi;
- theta += *arctanptr++;
+ xtemp = x - ( y >> i );
+ y = y + ( x >> i );
+ x = xtemp;
+ theta -= *arctanptr++;
}
} while ( ++i < FT_TRIG_MAX_ITERS );