summaryrefslogtreecommitdiff
path: root/gegl/gegl-matrix.h
blob: 76a1ee9535fc2bdacf8535978ba38237dc9c9dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#ifndef __GEGL_MATRIX_H__
#define __GEGL_MATRIX_H__


#include <glib.h>
#include <glib-object.h>

G_BEGIN_DECLS

/* Currenly only used internally.
 * Note: If making use of this in public API, add a boxed type for introspection
 */
typedef struct {
    gdouble coeff[2][2];
} GeglMatrix2;

/***
 * GeglMatrix3:
 *
 * #GeglMatrix3 is a 3x3 matrix for GEGL.
 * Matrixes are currently used by #GeglPath and the affine operations,
 * they might be used more centrally in the core of GEGL later.
 *
 */
typedef struct {
    gdouble coeff[3][3];
} GeglMatrix3;

#define GEGL_TYPE_MATRIX3               (gegl_matrix3_get_type ())
#define GEGL_VALUE_HOLDS_MATRIX3(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GEGL_TYPE_MATRIX3))

/**
 * gegl_matrix3_get_type:
 *
 * Returns: the #GType for GeglMatrix3 objects
 *
 **/
GType         gegl_matrix3_get_type     (void) G_GNUC_CONST;

/**
 * gegl_matrix3_new:
 *
 * Return: A newly allocated #GeglMatrix3
 */
GeglMatrix3 * gegl_matrix3_new (void);

/**
 * gegl_matrix3_identity:
 * @matrix: a #GeglMatrix
 *
 * Set the provided @matrix to the identity matrix.
 */
void       gegl_matrix3_identity        (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_equal:
 * @matrix1: a #GeglMatrix
 * @matrix2: a #GeglMatrix
 *
 * Check if two matrices are equal.
 *
 * Returns TRUE if the matrices are equal.
 */
gboolean   gegl_matrix3_equal           (GeglMatrix3 *matrix1,
                                         GeglMatrix3 *matrix2);

/**
 * gegl_matrix3_is_identity:
 * @matrix: a #GeglMatrix
 *
 * Check if a matrix is the identity matrix.
 *
 * Returns TRUE if the matrix is the identity matrix.
 */
gboolean   gegl_matrix3_is_identity     (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_is_scale:
 * @matrix: a #GeglMatrix
 *
 * Check if a matrix only does scaling.
 *
 * Returns TRUE if the matrix only does scaling.
 */
gboolean   gegl_matrix3_is_scale        (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_is_translate:
 * @matrix: a #GeglMatrix
 *
 * Check if a matrix only does translation.
 *
 * Returns TRUE if the matrix only does trasnlation.
 */
gboolean   gegl_matrix3_is_translate    (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_copy_into:
 * @dst: a #GeglMatrix
 * @src: a #GeglMatrix
 *
 * Copies the matrix in @src into @dst.
 */
void  gegl_matrix3_copy_into (GeglMatrix3 *dst,
                              GeglMatrix3 *src);

/**
 * gegl_matrix3_copy:
 * @matrix: a #GeglMatrix
 *
 * Returns a copy of @src.
 */
GeglMatrix3 *   gegl_matrix3_copy (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_determinant:
 * @matrix: a #GeglMatrix
 *
 * Returns the determinant for the matrix.
 */
gdouble    gegl_matrix3_determinant     (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_invert:
 * @matrix: a #GeglMatrix
 *
 * Inverts @matrix.
 */
void       gegl_matrix3_invert          (GeglMatrix3 *matrix);

/**
 * gegl_matrix3_multiply:
 * @left: a #GeglMatrix
 * @right: a #GeglMatrix
 * @product: a #GeglMatrix to store the result in.
 *
 * Multiples @product = @left · @right
 */
void       gegl_matrix3_multiply        (GeglMatrix3 *left,
                                         GeglMatrix3 *right,
                                         GeglMatrix3 *product);

/**
 * gegl_matrix3_originate:
 * @matrix: a #GeglMatrix
 * @x: x coordinate of new origin
 * @y: y coordinate of new origin.
 *
 * Hmm not quite sure what this does.
 *
 */
void       gegl_matrix3_originate       (GeglMatrix3 *matrix,
                                         gdouble     x,
                                         gdouble     y);


/**
 * gegl_matrix3_transform_point:
 * @matrix: a #GeglMatrix
 * @x: pointer to an x coordinate
 * @y: pointer to an y coordinate
 *
 * transforms the coordinates provided in @x and @y and changes to the
 * coordinates gotten when the transformed with the matrix.
 *
 */
void       gegl_matrix3_transform_point (GeglMatrix3 *matrix,
                                         gdouble    *x,
                                         gdouble    *y);

/**
 * gegl_matrix3_parse_string:
 * @matrix: a #GeglMatrix
 * @string: a string describing the matrix (right now a small subset of the
 * transform strings allowed by SVG)
 *
 * Parse a transofmation matrix from a string.
 */
void       gegl_matrix3_parse_string    (GeglMatrix3 *matrix,
                                         const gchar *string);
/**
 * gegl_matrix3_to_string:
 * @matrix: a #GeglMatrix
 *
 * Serialize a #GeglMatrix to a string.
 *
 * Returns a freshly allocated string representing that #GeglMatrix, the
 * returned string should be g_free()'d.
 *
 */
gchar *    gegl_matrix3_to_string       (GeglMatrix3 *matrix);

/***
 */

G_END_DECLS

#endif