added gimp_matrix2_mult().

2003-07-07  Sven Neumann  <sven@gimp.org>

	* libgimpmath/gimpmatrix.[ch]: added gimp_matrix2_mult().
This commit is contained in:
Sven Neumann 2003-07-07 18:36:00 +00:00 committed by Sven Neumann
parent 6f83a52571
commit 6b9681c7d3
5 changed files with 59 additions and 18 deletions

View File

@ -1,3 +1,7 @@
2003-07-07 Sven Neumann <sven@gimp.org>
* libgimpmath/gimpmatrix.[ch]: added gimp_matrix2_mult().
2003-07-07 Sven Neumann <sven@gimp.org>
* libgimpbase/gimpbasetypes.h: include <libgimpmath/gimpmathtypes.h>.

View File

@ -23,6 +23,7 @@ GimpMatrix2
GimpMatrix3
GimpMatrix4
gimp_matrix2_identity
gimp_matrix2_mult
gimp_matrix3_identity
gimp_matrix3_transform_point
gimp_matrix3_mult

View File

@ -53,6 +53,15 @@ basic matrix manipulations and tests.
@matrix:
<!-- ##### FUNCTION gimp_matrix2_mult ##### -->
<para>
</para>
@matrix1:
@matrix2:
<!-- ##### FUNCTION gimp_matrix3_identity ##### -->
<para>

View File

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

View File

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