[gimp/gimp-2-10] libgimpmath: add gimp_matrix3_equal()



commit 54a95ab75b41e1dcec992d7970f9411d90009ed0
Author: Ell <ell_se yahoo com>
Date:   Wed Jan 15 23:40:09 2020 +0200

    libgimpmath: add gimp_matrix3_equal()
    
    ... which compares two matrices.

 devel-docs/libgimpmath/libgimpmath-sections.txt |  1 +
 libgimpmath/gimpmath.def                        |  1 +
 libgimpmath/gimpmatrix.c                        | 29 +++++++++++++++++++++++++
 libgimpmath/gimpmatrix.h                        |  3 +++
 4 files changed, 34 insertions(+)
---
diff --git a/devel-docs/libgimpmath/libgimpmath-sections.txt b/devel-docs/libgimpmath/libgimpmath-sections.txt
index 18ab16966a..b3e25bed5a 100644
--- a/devel-docs/libgimpmath/libgimpmath-sections.txt
+++ b/devel-docs/libgimpmath/libgimpmath-sections.txt
@@ -44,6 +44,7 @@ gimp_matrix3_is_identity
 gimp_matrix3_is_diagonal
 gimp_matrix3_is_affine
 gimp_matrix3_is_simple
+gimp_matrix3_equal
 gimp_matrix4_identity
 gimp_matrix4_mult
 gimp_matrix4_to_deg
diff --git a/libgimpmath/gimpmath.def b/libgimpmath/gimpmath.def
index adc557276b..98ea0a1beb 100644
--- a/libgimpmath/gimpmath.def
+++ b/libgimpmath/gimpmath.def
@@ -7,6 +7,7 @@ EXPORTS
        gimp_matrix2_transform_point
        gimp_matrix3_affine
        gimp_matrix3_determinant
+       gimp_matrix3_equal
        gimp_matrix3_get_type
        gimp_matrix3_identity
        gimp_matrix3_invert
diff --git a/libgimpmath/gimpmatrix.c b/libgimpmath/gimpmatrix.c
index 1cf6a6cce7..ebee3921d4 100644
--- a/libgimpmath/gimpmatrix.c
+++ b/libgimpmath/gimpmatrix.c
@@ -931,6 +931,35 @@ gimp_matrix3_is_simple (const GimpMatrix3 *matrix)
   return TRUE;
 }
 
+/**
+ * gimp_matrix3_equal:
+ * @matrix1: The first matrix
+ * @matrix2: The second matrix
+ *
+ * Checks if two matrices are equal.
+ *
+ * Returns: %TRUE the matrices are equal, %FALSE otherwise
+ *
+ * Since: 2.10.16
+ */
+gboolean
+gimp_matrix3_equal (const GimpMatrix3 *matrix1,
+                    const GimpMatrix3 *matrix2)
+{
+  gint i, j;
+
+  for (i = 0; i < 3; i++)
+    {
+      for (j = 0; j < 3; j++)
+        {
+          if (fabs (matrix1->coeff[i][j] - matrix2->coeff[i][j]) > EPSILON)
+            return FALSE;
+        }
+    }
+
+  return TRUE;
+}
+
 /**
  * gimp_matrix4_identity:
  * @matrix: A matrix.
diff --git a/libgimpmath/gimpmatrix.h b/libgimpmath/gimpmatrix.h
index 75fc908429..a71a218a94 100644
--- a/libgimpmath/gimpmatrix.h
+++ b/libgimpmath/gimpmatrix.h
@@ -120,6 +120,9 @@ gboolean      gimp_matrix3_is_diagonal     (const GimpMatrix3 *matrix);
 gboolean      gimp_matrix3_is_affine       (const GimpMatrix3 *matrix);
 gboolean      gimp_matrix3_is_simple       (const GimpMatrix3 *matrix);
 
+gboolean      gimp_matrix3_equal           (const GimpMatrix3 *matrix1,
+                                            const GimpMatrix3 *matrix2);
+
 void          gimp_matrix3_transform_point (const GimpMatrix3 *matrix,
                                             gdouble            x,
                                             gdouble            y,


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