![]() |
![]() |
![]() |
GIMP Math Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
GimpMatrix2; GimpMatrix3; 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_mult (const GimpMatrix3 *matrix1, GimpMatrix3 *matrix2); void gimp_matrix3_translate (GimpMatrix3 *matrix, gdouble x, gdouble y); void gimp_matrix3_scale (GimpMatrix3 *matrix, gdouble x, gdouble y); void gimp_matrix3_rotate (GimpMatrix3 *matrix, gdouble theta); void gimp_matrix3_xshear (GimpMatrix3 *matrix, gdouble amount); void gimp_matrix3_yshear (GimpMatrix3 *matrix, gdouble amount); void gimp_matrix3_affine (GimpMatrix3 *matrix, gdouble a, gdouble b, gdouble c, gdouble d, gdouble e, gdouble f); void gimp_matrix3_transform_point (const GimpMatrix3 *matrix, gdouble x, gdouble y, gdouble *newx, gdouble *newy); gdouble gimp_matrix3_determinant (const GimpMatrix3 *matrix); void gimp_matrix3_invert (GimpMatrix3 *matrix); gboolean gimp_matrix3_is_identity (const GimpMatrix3 *matrix); gboolean gimp_matrix3_is_diagonal (const GimpMatrix3 *matrix); gboolean gimp_matrix3_is_affine (const GimpMatrix3 *matrix); gboolean gimp_matrix3_is_simple (const GimpMatrix3 *matrix); void gimp_matrix4_to_deg (const GimpMatrix4 *matrix, gdouble *a, gdouble *b, gdouble *c); #define GIMP_TYPE_MATRIX2 #define GIMP_TYPE_PARAM_MATRIX2 #define GIMP_IS_PARAM_SPEC_MATRIX2 (pspec) GParamSpec * gimp_param_spec_matrix2 (const gchar *name, const gchar *nick, const gchar *blurb, const GimpMatrix2 *default_value, GParamFlags flags); #define GIMP_VALUE_HOLDS_MATRIX2 (value)
When doing image manipulation you will often need 3x3 transformation matrices that define translation, rotation, scaling, shearing and arbitrary perspective transformations using a 3x3 matrix. Here you'll find a set of utility functions to set up those matrices and to perform basic matrix manipulations and tests.
Each matrix class has a 2 dimensional gdouble coeff member. The element for row r and column c of the matrix is coeff[r][c].
void gimp_matrix2_identity (GimpMatrix2 *matrix);
Sets the matrix to the identity matrix.
|
A matrix. |
void gimp_matrix2_mult (const GimpMatrix2 *matrix1, GimpMatrix2 *matrix2);
Multiplies two matrices and puts the result into the second one.
|
The first input matrix. |
|
The second input matrix which will be overwritten by the result. |
void gimp_matrix3_identity (GimpMatrix3 *matrix);
Sets the matrix to the identity matrix.
|
A matrix. |
void gimp_matrix3_mult (const GimpMatrix3 *matrix1, GimpMatrix3 *matrix2);
Multiplies two matrices and puts the result into the second one.
|
The first input matrix. |
|
The second input matrix which will be overwritten by the result. |
void gimp_matrix3_translate (GimpMatrix3 *matrix, gdouble x, gdouble y);
Translates the matrix by x and y.
|
The matrix that is to be translated. |
|
Translation in X direction. |
|
Translation in Y direction. |
void gimp_matrix3_scale (GimpMatrix3 *matrix, gdouble x, gdouble y);
Scales the matrix by x and y
|
The matrix that is to be scaled. |
|
X scale factor. |
|
Y scale factor. |
void gimp_matrix3_rotate (GimpMatrix3 *matrix, gdouble theta);
Rotates the matrix by theta degrees.
|
The matrix that is to be rotated. |
|
The angle of rotation (in radians). |
void gimp_matrix3_xshear (GimpMatrix3 *matrix, gdouble amount);
Shears the matrix in the X direction.
|
The matrix that is to be sheared. |
|
X shear amount. |
void gimp_matrix3_yshear (GimpMatrix3 *matrix, gdouble amount);
Shears the matrix in the Y direction.
|
The matrix that is to be sheared. |
|
Y shear amount. |
void gimp_matrix3_affine (GimpMatrix3 *matrix, gdouble a, gdouble b, gdouble c, gdouble d, gdouble e, gdouble f);
Applies the affine transformation given by six values to matrix
.
The six values form define an affine transformation matrix as
illustrated below:
( a c e ) ( b d f ) ( 0 0 1 )
|
The input matrix. |
|
|
|
|
|
|
|
|
|
|
|
void gimp_matrix3_transform_point (const GimpMatrix3 *matrix, gdouble x, gdouble y, gdouble *newx, gdouble *newy);
Transforms a point in 2D as specified by the transformation matrix.
|
The transformation matrix. |
|
The source X coordinate. |
|
The source Y coordinate. |
|
The transformed X coordinate. |
|
The transformed Y coordinate. |
gdouble gimp_matrix3_determinant (const GimpMatrix3 *matrix);
Calculates the determinant of the given matrix.
|
The input matrix. |
Returns : |
The determinant. |
void gimp_matrix3_invert (GimpMatrix3 *matrix);
Inverts the given matrix.
|
The matrix that is to be inverted. |
gboolean gimp_matrix3_is_identity (const GimpMatrix3 *matrix);
Checks if the given matrix is the identity matrix.
gboolean gimp_matrix3_is_diagonal (const GimpMatrix3 *matrix);
Checks if the given matrix is diagonal.
gboolean gimp_matrix3_is_affine (const GimpMatrix3 *matrix);
Checks if the given matrix defines an affine transformation.
|
The matrix that is to be tested. |
Returns : |
TRUE if the matrix defines an affine transformation,
FALSE otherwise
|
Since GIMP 2.4
gboolean gimp_matrix3_is_simple (const GimpMatrix3 *matrix);
Checks if we'll need to interpolate when applying this matrix as a transformation.
void gimp_matrix4_to_deg (const GimpMatrix4 *matrix, gdouble *a, gdouble *b, gdouble *c);
|
|
|
|
|
|
|
#define GIMP_IS_PARAM_SPEC_MATRIX2(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_MATRIX2))
|
GParamSpec * gimp_param_spec_matrix2 (const gchar *name, const gchar *nick, const gchar *blurb, const GimpMatrix2 *default_value, GParamFlags flags);
Creates a param spec to hold a GimpMatrix2 value.
See g_param_spec_internal()
for more information.
|
Canonical name of the param |
|
Nickname of the param |
|
Brief desciption of param. |
|
Value to use if none is assigned. |
|
a combination of GParamFlags |
Returns : |
a newly allocated GParamSpec instance |
Since GIMP 2.4