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

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

Copyright © 1997-2022 Jeroen van der Zijp