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,2022 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  FXMat4d(FXdouble s);
42 
44  FXMat4d(const FXMat3d& s);
45 
47  FXMat4d(const FXMat4d& s);
48 
50  FXMat4d(const FXdouble s[]);
51 
53  FXMat4d(FXdouble a,FXdouble b,FXdouble c,FXdouble d);
54 
56  FXMat4d(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
57  FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
58  FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
59  FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
60 
62  FXMat4d(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d);
63 
65  FXMat4d(const FXQuatd& quat);
66 
68  FXMat4d& operator=(FXdouble s);
69 
71  FXMat4d& operator=(const FXMat3d& s);
72  FXMat4d& operator=(const FXMat4d& s);
73 
75  FXMat4d& operator=(const FXQuatd& quat);
76 
78  FXMat4d& operator=(const FXdouble s[]);
79 
81  FXMat4d& set(FXdouble s);
82 
84  FXMat4d& set(const FXMat3d& s);
85 
87  FXMat4d& set(const FXMat4d& s);
88 
90  FXMat4d& set(const FXdouble s[]);
91 
93  FXMat4d& set(FXdouble a,FXdouble b,FXdouble c,FXdouble d);
94 
96  FXMat4d& set(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
97  FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
98  FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
99  FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
100 
102  FXMat4d& set(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d);
103 
105  FXMat4d& set(const FXQuatd& quat);
106 
108  FXMat4d& operator+=(const FXMat4d& w);
109  FXMat4d& operator-=(const FXMat4d& w);
110  FXMat4d& operator*=(const FXMat4d& w);
111  FXMat4d& operator*=(FXdouble w);
112  FXMat4d& operator/=(FXdouble w);
113 
115  FXVec4d& operator[](FXint i){return m[i];}
116  const FXVec4d& operator[](FXint i) const {return m[i];}
117 
119  operator FXdouble*(){return m[0];}
120  operator const FXdouble*() const {return m[0];}
121 
123  FXMat4d operator-() const;
124 
126  FXMat4d& identity();
127 
129  FXbool isIdentity() const;
130 
132  FXMat4d& setOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
133 
135  void getOrtho(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const;
136 
138  FXMat4d& setInverseOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
139 
141  FXMat4d& setFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
142 
144  void getFrustum(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const;
145 
147  FXMat4d& setInverseFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
148 
150  FXMat4d& left();
151 
153  FXMat4d& rot(const FXMat3d& r);
154 
156  FXMat4d& rot(const FXQuatd& q);
157 
159  FXMat4d& rot(const FXVec3d& v,FXdouble c,FXdouble s);
160 
162  FXMat4d& rot(const FXVec3d& v,FXdouble phi);
163 
165  FXMat4d& xrot(FXdouble c,FXdouble s);
166  FXMat4d& xrot(FXdouble phi);
167 
169  FXMat4d& yrot(FXdouble c,FXdouble s);
170  FXMat4d& yrot(FXdouble phi);
171 
173  FXMat4d& zrot(FXdouble c,FXdouble s);
174  FXMat4d& zrot(FXdouble phi);
175 
177  FXMat4d& look(const FXVec3d& from,const FXVec3d& to,const FXVec3d& up);
178 
180  FXMat4d& trans(FXdouble tx,FXdouble ty,FXdouble tz);
181  FXMat4d& trans(const FXVec3d& v);
182 
184  FXMat4d& scale(FXdouble sx,FXdouble sy,FXdouble sz);
185  FXMat4d& scale(const FXVec3d& v);
186  FXMat4d& scale(FXdouble s);
187 
189  FXdouble det() const;
190 
192  FXMat4d transpose() const;
193 
195  FXMat4d invert() const;
196 
198  FXMat4d affineInvert() const;
199 
201  FXMat4d rigidInvert() const;
202 
204  FXMat3d normalMatrix() const;
205 
208  };
209 
210 
212 extern FXAPI FXVec3d operator*(const FXMat4d& m,const FXVec3d& v);
213 extern FXAPI FXVec4d operator*(const FXMat4d& m,const FXVec4d& v);
214 
216 extern FXAPI FXVec3d operator*(const FXVec3d& v,const FXMat4d& m);
217 extern FXAPI FXVec4d operator*(const FXVec4d& v,const FXMat4d& m);
218 
220 extern FXAPI FXMat4d operator+(const FXMat4d& a,const FXMat4d& b);
221 extern FXAPI FXMat4d operator-(const FXMat4d& a,const FXMat4d& b);
222 
224 extern FXAPI FXMat4d operator*(const FXMat4d& a,const FXMat4d& b);
225 
227 extern FXAPI FXMat4d operator*(FXdouble x,const FXMat4d& a);
228 extern FXAPI FXMat4d operator*(const FXMat4d& a,FXdouble x);
229 extern FXAPI FXMat4d operator/(const FXMat4d& a,FXdouble x);
230 extern FXAPI FXMat4d operator/(FXdouble x,const FXMat4d& a);
231 
233 extern FXAPI FXbool operator==(const FXMat4d& a,const FXMat4d& b);
234 extern FXAPI FXbool operator!=(const FXMat4d& a,const FXMat4d& b);
235 extern FXAPI FXbool operator==(const FXMat4d& a,FXdouble n);
236 extern FXAPI FXbool operator!=(const FXMat4d& a,FXdouble n);
237 extern FXAPI FXbool operator==(FXdouble n,const FXMat4d& a);
238 extern FXAPI FXbool operator!=(FXdouble n,const FXMat4d& a);
239 
241 extern FXAPI FXMat4d orthogonalize(const FXMat4d& m);
242 
244 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat4d& m);
245 
247 extern FXAPI FXStream& operator>>(FXStream& store,FXMat4d& m);
248 
249 }
250 
251 #endif
Double-precision quaternion.
Definition: FXQuatd.h:32
Double-precision 4x4 matrix.
Definition: FXMat4d.h:32
FXVec4d & operator[](FXint i)
Indexing.
Definition: FXMat4d.h:115
Definition: FX4Splitter.h:28
Double-precision 4-element vector.
Definition: FXVec4d.h:28
~FXMat4d()
Destructor.
Definition: FXMat4d.h:207
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