[gegl] buffer: add gegl_buffer_matrix2_is_identity()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: add gegl_buffer_matrix2_is_identity()
- Date: Thu, 15 Nov 2018 20:15:10 +0000 (UTC)
commit 6a940eddd37175664b9679295a652449ff5068af
Author: Ell <ell_se yahoo com>
Date: Thu Nov 15 14:29:29 2018 -0500
buffer: add gegl_buffer_matrix2_is_identity()
... which checks if a GeglBufferMatrix2 is the identity.
gegl/buffer/gegl-buffer-matrix2.c | 8 +++++++-
gegl/buffer/gegl-buffer-matrix2.h | 14 ++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-matrix2.c b/gegl/buffer/gegl-buffer-matrix2.c
index 0842e9781..20b0e168c 100644
--- a/gegl/buffer/gegl-buffer-matrix2.c
+++ b/gegl/buffer/gegl-buffer-matrix2.c
@@ -20,6 +20,13 @@
#include "gegl-buffer-matrix2.h"
+gboolean
+gegl_buffer_matrix2_is_identity (GeglBufferMatrix2 *matrix)
+{
+ return matrix->coeff[0][0] == 1.0 && matrix->coeff[0][1] == 0.0 &&
+ matrix->coeff[1][0] == 0.0 && matrix->coeff[1][1] == 1.0;
+}
+
gboolean
gegl_buffer_matrix2_is_scale (GeglBufferMatrix2 *matrix)
{
@@ -32,4 +39,3 @@ gegl_buffer_matrix2_determinant (GeglBufferMatrix2 *matrix)
return matrix->coeff[0][0] * matrix->coeff[1][1] -
matrix->coeff[1][0] * matrix->coeff[0][1];
}
-
diff --git a/gegl/buffer/gegl-buffer-matrix2.h b/gegl/buffer/gegl-buffer-matrix2.h
index da99a6a2a..1454d3b33 100644
--- a/gegl/buffer/gegl-buffer-matrix2.h
+++ b/gegl/buffer/gegl-buffer-matrix2.h
@@ -32,6 +32,16 @@ typedef struct {
gdouble coeff[2][2];
} GeglBufferMatrix2;
+/*
+ * gegl_buffer_matrix2_is_identity:
+ * @matrix: a #GeglBufferMatrix2
+ *
+ * Check if a matrix is the identity matrix.
+ *
+ * Returns TRUE if the matrix is the identity matrix.
+ */
+gboolean gegl_buffer_matrix2_is_identity (GeglBufferMatrix2 *matrix);
+
/*
* gegl_buffer_matrix2_is_scale:
* @matrix: a #GeglBufferMatrix2
@@ -40,7 +50,7 @@ typedef struct {
*
* Returns TRUE if the matrix only does scaling.
*/
-gboolean gegl_buffer_matrix2_is_scale (GeglBufferMatrix2 *matrix);
+gboolean gegl_buffer_matrix2_is_scale (GeglBufferMatrix2 *matrix);
/*
* gegl_buffer_matrix2_determinant:
@@ -48,7 +58,7 @@ gboolean gegl_buffer_matrix2_is_scale (GeglBufferMatrix2 *matrix);
*
* Returns the determinant of @matrix.
*/
-gdouble gegl_buffer_matrix2_determinant (GeglBufferMatrix2 *matrix);
+gdouble gegl_buffer_matrix2_determinant (GeglBufferMatrix2 *matrix);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]