1 /* matrix.h -- Fixed-point 2D linear algebra operations with matrices
2 
3    Copyright 2001 Carl Worth
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 */
15 
16 #ifndef MATRIX_H
17 #define MATRIX_H
18 
19 struct matrix
20 {
21     int precision_bits;
22     long int m[3][3];
23 };
24 typedef struct matrix matrix_t;
25 
26 int matrix_init(matrix_t *matrix, int precision);
27 
28 void matrix_set_explicit(matrix_t *matrix,
29 			 double m00, double m01, double m02,
30 			 double m10, double m11, double m12,
31 			 double m20, double m21, double m22);
32 void matrix_set_identity(matrix_t *matrix);
33 void matrix_set_translate(matrix_t *matrix, double x_off, double y_off);
34 void matrix_set_scale(matrix_t *matrix, double x_scale, double y_scale);
35 void matrix_set_rotate(matrix_t *matrix, double theta);
36 void matrix_set_rotate_about(matrix_t *matrix, double theta, double x, double y);
37 
38 void matrix_copy(matrix_t *dest, matrix_t *src);
39 void matrix_multiply(matrix_t *result, matrix_t *a, matrix_t *b);
40 
41 #endif
42 
43