00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021
00022
00023 #include "matrix.h"
00024
00025 #ifdef RCSID
00026 static char *rcsid = "$Id: matrix.cc,v 1.1.1.1 2002/01/25 22:14:58 kergoth Exp $";
00027 #endif
00028
00029 Matrix::Matrix()
00030 {
00031 a = 1.0;
00032 d = 1.0;
00033 b = c = 0.0;
00034 tx = ty = 0;
00035 }
00036
00037 Matrix Matrix::operator*(Matrix m)
00038 {
00039 Matrix mat;
00040
00041 mat.a = this->a * m.a + this->b * m.c;
00042 mat.b = this->a * m.b + this->b * m.d;
00043 mat.c = this->c * m.a + this->d * m.c;
00044 mat.d = this->c * m.b + this->d * m.d;
00045
00046 mat.tx = this->getX(m.tx,m.ty);
00047 mat.ty = this->getY(m.tx,m.ty);
00048
00049 return mat;
00050 }
00051
00052 Matrix Matrix::invert()
00053 {
00054 Matrix mat;
00055 float det;
00056
00057 det = a*d-b*c;
00058
00059 mat.a = d/det;
00060 mat.b = -b/det;
00061 mat.c = -c/det;
00062 mat.d = a/det;
00063
00064 mat.tx = - (long)(mat.a * tx + mat.b * ty);
00065 mat.ty = - (long)(mat.c * tx + mat.d * ty);
00066
00067 return mat;
00068 }