From 1fc776b5f14e2be6fa3d6573f5cd3fb88a7ae468 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Thu, 28 Jun 2018 21:42:26 -0400 Subject: * src/base/fttrigon.c (FT_Tan): Improve accuracy. (FT_Vector_Rotate): Simplify. --- ChangeLog | 5 +++++ src/base/fttrigon.c | 16 ++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2dc6d298b..e23cc967a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-06-28 Alexei Podtelezhnikov + + * src/base/fttrigon.c (FT_Tan): Improve accuracy. + (FT_Vector_Rotate): Simplify. + 2018-06-28 Alexei Podtelezhnikov * src/base/ftobjs.c (FT_Set_Charmap): Robustify. diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c index 6a10492b2..d375bd730 100644 --- a/src/base/fttrigon.c +++ b/src/base/fttrigon.c @@ -325,10 +325,10 @@ FT_EXPORT_DEF( FT_Fixed ) FT_Tan( FT_Angle angle ) { - FT_Vector v; + FT_Vector v = { 1 << 24, 0 }; - FT_Vector_Unit( &v, angle ); + ft_trig_pseudo_rotate( &v, angle ); return FT_DivFix( v.y, v.x ); } @@ -372,14 +372,6 @@ } - /* these macros return 0 for positive numbers, - and -1 for negative ones */ -#define FT_SIGN_LONG( x ) ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) ) -#define FT_SIGN_INT( x ) ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) ) -#define FT_SIGN_INT32( x ) ( (x) >> 31 ) -#define FT_SIGN_INT16( x ) ( (x) >> 15 ) - - /* documentation is in fttrigon.h */ FT_EXPORT_DEF( void ) @@ -408,8 +400,8 @@ FT_Int32 half = (FT_Int32)1L << ( shift - 1 ); - vec->x = ( v.x + half + FT_SIGN_LONG( v.x ) ) >> shift; - vec->y = ( v.y + half + FT_SIGN_LONG( v.y ) ) >> shift; + vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift; + vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift; } else { -- cgit v1.2.1