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.
This commit is contained in:
Thomas Manni 2015-11-24 10:31:47 +01:00
parent bc980cd73a
commit 127b3de54a
1 changed files with 12 additions and 1 deletions

View File

@ -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;