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

FXMat4d.h
1 /********************************************************************************
2 * *
3 * D o u b l e - P r e c i s i o n 4 x 4 M a t r i x *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1994,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 FXMAT4D_H
22 #define FXMAT4D_H
23 
24 namespace FX {
25 
26 
27 class FXQuatd;
28 class FXMat3d;
29 
30 
32 class FXAPI FXMat4d {
33 protected:
34  FXVec4d m[4];
35 public:
36 
38  FXMat4d(){}
39 
41  explicit FXMat4d(FXdouble s);
42 
44  FXMat4d(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
45  FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
46  FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
47  FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
48 
50  FXMat4d(const FXMat3d& s);
51 
53  FXMat4d(const FXMat4d& s);
54 
56  FXMat4d(const FXQuatd& quat);
57 
59  FXMat4d(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d);
60 
62  FXMat4d(FXdouble a,FXdouble b,FXdouble c,FXdouble d);
63 
65  explicit FXMat4d(const FXVec4d& d);
66 
68  explicit FXMat4d(const FXdouble s[]);
69 
71  FXMat4d& operator=(FXdouble s);
72 
74  FXMat4d& operator=(const FXMat3d& s);
75  FXMat4d& operator=(const FXMat4d& s);
76 
78  FXMat4d& operator=(const FXQuatd& quat);
79 
81  FXMat4d& operator=(const FXdouble s[]);
82 
84  FXMat4d& set(FXdouble s);
85 
87  FXMat4d& set(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
88  FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
89  FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
90  FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
91 
93  FXMat4d& set(const FXMat3d& s);
94 
96  FXMat4d& set(const FXMat4d& s);
97 
99  FXMat4d& set(const FXQuatd& quat);
100 
102  FXMat4d& set(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d);
103 
105  FXMat4d& set(FXdouble a,FXdouble b,FXdouble c,FXdouble d);
106 
108  FXMat4d& set(const FXVec4d& d);
109 
111  FXMat4d& set(const FXdouble s[]);
112 
114  FXMat4d& operator+=(const FXMat4d& w);
115  FXMat4d& operator-=(const FXMat4d& w);
116  FXMat4d& operator*=(const FXMat4d& w);
117  FXMat4d& operator*=(FXdouble w);
118  FXMat4d& operator/=(FXdouble w);
119 
121  FXVec4d& operator[](FXint i){return m[i];}
122  const FXVec4d& operator[](FXint i) const {return m[i];}
123 
125  operator FXdouble*(){return m[0];}
126  operator const FXdouble*() const {return m[0];}
127 
129  FXMat4d operator-() const;
130 
132  FXMat4d& identity();
133 
135  FXbool isIdentity() const;
136 
138  FXMat4d& setOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
139 
141  void getOrtho(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const;
142 
144  FXMat4d& setInverseOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
145 
147  FXMat4d& setFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
148 
150  void getFrustum(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const;
151 
153  FXMat4d& setInverseFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
154 
156  FXMat4d& left();
157 
159  FXMat4d& rot(const FXMat3d& r);
160 
162  FXMat4d& rot(const FXQuatd& q);
163 
165  FXMat4d& rot(const FXVec3d& v,FXdouble c,FXdouble s);
166 
168  FXMat4d& rot(const FXVec3d& v,FXdouble phi);
169 
171  FXMat4d& xrot(FXdouble c,FXdouble s);
172  FXMat4d& xrot(FXdouble phi);
173 
175  FXMat4d& yrot(FXdouble c,FXdouble s);
176  FXMat4d& yrot(FXdouble phi);
177 
179  FXMat4d& zrot(FXdouble c,FXdouble s);
180  FXMat4d& zrot(FXdouble phi);
181 
183  FXMat4d& look(const FXVec3d& from,const FXVec3d& to,const FXVec3d& up);
184 
186  FXMat4d& trans(FXdouble tx,FXdouble ty,FXdouble tz);
187  FXMat4d& trans(const FXVec3d& v);
188 
190  FXMat4d& scale(FXdouble sx,FXdouble sy,FXdouble sz);
191  FXMat4d& scale(const FXVec3d& v);
192  FXMat4d& scale(FXdouble s);
193 
195  FXMat4d& mirror(const FXVec3d& n);
196 
198  FXdouble det() const;
199 
201  FXMat4d transpose() const;
202 
204  FXMat4d invert() const;
205 
207  FXMat4d affineInvert() const;
208 
210  FXMat4d rigidInvert() const;
211 
213  FXMat3d normalMatrix() const;
214 
217  };
218 
219 
221 extern FXAPI FXVec3d operator*(const FXMat4d& m,const FXVec3d& v);
222 extern FXAPI FXVec4d operator*(const FXMat4d& m,const FXVec4d& v);
223 
225 extern FXAPI FXVec3d operator*(const FXVec3d& v,const FXMat4d& m);
226 extern FXAPI FXVec4d operator*(const FXVec4d& v,const FXMat4d& m);
227 
229 extern FXAPI FXMat4d operator+(const FXMat4d& a,const FXMat4d& b);
230 extern FXAPI FXMat4d operator-(const FXMat4d& a,const FXMat4d& b);
231 
233 extern FXAPI FXMat4d operator*(const FXMat4d& a,const FXMat4d& b);
234 
236 extern FXAPI FXMat4d operator*(FXdouble x,const FXMat4d& a);
237 extern FXAPI FXMat4d operator*(const FXMat4d& a,FXdouble x);
238 extern FXAPI FXMat4d operator/(const FXMat4d& a,FXdouble x);
239 extern FXAPI FXMat4d operator/(FXdouble x,const FXMat4d& a);
240 
242 extern FXAPI FXbool operator==(const FXMat4d& a,const FXMat4d& b);
243 extern FXAPI FXbool operator!=(const FXMat4d& a,const FXMat4d& b);
244 extern FXAPI FXbool operator==(const FXMat4d& a,FXdouble n);
245 extern FXAPI FXbool operator!=(const FXMat4d& a,FXdouble n);
246 extern FXAPI FXbool operator==(FXdouble n,const FXMat4d& a);
247 extern FXAPI FXbool operator!=(FXdouble n,const FXMat4d& a);
248 
250 extern FXAPI FXMat4d orthogonalize(const FXMat4d& m);
251 
253 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat4d& m);
254 
256 extern FXAPI FXStream& operator>>(FXStream& store,FXMat4d& m);
257 
258 }
259 
260 #endif
Double-precision quaternion.
Definition: FXQuatd.h:32
Double-precision 4x4 matrix.
Definition: FXMat4d.h:32
FXVec4d & operator[](FXint i)
Indexing.
Definition: FXMat4d.h:121
Definition: FX4Splitter.h:28
Double-precision 4-element vector.
Definition: FXVec4d.h:28
~FXMat4d()
Destructor.
Definition: FXMat4d.h:216
FXMat4d()
Default constructor; value is not initialized.
Definition: FXMat4d.h:38
Double-precision 3x3 matrix.
Definition: FXMat3d.h:33

Copyright © 1997-2022 Jeroen van der Zijp