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

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

Copyright © 1997-2022 Jeroen van der Zijp