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  FXMat2d(FXdouble s);
41 
43  FXMat2d(const FXMat2d& s);
44 
46  FXMat2d(const FXMat3d& s);
47 
49  FXMat2d(const FXdouble s[]);
50 
52  FXMat2d(FXdouble a,FXdouble b);
53 
55  FXMat2d(FXdouble a00,FXdouble a01,FXdouble a10,FXdouble a11);
56 
58  FXMat2d(const FXVec2d& a,const FXVec2d& b);
59 
61  FXMat2d& operator=(FXdouble s);
62 
64  FXMat2d& operator=(const FXMat2d& s);
65  FXMat2d& operator=(const FXMat3d& s);
66 
68  FXMat2d& operator=(const FXdouble s[]);
69 
71  FXMat2d& set(FXdouble s);
72 
74  FXMat2d& set(const FXMat2d& s);
75 
77  FXMat2d& set(const FXMat3d& s);
78 
80  FXMat2d& set(const FXdouble s[]);
81 
83  FXMat2d& set(FXdouble a,FXdouble b);
84 
86  FXMat2d& set(FXdouble a00,FXdouble a01,FXdouble a10,FXdouble a11);
87 
89  FXMat2d& set(const FXVec2d& a,const FXVec2d& b);
90 
92  FXMat2d& operator+=(const FXMat2d& s);
93  FXMat2d& operator-=(const FXMat2d& s);
94  FXMat2d& operator*=(const FXMat2d& s);
95  FXMat2d& operator*=(FXdouble s);
96  FXMat2d& operator/=(FXdouble s);
97 
99  FXVec2d& operator[](FXint i){return m[i];}
100  const FXVec2d& operator[](FXint i) const {return m[i];}
101 
103  operator FXdouble*(){return m[0];}
104  operator const FXdouble*() const {return m[0];}
105 
107  FXMat2d operator-() const;
108 
110  FXMat2d& identity();
111 
113  FXbool isIdentity() const;
114 
116  FXMat2d& rot(FXdouble c,FXdouble s);
117  FXMat2d& rot(FXdouble phi);
118 
120  FXMat2d& scale(FXdouble sx,FXdouble sy);
121  FXMat2d& scale(FXdouble s);
122 
124  FXdouble det() const;
125 
127  FXMat2d transpose() const;
128 
130  FXMat2d invert() const;
131 
134  };
135 
136 
138 extern FXAPI FXVec2d operator*(const FXMat2d& m,const FXVec2d& v);
139 
141 extern FXAPI FXVec2d operator*(const FXVec2d& v,const FXMat2d& m);
142 
144 extern FXAPI FXMat2d operator+(const FXMat2d& a,const FXMat2d& b);
145 extern FXAPI FXMat2d operator-(const FXMat2d& a,const FXMat2d& b);
146 
148 extern FXAPI FXMat2d operator*(const FXMat2d& a,const FXMat2d& b);
149 
151 extern FXAPI FXMat2d operator*(FXdouble x,const FXMat2d& a);
152 extern FXAPI FXMat2d operator*(const FXMat2d& a,FXdouble x);
153 extern FXAPI FXMat2d operator/(const FXMat2d& a,FXdouble x);
154 extern FXAPI FXMat2d operator/(FXdouble x,const FXMat2d& a);
155 
157 extern FXAPI FXbool operator==(const FXMat2d& a,const FXMat2d& b);
158 extern FXAPI FXbool operator!=(const FXMat2d& a,const FXMat2d& b);
159 extern FXAPI FXbool operator==(const FXMat2d& a,FXdouble n);
160 extern FXAPI FXbool operator!=(const FXMat2d& a,FXdouble n);
161 extern FXAPI FXbool operator==(FXdouble n,const FXMat2d& a);
162 extern FXAPI FXbool operator!=(FXdouble n,const FXMat2d& a);
163 
165 extern FXAPI FXMat2d orthogonalize(const FXMat2d& m);
166 
168 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat2d& m);
169 
171 extern FXAPI FXStream& operator>>(FXStream& store,FXMat2d& m);
172 
173 }
174 
175 #endif
Double-precision 2x2 matrix.
Definition: FXMat2d.h:31
FXVec2d & operator[](FXint i)
Indexing.
Definition: FXMat2d.h:99
FXMat2d()
Default constructor; value is not initialized.
Definition: FXMat2d.h:37
Definition: FX4Splitter.h:28
~FXMat2d()
Destructor.
Definition: FXMat2d.h:133
Double-precision 2-element vector.
Definition: FXVec2d.h:28
Double-precision 3x3 matrix.
Definition: FXMat3d.h:33

Copyright © 1997-2022 Jeroen van der Zijp