[gegl] matrix: add gegl_matrix3_is_affine()



commit fa03134a45614406eed8c828a7e9ba62772e8a1b
Author: Ell <ell_se yahoo com>
Date:   Fri Feb 22 02:57:00 2019 -0500

    matrix: add gegl_matrix3_is_affine()
    
    ... move from GeglTransformCore.

 gegl/gegl-matrix.c                    |  8 ++++++++
 gegl/gegl-matrix.h                    | 10 ++++++++++
 operations/transform/transform-core.c | 13 -------------
 3 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/gegl/gegl-matrix.c b/gegl/gegl-matrix.c
index adf52f21e..83da9f872 100644
--- a/gegl/gegl-matrix.c
+++ b/gegl/gegl-matrix.c
@@ -111,6 +111,14 @@ gegl_matrix3_is_translate (GeglMatrix3 *matrix)
   return gegl_matrix3_is_identity (&copy);
 }
 
+gboolean
+gegl_matrix3_is_affine (GeglMatrix3 *matrix)
+{
+  return fabs (matrix->coeff[2][0])       <= EPSILON &&
+         fabs (matrix->coeff[2][1])       <= EPSILON &&
+         fabs (matrix->coeff[2][2] - 1.0) <= EPSILON;
+}
+
 void
 gegl_matrix3_copy_into (GeglMatrix3 *dst,
                         GeglMatrix3 *src)
diff --git a/gegl/gegl-matrix.h b/gegl/gegl-matrix.h
index 53b06f7ba..92d279b02 100644
--- a/gegl/gegl-matrix.h
+++ b/gegl/gegl-matrix.h
@@ -106,6 +106,16 @@ gboolean   gegl_matrix3_is_scale        (GeglMatrix3 *matrix);
  */
 gboolean   gegl_matrix3_is_translate    (GeglMatrix3 *matrix);
 
+/**
+ * gegl_matrix3_is_affine:
+ * @matrix: a #GeglMatrix3
+ *
+ * Check if a matrix only does an affine transformation.
+ *
+ * Returns TRUE if the matrix only does an affine transformation.
+ */
+gboolean   gegl_matrix3_is_affine       (GeglMatrix3 *matrix);
+
 /**
  * gegl_matrix3_copy_into:
  * @dst: a #GeglMatrix3
diff --git a/operations/transform/transform-core.c b/operations/transform/transform-core.c
index 7e0c60319..8d9c75411 100644
--- a/operations/transform/transform-core.c
+++ b/operations/transform/transform-core.c
@@ -98,7 +98,6 @@ static GeglNode     *gegl_transform_detect                       (GeglOperation
                                                                   gint                  x,
                                                                   gint                  y);
 
-static gboolean      gegl_matrix3_is_affine                      (GeglMatrix3          *matrix);
 static gboolean      gegl_transform_matrix3_allow_fast_translate (GeglMatrix3          *matrix);
 static void          gegl_transform_create_composite_matrix      (OpTransform          *transform,
                                                                   GeglMatrix3          *matrix);
@@ -1557,18 +1556,6 @@ static inline gboolean is_zero (const gdouble f)
           GEGL_TRANSFORM_CORE_EPSILON*GEGL_TRANSFORM_CORE_EPSILON);
 }
 
-static inline gboolean is_one (const gdouble f)
-{
-  return (is_zero (f-(gdouble) 1.0));
-}
-
-static gboolean gegl_matrix3_is_affine (GeglMatrix3 *matrix)
-{
-  return (is_zero (matrix->coeff [2][0]) &&
-          is_zero (matrix->coeff [2][1]) &&
-          is_one  (matrix->coeff [2][2]));
-}
-
 static gboolean
 gegl_transform_matrix3_allow_fast_translate (GeglMatrix3 *matrix)
 {


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