added matrix code
[csgray] / src / matrix.h
1 #ifndef MATRIX_H_
2 #define MATRIX_H_
3
4 #include <stdio.h>
5
6 void mat4_identity(float *m);
7 void mat4_copy(float *dest, float *src);
8 void mat4_mul(float *dest, float *a, float *b);
9
10 void mat4_xform3(float *vdest, float *m, float *v);
11 void mat4_xform4(float *vdest, float *m, float *v);
12
13 float *mat4_row(float *m, int row);
14 float mat4_elem(float *m, int row, int col);
15
16 void mat4_upper3x3(float *m);
17
18 void mat4_transpose(float *m);
19 int mat4_inverse(float *m);
20
21 void mat4_translation(float *m, float x, float y, float z);
22 void mat4_rotation_x(float *m, float angle);
23 void mat4_rotation_y(float *m, float angle);
24 void mat4_rotation_z(float *m, float angle);
25 void mat4_rotation(float *m, float angle, float x, float y, float z);
26 void mat4_scaling(float *m, float sx, float sy, float sz);
27
28 void mat4_translate(float *m, float x, float y, float z);
29 void mat4_rotate_x(float *m, float angle);
30 void mat4_rotate_y(float *m, float angle);
31 void mat4_rotate_z(float *m, float angle);
32 void mat4_rotate(float *m, float angle, float x, float y, float z);
33 void mat4_scale(float *m, float sx, float sy, float sz);
34
35 void mat4_pre_translate(float *m, float x, float y, float z);
36 void mat4_pre_rotate_x(float *m, float angle);
37 void mat4_pre_rotate_y(float *m, float angle);
38 void mat4_pre_rotate_z(float *m, float angle);
39 void mat4_pre_rotate(float *m, float angle, float x, float y, float z);
40 void mat4_pre_scale(float *m, float sx, float sy, float sz);
41
42 void mat4_lookat(float *m, float x, float y, float z, float tx, float ty, float tz, float ux, float uy, float uz);
43 void mat4_inv_lookat(float *m, float x, float y, float z, float tx, float ty, float tz, float ux, float uy, float uz);
44 void mat4_ortho(float *m, float left, float right, float bottom, float top, float znear, float zfar);
45 void mat4_frustum(float *m, float *left, float right, float bottom, float top, float znear, float zfar);
46 void mat4_perspective(float *m, float fov, float aspect, float znear, float zfar);
47
48 void mat4_mirror(float *m, float a, float b, float c, float d);
49
50 void mat4_print(float *m, FILE *fp);
51
52 #endif  /* MATRIX_H_ */