[gimp] Bug 756775 - UnifiedTransformTool: nan value in handle geometry computation



commit 127b3de54abfe001a882dc6a08636478d2cfbc3a
Author: Thomas Manni <thomas manni free fr>
Date:   Tue Nov 24 10:31:47 2015 +0100

    Bug 756775 - UnifiedTransformTool: nan value in handle geometry computation
    
    Do not compute angle between 2 vectors if at least one of them is a null vector.
    Return 0.0 instead.

 app/tools/gimpunifiedtransformtool.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index 7338ba2..5ed937a 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -148,6 +148,12 @@ transform_is_convex (GimpVector2 *pos)
                                            pos[3].x, pos[3].y);
 }
 
+static inline gboolean
+vectorisnull (GimpVector2 v)
+{
+  return ((v.x == 0.0) && (v.y == 0.0));
+}
+
 static inline gdouble
 dotprod (GimpVector2 a,
          GimpVector2 b)
@@ -210,7 +216,12 @@ calcangle (GimpVector2 a,
            GimpVector2 b)
 {
   gdouble angle, angle2;
-  gdouble length = norm (a) * norm (b);
+  gdouble length;
+
+  if (vectorisnull (a) || vectorisnull (b))
+    return 0.0;
+
+  length = norm (a) * norm (b);
 
   angle = acos (dotprod (a, b)/length);
   angle2 = b.y;


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