diff options
Diffstat (limited to 'matrix.h')
-rw-r--r-- | matrix.h | 74 |
1 files changed, 41 insertions, 33 deletions
@@ -30,51 +30,59 @@ #include "global.h" template <class Ty> class Matrix +{ +public: + Matrix() { - public: - Matrix() - { - int a,b; - - for(a=0;a<3;a++) - for(b=0;b<3;b++) - mat[a][b]=0; - } + int a,b; - ~Matrix() + for(a=0;a<3;a++) { + for(b=0;b<3;b++) + { + mat[a][b]=0; + } } + } - void identity() - { - int a,b; + ~Matrix() + { + } - for(a=0;a<3;a++) - for(b=0;b<3;b++) - mat[a][b]=(a==b) ? 1:0; - } + void identity() + { + int a,b; - void set(Ty x, Ty y, Ty z) + for(a=0;a<3;a++) { - identity(); - mat[0][0]=x; - mat[1][1]=y; - mat[2][2]=z; - mat[3][3]=1; + for(b=0;b<3;b++) + { + mat[a][b]=(a==b) ? 1:0; + } } + } - void get(Ty& x, Ty& y, Ty& z) - { - x=mat[0][0]; - y=mat[1][1]; - z=mat[2][2]; - } + void set(Ty x, Ty y, Ty z) + { + identity(); + mat[0][0] = x; + mat[1][1] = y; + mat[2][2] = z; + mat[3][3] = 1; + } + + void get(Ty& x, Ty& y, Ty& z) + { + x = mat[0][0]; + y = mat[1][1]; + z = mat[2][2]; + } - Matrix& operator*(Matrix<Ty>& m); + Matrix& operator*(Matrix<Ty>& m); - private: - Ty mat[4][4]; - }; +private: + Ty mat[4][4]; +}; #endif |