[dia] [matherr] Fix polybezier_bbox() for acos(-1)



commit 180766786b886249a45fc3e231d4416685c3c5fc
Author: Hans Breuer <hans breuer org>
Date:   Mon Oct 15 12:21:08 2012 +0200

    [matherr] Fix polybezier_bbox() for acos(-1)
    
    I've added some special handling years ago, but now it is
    adapted to not produce a matherr()

 lib/boundingbox.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/lib/boundingbox.c b/lib/boundingbox.c
index 88cbca0..eb71f35 100644
--- a/lib/boundingbox.c
+++ b/lib/boundingbox.c
@@ -496,14 +496,19 @@ polybezier_bbox(const BezPoint *pts, int numpoints,
       point_copy_add_scaled(&vxn,&vn,&vx,-1);
       point_normalize(&vxn);
 
-      co = point_dot(&vpx,&vxn);      
-      alpha = acos(-co); 
+      co = point_dot(&vpx,&vxn);
+      if (co >= 1.0)
+        alpha = 0.0;
+      else if (co <= -1.0)
+        alpha = M_PI;
+      else
+        alpha = acos(-co); 
       if (co > -0.9816) { /* 0.9816 = cos(11deg) */
         /* we have a pointy join. */
         real overshoot;
         Point vovs,pto;
 
-	if (finite(alpha))
+	if (alpha > 0.0 && alpha < M_PI)
 	  overshoot = extra->middle_trans / sin(alpha/2.0);
 	else /* prependicular? */
 	  overshoot = extra->middle_trans;
@@ -549,7 +554,3 @@ rectangle_bbox(const Rectangle *rin,
   rout->bottom = rin->bottom + extra->border_trans;
 }
 
-  
-/* TODO: text_bbox ? */  
-
-            



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]