• Home
  • Raw
  • Download

Lines Matching refs:M

116 static inline void mat4x4_identity(mat4x4 M) {  in mat4x4_identity()  argument
120 M[i][j] = i == j ? 1.f : 0.f; in mat4x4_identity()
122 static inline void mat4x4_dup(mat4x4 M, mat4x4 N) { in mat4x4_dup() argument
126 M[i][j] = N[i][j]; in mat4x4_dup()
128 static inline void mat4x4_row(vec4 r, mat4x4 M, int i) { in mat4x4_row() argument
131 r[k] = M[k][i]; in mat4x4_row()
133 static inline void mat4x4_col(vec4 r, mat4x4 M, int i) { in mat4x4_col() argument
136 r[k] = M[i][k]; in mat4x4_col()
138 static inline void mat4x4_transpose(mat4x4 M, mat4x4 N) { in mat4x4_transpose() argument
142 M[i][j] = N[j][i]; in mat4x4_transpose()
144 static inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) { in mat4x4_add() argument
147 vec4_add(M[i], a[i], b[i]); in mat4x4_add()
149 static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) { in mat4x4_sub() argument
152 vec4_sub(M[i], a[i], b[i]); in mat4x4_sub()
154 static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k) { in mat4x4_scale() argument
157 vec4_scale(M[i], a[i], k); in mat4x4_scale()
159 static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, in mat4x4_scale_aniso() argument
162 vec4_scale(M[0], a[0], x); in mat4x4_scale_aniso()
163 vec4_scale(M[1], a[1], y); in mat4x4_scale_aniso()
164 vec4_scale(M[2], a[2], z); in mat4x4_scale_aniso()
166 M[3][i] = a[3][i]; in mat4x4_scale_aniso()
169 static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) { in mat4x4_mul() argument
173 M[c][r] = 0.f; in mat4x4_mul()
175 M[c][r] += a[k][r] * b[c][k]; in mat4x4_mul()
178 static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) { in mat4x4_mul_vec4() argument
183 r[j] += M[i][j] * v[i]; in mat4x4_mul_vec4()
192 static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, in mat4x4_translate_in_place() argument
198 mat4x4_row(r, M, i); in mat4x4_translate_in_place()
199 M[3][i] += vec4_mul_inner(r, t); in mat4x4_translate_in_place()
202 static inline void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b) { in mat4x4_from_vec3_mul_outer() argument
206 M[i][j] = i < 3 && j < 3 ? a[i] * b[j] : 0.f; in mat4x4_from_vec3_mul_outer()
208 static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, in mat4x4_rotate() argument
235 mat4x4_mul(R, M, T); in mat4x4_rotate()
237 mat4x4_dup(R, M); in mat4x4_rotate()
240 static inline void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle) { in mat4x4_rotate_X() argument
247 mat4x4_mul(Q, M, R); in mat4x4_rotate_X()
249 static inline void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) { in mat4x4_rotate_Y() argument
256 mat4x4_mul(Q, M, R); in mat4x4_rotate_Y()
258 static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) { in mat4x4_rotate_Z() argument
265 mat4x4_mul(Q, M, R); in mat4x4_rotate_Z()
267 static inline void mat4x4_invert(mat4x4 T, mat4x4 M) { in mat4x4_invert() argument
270 s[0] = M[0][0] * M[1][1] - M[1][0] * M[0][1]; in mat4x4_invert()
271 s[1] = M[0][0] * M[1][2] - M[1][0] * M[0][2]; in mat4x4_invert()
272 s[2] = M[0][0] * M[1][3] - M[1][0] * M[0][3]; in mat4x4_invert()
273 s[3] = M[0][1] * M[1][2] - M[1][1] * M[0][2]; in mat4x4_invert()
274 s[4] = M[0][1] * M[1][3] - M[1][1] * M[0][3]; in mat4x4_invert()
275 s[5] = M[0][2] * M[1][3] - M[1][2] * M[0][3]; in mat4x4_invert()
277 c[0] = M[2][0] * M[3][1] - M[3][0] * M[2][1]; in mat4x4_invert()
278 c[1] = M[2][0] * M[3][2] - M[3][0] * M[2][2]; in mat4x4_invert()
279 c[2] = M[2][0] * M[3][3] - M[3][0] * M[2][3]; in mat4x4_invert()
280 c[3] = M[2][1] * M[3][2] - M[3][1] * M[2][2]; in mat4x4_invert()
281 c[4] = M[2][1] * M[3][3] - M[3][1] * M[2][3]; in mat4x4_invert()
282 c[5] = M[2][2] * M[3][3] - M[3][2] * M[2][3]; in mat4x4_invert()
288 T[0][0] = (M[1][1] * c[5] - M[1][2] * c[4] + M[1][3] * c[3]) * idet; in mat4x4_invert()
289 T[0][1] = (-M[0][1] * c[5] + M[0][2] * c[4] - M[0][3] * c[3]) * idet; in mat4x4_invert()
290 T[0][2] = (M[3][1] * s[5] - M[3][2] * s[4] + M[3][3] * s[3]) * idet; in mat4x4_invert()
291 T[0][3] = (-M[2][1] * s[5] + M[2][2] * s[4] - M[2][3] * s[3]) * idet; in mat4x4_invert()
293 T[1][0] = (-M[1][0] * c[5] + M[1][2] * c[2] - M[1][3] * c[1]) * idet; in mat4x4_invert()
294 T[1][1] = (M[0][0] * c[5] - M[0][2] * c[2] + M[0][3] * c[1]) * idet; in mat4x4_invert()
295 T[1][2] = (-M[3][0] * s[5] + M[3][2] * s[2] - M[3][3] * s[1]) * idet; in mat4x4_invert()
296 T[1][3] = (M[2][0] * s[5] - M[2][2] * s[2] + M[2][3] * s[1]) * idet; in mat4x4_invert()
298 T[2][0] = (M[1][0] * c[4] - M[1][1] * c[2] + M[1][3] * c[0]) * idet; in mat4x4_invert()
299 T[2][1] = (-M[0][0] * c[4] + M[0][1] * c[2] - M[0][3] * c[0]) * idet; in mat4x4_invert()
300 T[2][2] = (M[3][0] * s[4] - M[3][1] * s[2] + M[3][3] * s[0]) * idet; in mat4x4_invert()
301 T[2][3] = (-M[2][0] * s[4] + M[2][1] * s[2] - M[2][3] * s[0]) * idet; in mat4x4_invert()
303 T[3][0] = (-M[1][0] * c[3] + M[1][1] * c[1] - M[1][2] * c[0]) * idet; in mat4x4_invert()
304 T[3][1] = (M[0][0] * c[3] - M[0][1] * c[1] + M[0][2] * c[0]) * idet; in mat4x4_invert()
305 T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet; in mat4x4_invert()
306 T[3][3] = (M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet; in mat4x4_invert()
308 static inline void mat4x4_orthonormalize(mat4x4 R, mat4x4 M) { in mat4x4_orthonormalize() argument
309 mat4x4_dup(R, M); in mat4x4_orthonormalize()
331 static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, in mat4x4_frustum() argument
333 M[0][0] = 2.f * n / (r - l); in mat4x4_frustum()
334 M[0][1] = M[0][2] = M[0][3] = 0.f; in mat4x4_frustum()
336 M[1][1] = 2.f * n / (t - b); in mat4x4_frustum()
337 M[1][0] = M[1][2] = M[1][3] = 0.f; in mat4x4_frustum()
339 M[2][0] = (r + l) / (r - l); in mat4x4_frustum()
340 M[2][1] = (t + b) / (t - b); in mat4x4_frustum()
341 M[2][2] = -(f + n) / (f - n); in mat4x4_frustum()
342 M[2][3] = -1.f; in mat4x4_frustum()
344 M[3][2] = -2.f * (f * n) / (f - n); in mat4x4_frustum()
345 M[3][0] = M[3][1] = M[3][3] = 0.f; in mat4x4_frustum()
347 static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, in mat4x4_ortho() argument
349 M[0][0] = 2.f / (r - l); in mat4x4_ortho()
350 M[0][1] = M[0][2] = M[0][3] = 0.f; in mat4x4_ortho()
352 M[1][1] = 2.f / (t - b); in mat4x4_ortho()
353 M[1][0] = M[1][2] = M[1][3] = 0.f; in mat4x4_ortho()
355 M[2][2] = -2.f / (f - n); in mat4x4_ortho()
356 M[2][0] = M[2][1] = M[2][3] = 0.f; in mat4x4_ortho()
358 M[3][0] = -(r + l) / (r - l); in mat4x4_ortho()
359 M[3][1] = -(t + b) / (t - b); in mat4x4_ortho()
360 M[3][2] = -(f + n) / (f - n); in mat4x4_ortho()
361 M[3][3] = 1.f; in mat4x4_ortho()
481 static inline void mat4x4_from_quat(mat4x4 M, quat q) { in mat4x4_from_quat() argument
491 M[0][0] = a2 + b2 - c2 - d2; in mat4x4_from_quat()
492 M[0][1] = 2.f * (b * c + a * d); in mat4x4_from_quat()
493 M[0][2] = 2.f * (b * d - a * c); in mat4x4_from_quat()
494 M[0][3] = 0.f; in mat4x4_from_quat()
496 M[1][0] = 2 * (b * c - a * d); in mat4x4_from_quat()
497 M[1][1] = a2 - b2 + c2 - d2; in mat4x4_from_quat()
498 M[1][2] = 2.f * (c * d + a * b); in mat4x4_from_quat()
499 M[1][3] = 0.f; in mat4x4_from_quat()
501 M[2][0] = 2.f * (b * d + a * c); in mat4x4_from_quat()
502 M[2][1] = 2.f * (c * d - a * b); in mat4x4_from_quat()
503 M[2][2] = a2 - b2 - c2 + d2; in mat4x4_from_quat()
504 M[2][3] = 0.f; in mat4x4_from_quat()
506 M[3][0] = M[3][1] = M[3][2] = 0.f; in mat4x4_from_quat()
507 M[3][3] = 1.f; in mat4x4_from_quat()
510 static inline void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q) { in mat4x4o_mul_quat() argument
513 quat_mul_vec3(R[0], q, M[0]); in mat4x4o_mul_quat()
514 quat_mul_vec3(R[1], q, M[1]); in mat4x4o_mul_quat()
515 quat_mul_vec3(R[2], q, M[2]); in mat4x4o_mul_quat()
520 static inline void quat_from_mat4x4(quat q, mat4x4 M) { in quat_from_mat4x4() argument
528 float m = M[i][i]; in quat_from_mat4x4()
535 r = sqrtf(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]]); in quat_from_mat4x4()
544 q[1] = (M[p[0]][p[1]] - M[p[1]][p[0]]) / (2.f * r); in quat_from_mat4x4()
545 q[2] = (M[p[2]][p[0]] - M[p[0]][p[2]]) / (2.f * r); in quat_from_mat4x4()
546 q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]]) / (2.f * r); in quat_from_mat4x4()