5274b309a80fa09c9f65b33935a5c27951c8744f
[ctsim.git] / include / transformmatrix.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **      Name:         sgp.h
5 **      Purpose:      Header file for Simple Graphics Package
6 **      Author:       Kevin Rosenberg
7 **      Date Started: 1984
8 **
9 **  This is part of the CTSim program
10 **  Copyright (C) 1983-2000 Kevin Rosenberg
11 **
12 **  $Id: transformmatrix.h,v 1.1 2000/07/28 08:28:08 kevin Exp $
13 **
14 **  This program is free software; you can redistribute it and/or modify
15 **  it under the terms of the GNU General Public License (version 2) as
16 **  published by the Free Software Foundation.
17 **
18 **  This program is distributed in the hope that it will be useful,
19 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 **  GNU General Public License for more details.
22 **
23 **  You should have received a copy of the GNU General Public License
24 **  along with this program; if not, write to the Free Software
25 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 ******************************************************************************/
27
28 #ifndef __H_TRANSFORMMATRIX
29 #define __H_TRANSFORMMATRIX
30
31 class ostream;
32 class TransformationMatrix2D {
33 public:
34   double mtx[3][3];
35
36   TransformationMatrix2D () {};
37   TransformationMatrix2D (double m[3][3]);
38
39   void setIdentity();
40   void setTranslate (double x, double y);
41   void setScale (double sx, double sy);
42   void setShear (double shrx, double shry);
43   void setRotate (double theta);
44
45   double determinant () const;
46
47   const TransformationMatrix2D invert () const;
48
49   void transformPoint (double *pX, double *pY) const;
50
51   void print (ostream& ostr) const;
52
53   friend const TransformationMatrix2D operator* (const TransformationMatrix2D& lhs, const TransformationMatrix2D& rhs);
54
55 };
56
57
58 const TransformationMatrix2D  operator* (const TransformationMatrix2D& lhs, const TransformationMatrix2D& rhs);
59
60 #endif