From 6b9681c7d334c45f1abe7e865880cb28dee250b6 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 7 Jul 2003 18:36:00 +0000 Subject: [PATCH] added gimp_matrix2_mult(). 2003-07-07 Sven Neumann * libgimpmath/gimpmatrix.[ch]: added gimp_matrix2_mult(). --- ChangeLog | 4 ++ .../libgimpmath/libgimpmath-sections.txt | 1 + devel-docs/libgimpmath/tmpl/gimpmatrix.sgml | 9 +++ libgimpmath/gimpmatrix.c | 59 +++++++++++++------ libgimpmath/gimpmatrix.h | 4 +- 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index af27f1cdd1..d236cbd6ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-07-07 Sven Neumann + + * libgimpmath/gimpmatrix.[ch]: added gimp_matrix2_mult(). + 2003-07-07 Sven Neumann * libgimpbase/gimpbasetypes.h: include . diff --git a/devel-docs/libgimpmath/libgimpmath-sections.txt b/devel-docs/libgimpmath/libgimpmath-sections.txt index f1e2695e61..622025bc3c 100644 --- a/devel-docs/libgimpmath/libgimpmath-sections.txt +++ b/devel-docs/libgimpmath/libgimpmath-sections.txt @@ -23,6 +23,7 @@ GimpMatrix2 GimpMatrix3 GimpMatrix4 gimp_matrix2_identity +gimp_matrix2_mult gimp_matrix3_identity gimp_matrix3_transform_point gimp_matrix3_mult diff --git a/devel-docs/libgimpmath/tmpl/gimpmatrix.sgml b/devel-docs/libgimpmath/tmpl/gimpmatrix.sgml index 438a06b373..ca7785f43b 100644 --- a/devel-docs/libgimpmath/tmpl/gimpmatrix.sgml +++ b/devel-docs/libgimpmath/tmpl/gimpmatrix.sgml @@ -53,6 +53,15 @@ basic matrix manipulations and tests. @matrix: + + + + + +@matrix1: +@matrix2: + + diff --git a/libgimpmath/gimpmatrix.c b/libgimpmath/gimpmatrix.c index a4668fec8f..61d2c22f4d 100644 --- a/libgimpmath/gimpmatrix.c +++ b/libgimpmath/gimpmatrix.c @@ -29,6 +29,7 @@ #define EPSILON 1e-6 + /** * gimp_matrix2_identity: * @matrix: A matrix. @@ -44,6 +45,46 @@ gimp_matrix2_identity (GimpMatrix2 *matrix) *matrix = identity; } +/** + * gimp_matrix2_mult: + * @matrix1: The first input matrix. + * @matrix2: The second input matrix which will be overwritten by the result. + * + * Multiplies two matrices and puts the result into the second one. + */ +void +gimp_matrix2_mult (const GimpMatrix2 *matrix1, + GimpMatrix2 *matrix2) +{ + GimpMatrix2 tmp; + + tmp.coeff[0][0] = (matrix1->coeff[0][0] * matrix2->coeff[0][0] + + matrix1->coeff[0][1] * matrix2->coeff[1][0]); + tmp.coeff[0][1] = (matrix1->coeff[0][0] * matrix2->coeff[0][1] + + matrix1->coeff[0][1] * matrix2->coeff[1][1]); + tmp.coeff[1][0] = (matrix1->coeff[1][0] * matrix2->coeff[0][0] + + matrix1->coeff[1][1] * matrix2->coeff[1][0]); + tmp.coeff[1][1] = (matrix1->coeff[1][0] * matrix2->coeff[0][1] + + matrix1->coeff[1][1] * matrix2->coeff[1][1]); + + *matrix2 = tmp; +} + +/** + * gimp_matrix3_identity: + * @matrix: A matrix. + * + * Sets the matrix to the identity matrix. + */ +void +gimp_matrix3_identity (GimpMatrix3 *matrix) +{ + static const GimpMatrix3 identity = { { { 1.0, 0.0, 0.0 }, + { 0.0, 1.0, 0.0 }, + { 0.0, 0.0, 1.0 } } }; + + *matrix = identity; +} /** * gimp_matrix3_transform_point: @@ -82,7 +123,7 @@ gimp_matrix3_transform_point (const GimpMatrix3 *matrix, /** * gimp_matrix3_mult: * @matrix1: The first input matrix. - * @matrix2: The second input matrix which will be oeverwritten by the result. + * @matrix2: The second input matrix which will be overwritten by the result. * * Multiplies two matrices and puts the result into the second one. */ @@ -111,22 +152,6 @@ gimp_matrix3_mult (const GimpMatrix3 *matrix1, *matrix2 = tmp; } -/** - * gimp_matrix3_identity: - * @matrix: A matrix. - * - * Sets the matrix to the identity matrix. - */ -void -gimp_matrix3_identity (GimpMatrix3 *matrix) -{ - static const GimpMatrix3 identity = { { { 1.0, 0.0, 0.0 }, - { 0.0, 1.0, 0.0 }, - { 0.0, 0.0, 1.0 } } }; - - *matrix = identity; -} - /** * gimp_matrix3_translate: * @matrix: The matrix that is to be translated. diff --git a/libgimpmath/gimpmatrix.h b/libgimpmath/gimpmatrix.h index 9f83b5dd08..6c14a97b9f 100644 --- a/libgimpmath/gimpmatrix.h +++ b/libgimpmath/gimpmatrix.h @@ -44,7 +44,10 @@ struct _GimpMatrix4 void gimp_matrix2_identity (GimpMatrix2 *matrix); +void gimp_matrix2_mult (const GimpMatrix2 *matrix1, + GimpMatrix2 *matrix2); +void gimp_matrix3_identity (GimpMatrix3 *matrix); void gimp_matrix3_transform_point (const GimpMatrix3 *matrix, gdouble x, gdouble y, @@ -52,7 +55,6 @@ void gimp_matrix3_transform_point (const GimpMatrix3 *matrix, gdouble *newy); void gimp_matrix3_mult (const GimpMatrix3 *matrix1, GimpMatrix3 *matrix2); -void gimp_matrix3_identity (GimpMatrix3 *matrix); void gimp_matrix3_translate (GimpMatrix3 *matrix, gdouble x, gdouble y);