diff options
Diffstat (limited to '')
-rw-r--r-- | src/others/mimesh/libg3d-0.0.8/include/g3d/matrix.h | 189 |
1 files changed, 189 insertions, 0 deletions
diff --git a/src/others/mimesh/libg3d-0.0.8/include/g3d/matrix.h b/src/others/mimesh/libg3d-0.0.8/include/g3d/matrix.h new file mode 100644 index 0000000..df4a7a2 --- /dev/null +++ b/src/others/mimesh/libg3d-0.0.8/include/g3d/matrix.h | |||
@@ -0,0 +1,189 @@ | |||
1 | /* $Id$ */ | ||
2 | |||
3 | /* | ||
4 | libg3d - 3D object loading library | ||
5 | |||
6 | Copyright (C) 2005-2009 Markus Dahms <mad@automagically.de> | ||
7 | |||
8 | This library is free software; you can redistribute it and/or | ||
9 | modify it under the terms of the GNU Lesser General Public | ||
10 | License as published by the Free Software Foundation; either | ||
11 | version 2.1 of the License, or (at your option) any later version. | ||
12 | |||
13 | This library is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | Lesser General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU Lesser General Public | ||
19 | License along with this library; if not, write to the Free Software | ||
20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef _G3D_MATRIX_H | ||
24 | #define _G3D_MATRIX_H | ||
25 | |||
26 | #include <g3d/types.h> | ||
27 | |||
28 | #ifdef __cplusplus | ||
29 | extern "C" { | ||
30 | #endif /* ifdef __cplusplus */ | ||
31 | |||
32 | /** | ||
33 | * SECTION:matrix | ||
34 | * @short_description: Matrix manipulation and calculation | ||
35 | * @include: g3d/matrix.h | ||
36 | * | ||
37 | * Matrices in libg3d have the following layout: | ||
38 | * | ||
39 | * G3DMatrix matrix[16]: | ||
40 | * | ||
41 | * matrix[col * 4 + row] = f; | ||
42 | */ | ||
43 | |||
44 | /** | ||
45 | * g3d_matrix_identity: | ||
46 | * @matrix: 4x4 matrix (float[16]) | ||
47 | * | ||
48 | * Sets the given matrix to the identity matrix. | ||
49 | * | ||
50 | * Returns: TRUE on success, FALSE else | ||
51 | */ | ||
52 | EAPI | ||
53 | gboolean g3d_matrix_identity(G3DMatrix *matrix); | ||
54 | |||
55 | /** | ||
56 | * g3d_matrix_new: | ||
57 | * | ||
58 | * Create a new matrix. It is also set to the identity matrix. | ||
59 | * | ||
60 | * Returns: the new matrix | ||
61 | */ | ||
62 | _G3D_STATIC_INLINE G3DMatrix *g3d_matrix_new(void) { | ||
63 | G3DMatrix *matrix = g_new(G3DMatrix, 16); | ||
64 | g3d_matrix_identity(matrix); | ||
65 | return matrix; | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * g3d_matrix_free: | ||
70 | * @matrix: the matrix to free | ||
71 | * | ||
72 | * Free the memory allocated by a matrix. | ||
73 | */ | ||
74 | _G3D_STATIC_INLINE void g3d_matrix_free(G3DMatrix *matrix) { | ||
75 | g_free(matrix); | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * g3d_matrix_multiply: | ||
80 | * @m1: first matrix | ||
81 | * @m2: second matrix | ||
82 | * @rm: resulting matrix | ||
83 | * | ||
84 | * Multiplies the matrixes. | ||
85 | * | ||
86 | * Returns: TRUE on success, FALSE else | ||
87 | */ | ||
88 | EAPI | ||
89 | gboolean g3d_matrix_multiply(G3DMatrix *m1, G3DMatrix *m2, G3DMatrix *rm); | ||
90 | |||
91 | /** | ||
92 | * g3d_matrix_translate: | ||
93 | * @x: x translation | ||
94 | * @y: y translation | ||
95 | * @z: z translation | ||
96 | * @rm: resulting matrix | ||
97 | * | ||
98 | * Adds a translation to the the matrix. | ||
99 | * | ||
100 | * Returns: TRUE on success, FALSE else | ||
101 | */ | ||
102 | EAPI | ||
103 | gboolean g3d_matrix_translate(G3DFloat x, G3DFloat y, G3DFloat z, | ||
104 | G3DMatrix *rm); | ||
105 | |||
106 | /** | ||
107 | * g3d_matrix_rotate: | ||
108 | * @angle: rotation angle | ||
109 | * @ax: x component of rotation axis | ||
110 | * @ay: y component of rotation axis | ||
111 | * @az: z component of rotation axis | ||
112 | * @rm: resulting matrix | ||
113 | * | ||
114 | * Adds a rotation to the matrix. | ||
115 | * | ||
116 | * Returns: TRUE on success, FALSE else | ||
117 | */ | ||
118 | EAPI | ||
119 | gboolean g3d_matrix_rotate(G3DFloat angle, G3DFloat ax, G3DFloat ay, | ||
120 | G3DFloat az, G3DMatrix *rm); | ||
121 | |||
122 | /** | ||
123 | * g3d_matrix_rotate_xyz | ||
124 | * @rx: rotation around x axis | ||
125 | * @ry: rotation around y axis | ||
126 | * @rz: rotation around z axis | ||
127 | * @rm: resulting matrix | ||
128 | * | ||
129 | * Adds a rotation around the 3 coordinate system axes to the matrix. | ||
130 | * | ||
131 | * Returns: TRUE on success, FALSE else | ||
132 | */ | ||
133 | EAPI | ||
134 | gboolean g3d_matrix_rotate_xyz(G3DFloat rx, G3DFloat ry, G3DFloat rz, | ||
135 | G3DMatrix *rm); | ||
136 | |||
137 | /** | ||
138 | * g3d_matrix_scale: | ||
139 | * @x: x factor | ||
140 | * @y: y factor | ||
141 | * @z: z factor | ||
142 | * @rm: resulting matrix | ||
143 | * | ||
144 | * Adds a scaling to the matrix. | ||
145 | * | ||
146 | * Returns: TRUE on success, FALSE else | ||
147 | */ | ||
148 | EAPI | ||
149 | gboolean g3d_matrix_scale(G3DFloat x, G3DFloat y, G3DFloat z, G3DMatrix *rm); | ||
150 | |||
151 | /** | ||
152 | * g3d_matrix_transpose: | ||
153 | * @matrix: the matrix | ||
154 | * | ||
155 | * Transposes the matrix. | ||
156 | * | ||
157 | * Returns: TRUE on success, FALSE else | ||
158 | */ | ||
159 | EAPI | ||
160 | gboolean g3d_matrix_transpose(G3DMatrix *matrix); | ||
161 | |||
162 | /** | ||
163 | * g3d_matrix_determinant: | ||
164 | * @matrix: the matrix | ||
165 | * | ||
166 | * Calculate the determinant of the matrix (FIXME: not verified). | ||
167 | * | ||
168 | * Returns: the determinant. | ||
169 | */ | ||
170 | EAPI | ||
171 | G3DFloat g3d_matrix_determinant(G3DMatrix *matrix); | ||
172 | |||
173 | /** | ||
174 | * g3d_matrix_dump: | ||
175 | * @matrix: the matrix | ||
176 | * | ||
177 | * If debugging is enabled, this function dump the matrix to stderr. | ||
178 | * | ||
179 | * Returns: TRUE if matrix is dumped, FALSE else | ||
180 | */ | ||
181 | EAPI | ||
182 | gboolean g3d_matrix_dump(G3DMatrix *matrix); | ||
183 | |||
184 | #ifdef __cplusplus | ||
185 | } | ||
186 | #endif /* ifdef __cplusplus */ | ||
187 | |||
188 | #endif /* _G3D_MATRIX_H */ | ||
189 | |||