-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.h
39 lines (29 loc) · 966 Bytes
/
matrix.h
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
#ifndef MATRIX_H
#define MATRIX_H
#include <stddef.h>
#include "vector.h"
struct matrix {
struct vector *m;
int cols;
int lastcol;
} matrix;
static const struct matrix EMPTY_MATRIX = {NULL, 0, -1};
typedef double tmatrix[4][4];
//Basic matrix manipulation routines
void new_matrix(struct matrix *m, int cols);
void free_matrix(struct matrix *m);
void grow_matrix(struct matrix *m, int newcols);
void copy_tmatrix(tmatrix a, tmatrix b);
void print_matrix(struct matrix *m);
void print_tmatrix(tmatrix m);
void ident(tmatrix m);
void tmatrix_mult(tmatrix a, tmatrix b); /* a *= b */
void transform_pt(tmatrix a, struct vector *b);
void transform_pts(tmatrix a, struct matrix *b); /* b = a * b */
/* transformation routines */
void make_translate(tmatrix m, struct vector *d);
void make_scale(tmatrix m, struct vector *d);
void make_rotX(tmatrix m, double theta);
void make_rotY(tmatrix m, double theta);
void make_rotZ(tmatrix m, double theta);
#endif