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,2024 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  explicit FXMat2f(FXfloat s);
41 
43  FXMat2f(FXfloat a00,FXfloat a01,
44  FXfloat a10,FXfloat a11);
45 
47  FXMat2f(const FXMat2f& s);
48 
50  FXMat2f(const FXMat3f& s);
51 
53  FXMat2f(const FXVec2f& a,const FXVec2f& b);
54 
56  FXMat2f(FXfloat a,FXfloat b);
57 
59  explicit FXMat2f(const FXVec2f& d);
60 
62  explicit FXMat2f(const FXfloat s[]);
63 
65  FXMat2f& operator=(FXfloat s);
66 
68  FXMat2f& operator=(const FXMat2f& s);
69  FXMat2f& operator=(const FXMat3f& s);
70 
72  FXMat2f& operator=(const FXfloat s[]);
73 
75  FXMat2f& set(FXfloat s);
76 
78  FXMat2f& set(FXfloat a00,FXfloat a01,
79  FXfloat a10,FXfloat a11);
80 
82  FXMat2f& set(const FXMat2f& s);
83 
85  FXMat2f& set(const FXMat3f& s);
86 
88  FXMat2f& set(const FXVec2f& a,const FXVec2f& b);
89 
91  FXMat2f& set(FXfloat a,FXfloat b);
92 
94  FXMat2f& set(const FXVec2f& d);
95 
97  FXMat2f& set(const FXfloat s[]);
98 
100  FXMat2f& operator+=(const FXMat2f& s);
101  FXMat2f& operator-=(const FXMat2f& s);
102  FXMat2f& operator*=(const FXMat2f& s);
103  FXMat2f& operator*=(FXfloat s);
104  FXMat2f& operator/=(FXfloat s);
105 
107  FXVec2f& operator[](FXint i){return m[i];}
108  const FXVec2f& operator[](FXint i) const {return m[i];}
109 
111  operator FXfloat*(){return m[0];}
112  operator const FXfloat*() const {return m[0];}
113 
115  FXMat2f operator-() const;
116 
118  FXMat2f& identity();
119 
121  FXbool isIdentity() const;
122 
124  FXMat2f& rot(FXfloat c,FXfloat s);
125  FXMat2f& rot(FXfloat phi);
126 
128  FXMat2f& scale(FXfloat sx,FXfloat sy);
129  FXMat2f& scale(FXfloat s);
130 
132  FXfloat det() const;
133 
135  FXMat2f transpose() const;
136 
138  FXMat2f invert() const;
139 
142  };
143 
144 
146 extern FXAPI FXVec2f operator*(const FXMat2f& m,const FXVec2f& v);
147 
149 extern FXAPI FXVec2f operator*(const FXVec2f& v,const FXMat2f& m);
150 
152 extern FXAPI FXMat2f operator+(const FXMat2f& a,const FXMat2f& b);
153 extern FXAPI FXMat2f operator-(const FXMat2f& a,const FXMat2f& b);
154 
156 extern FXAPI FXMat2f operator*(const FXMat2f& a,const FXMat2f& b);
157 
159 extern FXAPI FXMat2f operator*(FXfloat x,const FXMat2f& a);
160 extern FXAPI FXMat2f operator*(const FXMat2f& a,FXfloat x);
161 extern FXAPI FXMat2f operator/(const FXMat2f& a,FXfloat x);
162 extern FXAPI FXMat2f operator/(FXfloat x,const FXMat2f& a);
163 
165 extern FXAPI FXbool operator==(const FXMat2f& a,const FXMat2f& b);
166 extern FXAPI FXbool operator!=(const FXMat2f& a,const FXMat2f& b);
167 extern FXAPI FXbool operator==(const FXMat2f& a,FXfloat n);
168 extern FXAPI FXbool operator!=(const FXMat2f& a,FXfloat n);
169 extern FXAPI FXbool operator==(FXfloat n,const FXMat2f& a);
170 extern FXAPI FXbool operator!=(FXfloat n,const FXMat2f& a);
171 
173 extern FXAPI FXMat2f orthogonalize(const FXMat2f& m);
174 
176 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat2f& m);
177 
179 extern FXAPI FXStream& operator>>(FXStream& store,FXMat2f& m);
180 
181 }
182 
183 #endif
FXVec2f & operator[](FXint i)
Indexing.
Definition: FXMat2f.h:107
Single-precision 2-element vector.
Definition: FXVec2f.h:28
FXMat2f()
Default constructor; value is not initialized.
Definition: FXMat2f.h:37
Single-precision 3x3 matrix.
Definition: FXMat3f.h:33
Definition: FX4Splitter.h:28
Single-precision 2x2 matrix.
Definition: FXMat2f.h:31
~FXMat2f()
Destructor.
Definition: FXMat2f.h:141

Copyright © 1997-2022 Jeroen van der Zijp