Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXMat2f.h
1 /********************************************************************************
2 * *
3 * S i n g l e - P r e c i s i o n 2 x 2 M a t r i x *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2003,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXMAT2F_H
22 #define FXMAT2F_H
23 
24 namespace FX {
25 
26 
27 class FXMat3f;
28 
29 
31 class FXAPI FXMat2f {
32 protected:
33  FXVec2f m[2];
34 public:
35 
37  FXMat2f(){}
38 
40  FXMat2f(FXfloat s);
41 
43  FXMat2f(const FXMat2f& s);
44 
46  FXMat2f(const FXMat3f& s);
47 
49  FXMat2f(const FXfloat s[]);
50 
52  FXMat2f(FXfloat a,FXfloat b);
53 
55  FXMat2f(FXfloat a00,FXfloat a01,FXfloat a10,FXfloat a11);
56 
58  FXMat2f(const FXVec2f& a,const FXVec2f& b);
59 
61  FXMat2f& operator=(FXfloat s);
62 
64  FXMat2f& operator=(const FXMat2f& s);
65  FXMat2f& operator=(const FXMat3f& s);
66 
68  FXMat2f& operator=(const FXfloat s[]);
69 
71  FXMat2f& set(FXfloat s);
72 
74  FXMat2f& set(const FXMat2f& s);
75 
77  FXMat2f& set(const FXMat3f& s);
78 
80  FXMat2f& set(const FXfloat s[]);
81 
83  FXMat2f& set(FXfloat a,FXfloat b);
84 
86  FXMat2f& set(FXfloat a00,FXfloat a01,FXfloat a10,FXfloat a11);
87 
89  FXMat2f& set(const FXVec2f& a,const FXVec2f& b);
90 
92  FXMat2f& operator+=(const FXMat2f& s);
93  FXMat2f& operator-=(const FXMat2f& s);
94  FXMat2f& operator*=(const FXMat2f& s);
95  FXMat2f& operator*=(FXfloat s);
96  FXMat2f& operator/=(FXfloat s);
97 
99  FXVec2f& operator[](FXint i){return m[i];}
100  const FXVec2f& operator[](FXint i) const {return m[i];}
101 
103  operator FXfloat*(){return m[0];}
104  operator const FXfloat*() const {return m[0];}
105 
107  FXMat2f operator-() const;
108 
110  FXMat2f& identity();
111 
113  FXbool isIdentity() const;
114 
116  FXMat2f& rot(FXfloat c,FXfloat s);
117  FXMat2f& rot(FXfloat phi);
118 
120  FXMat2f& scale(FXfloat sx,FXfloat sy);
121  FXMat2f& scale(FXfloat s);
122 
124  FXfloat det() const;
125 
127  FXMat2f transpose() const;
128 
130  FXMat2f invert() const;
131 
134  };
135 
136 
138 extern FXAPI FXVec2f operator*(const FXMat2f& m,const FXVec2f& v);
139 
141 extern FXAPI FXVec2f operator*(const FXVec2f& v,const FXMat2f& m);
142 
144 extern FXAPI FXMat2f operator+(const FXMat2f& a,const FXMat2f& b);
145 extern FXAPI FXMat2f operator-(const FXMat2f& a,const FXMat2f& b);
146 
148 extern FXAPI FXMat2f operator*(const FXMat2f& a,const FXMat2f& b);
149 
151 extern FXAPI FXMat2f operator*(FXfloat x,const FXMat2f& a);
152 extern FXAPI FXMat2f operator*(const FXMat2f& a,FXfloat x);
153 extern FXAPI FXMat2f operator/(const FXMat2f& a,FXfloat x);
154 extern FXAPI FXMat2f operator/(FXfloat x,const FXMat2f& a);
155 
157 extern FXAPI FXbool operator==(const FXMat2f& a,const FXMat2f& b);
158 extern FXAPI FXbool operator!=(const FXMat2f& a,const FXMat2f& b);
159 extern FXAPI FXbool operator==(const FXMat2f& a,FXfloat n);
160 extern FXAPI FXbool operator!=(const FXMat2f& a,FXfloat n);
161 extern FXAPI FXbool operator==(FXfloat n,const FXMat2f& a);
162 extern FXAPI FXbool operator!=(FXfloat n,const FXMat2f& a);
163 
165 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat2f& m);
166 
168 extern FXAPI FXStream& operator>>(FXStream& store,FXMat2f& m);
169 
170 }
171 
172 #endif

Copyright © 1997-2016 Jeroen van der Zijp