Commit fb09a51f0f6b57b8110ae1ada81c48adc968b4c2

Werner Lemberg 2013-08-04T18:24:02

Add comments to `ft_corner_is_flat'.

diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 0ec0d78..c02daa4 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -945,11 +945,27 @@
     FT_Pos  d_in, d_out, d_corner;
 
 
+    /* We approximate the Euclidean metric (sqrt(x^2 + y^2)) with */
+    /* the Taxicab metric (x + y), which can be computed much     */
+    /* faster.  If one of the two vectors is much longer than the */
+    /* other one, the direction of the shorter vector doesn't     */
+    /* influence the result any more.                             */
+    /*                                                            */
+    /*                 corner                                     */
+    /*       x---------------------------x                        */
+    /*        \                      /                            */
+    /*         \                /                                 */
+    /*      in  \          /  out                                 */
+    /*           \    /                                           */
+    /*            o                                               */
+    /*              Point                                         */
+    /*                                                            */
+
     if ( ax < 0 )
       ax = -ax;
     if ( ay < 0 )
       ay = -ay;
-    d_in = ax + ay;
+    d_in = ax + ay;  /* d_in = || in || */
 
     ax = out_x;
     if ( ax < 0 )
@@ -957,7 +973,7 @@
     ay = out_y;
     if ( ay < 0 )
       ay = -ay;
-    d_out = ax + ay;
+    d_out = ax + ay;  /* d_out = || out || */
 
     ax = out_x + in_x;
     if ( ax < 0 )
@@ -965,7 +981,11 @@
     ay = out_y + in_y;
     if ( ay < 0 )
       ay = -ay;
-    d_corner = ax + ay;
+    d_corner = ax + ay;  /* d_corner = || in + out || */
+
+    /* now do a simple length comparison: */
+    /*                                    */
+    /*   d_in + d_out < 17/16 d_corner    */
 
     return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
   }