ICF 3.0.5.47
Technical documentation of ICF Libraries
CMatrix3d.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// ICF includes
10#include <imath/TMatrix.h>
11#include <i3d/CVector3d.h>
12
13
14namespace i3d
15{
16
17
21class CMatrix3d: public imath::TMatrix<3, 3>
22{
23public:
25
29 CMatrix3d();
30 CMatrix3d(const CMatrix3d& transform);
34 CMatrix3d( const CVector3d& axisX,
35 const CVector3d& axisY,
36 const CVector3d& axisZ);
40 CMatrix3d( double m11, double m12, double m13,
41 double m21, double m22, double m23,
42 double m31, double m32, double m33);
43
47 void Reset();
48
49 // operations
51 CVector3d GetMultiplied(const CVector3d& position) const;
52 CMatrix3d GetMultiplied(const CMatrix3d& matrix) const;
53 void Multiply(const CMatrix3d& matrix);
54 void MultiplyLeft(const CMatrix3d& matrix);
55
59 CVector3d GetAxisX() const;
60
64 CVector3d GetAxisY() const;
65
69 CVector3d GetAxisZ() const;
70
75
79 void GetAxesLengths(CVector3d& result) const;
80
85
89 bool GetInvMultiplied(const i3d::CVector3d& position, i3d::CVector3d& result) const;
90
94 CMatrix3d GetInverted() const;
95
99 bool GetInverted(CMatrix3d& result) const;
100
102
106 CMatrix3d GetTransposed() const;
107
111 double GetDet() const;
112
116 CMatrix3d& operator=(const CMatrix3d& matrix);
117
121 CMatrix3d operator*(double scale) const;
125 CMatrix3d operator/(double scale) const;
126
127 // static methods
128 static const CMatrix3d& GetIdentity();
129
130private:
131 // static members
132 static CMatrix3d s_identity;
133};
134
135
136// inline methods
137
139{
140}
141
142
143inline CMatrix3d::CMatrix3d(const CMatrix3d& matrix)
144: BaseClass(matrix)
145{
146}
147
148
150 const CVector3d& axisX,
151 const CVector3d& axisY,
152 const CVector3d& axisZ)
153{
154 SetAt(0, 0, axisX[0]);
155 SetAt(0, 1, axisX[1]);
156 SetAt(0, 2, axisX[2]);
157 SetAt(1, 0, axisY[0]);
158 SetAt(1, 1, axisY[1]);
159 SetAt(1, 2, axisY[2]);
160 SetAt(2, 0, axisZ[0]);
161 SetAt(2, 1, axisZ[1]);
162 SetAt(2, 2, axisZ[2]);
163}
164
165
167 double m11, double m12, double m13,
168 double m21, double m22, double m23,
169 double m31, double m32, double m33)
170{
171 SetAt(0, 0, m11);
172 SetAt(0, 1, m12);
173 SetAt(0, 2, m13);
174 SetAt(1, 0, m21);
175 SetAt(1, 1, m22);
176 SetAt(1, 2, m23);
177 SetAt(2, 0, m31);
178 SetAt(2, 1, m32);
179 SetAt(2, 2, m33);
180}
181
182
183inline CVector3d CMatrix3d::GetMultiplied(const CVector3d& position) const
184{
185 CVector3d retVal;
186
187 GetMultiplied(position, retVal);
188
189 return retVal;
190}
191
192
194{
195 CMatrix3d retVal;
196
197 GetMultiplied(matrix, retVal);
198
199 return retVal;
200}
201
202
204{
205 return CVector3d(GetAt(0, 0), GetAt(0, 1), GetAt(0, 2));
206}
207
208
210{
211 return CVector3d(GetAt(1, 0), GetAt(1, 1), GetAt(1, 2));
212}
213
215{
216 return CVector3d(GetAt(2, 0), GetAt(2, 1), GetAt(2, 2));
217}
218
219
221{
222 CVector3d result;
223
224 GetAxesLengths(result);
225
226 return result;
227}
228
229
230inline void CMatrix3d::GetAxesLengths(CVector3d& result) const
231{
232 result.SetX(GetAxisX().GetLength());
233 result.SetY(GetAxisY().GetLength());
234 result.SetZ(GetAxisZ().GetLength());
235}
236
237
239{
240 CMatrix3d result;
241
242 GetInverted(result);
243
244 return result;
245}
246
247
249{
250 return CMatrix3d( GetAt(0, 0), GetAt(1, 0), GetAt(2, 0),
251 GetAt(0, 1), GetAt(1, 1), GetAt(2, 1),
252 GetAt(0, 2), GetAt(1, 2), GetAt(2, 2));
253}
254
255
256inline double CMatrix3d::GetDet() const
257{
258 return (GetAt(0, 0) * GetAt(1, 1) * GetAt(2, 2)) +
259 (GetAt(0, 1) * GetAt(1, 2) * GetAt(2, 0)) +
260 (GetAt(0, 2) * GetAt(1, 0) * GetAt(2, 1)) -
261 (GetAt(0, 0) * GetAt(1, 2) * GetAt(2, 1)) -
262 (GetAt(0, 1) * GetAt(1, 0) * GetAt(2, 2)) -
263 (GetAt(0, 2) * GetAt(1, 1) * GetAt(2, 0));
264}
265
266
267// operators
268
270{
271 BaseClass::operator=(matrix);
272
273 return *this;
274}
275
276
277inline CMatrix3d CMatrix3d::operator*(double scale) const
278{
279 CMatrix3d retVal;
280
281 GetScaled(scale, retVal);
282
283 return retVal;
284}
285
286
287inline CMatrix3d CMatrix3d::operator/(double scale) const
288{
289 return CMatrix3d( GetAt(0, 0) / scale,
290 GetAt(0, 1) / scale,
291 GetAt(0, 2) / scale,
292 GetAt(1, 0) / scale,
293 GetAt(1, 1) / scale,
294 GetAt(1, 2) / scale,
295 GetAt(2, 0) / scale,
296 GetAt(2, 1) / scale,
297 GetAt(2, 2) / scale);
298}
299
300
301// static methods
302
304{
305 return s_identity;
306}
307
308
309} // namespace i3d
310
311
3D-matrix definition.
Definition CMatrix3d.h:22
CMatrix3d()
Constructor with no member initialization.
Definition CMatrix3d.h:138
void Reset()
Default reset to identity.
imath::TMatrix< 3, 3 > BaseClass
Definition CMatrix3d.h:24
CVector3d GetMultiplied(const CVector3d &position) const
Definition CMatrix3d.h:183
static const CMatrix3d & GetIdentity()
Definition CMatrix3d.h:303
CMatrix3d operator*(double scale) const
Multiplication by scalar number.
Definition CMatrix3d.h:277
CMatrix3d GetInverted() const
Calculate inverted matrix.
Definition CMatrix3d.h:238
CVector3d GetAxisY() const
Get axis Y vector.
Definition CMatrix3d.h:209
CVector3d GetAxisX() const
Get axis X vector.
Definition CMatrix3d.h:203
i3d::CVector3d GetInvMultiplied(const i3d::CVector3d &position) const
Inverted operation to GetApply().
double GetDet() const
Calculate determinant of deformation matrix.
Definition CMatrix3d.h:256
CMatrix3d operator/(double scale) const
Division by scalar number.
Definition CMatrix3d.h:287
bool GetInvMultiplied(const i3d::CVector3d &position, i3d::CVector3d &result) const
Inverted operation to GetApply().
CMatrix3d & operator=(const CMatrix3d &matrix)
Copy operator.
Definition CMatrix3d.h:269
void Multiply(const CMatrix3d &matrix)
CVector3d GetAxisZ() const
Get axis Z vector.
Definition CMatrix3d.h:214
void MultiplyLeft(const CMatrix3d &matrix)
CMatrix3d GetTransposed() const
Calculate transposed matrix.
Definition CMatrix3d.h:248
CVector3d GetAxesLengths() const
Get lengths of axes vectors.
Definition CMatrix3d.h:220
bool GetInverted(CMatrix3d &result) const
Calculate inverted matrix.
Definition of position or mathematical vector in 3D space.
Definition CVector3d.h:26
void SetZ(double value)
Set Y position of this vector.
Definition CVector3d.h:174
void SetX(double value)
Set X position of this vector.
Definition CVector3d.h:150
void SetY(double value)
Set Y position of this vector.
Definition CVector3d.h:162
Definition of mathematical matrix with fixed dimensions.
Definition TMatrix.h:33
TMatrix< Height, Width, double > GetTransposed() const
Definition TMatrix.h:347
void GetMultiplied(const TMatrix< SecondWidth, Width, double > &matrix, TMatrix< SecondWidth, Height, double > &result) const
Definition TMatrix.h:200
void GetScaled(double value, TMatrix< Width, Height, double > &result) const
Definition TMatrix.h:771
void SetAt(const IndexType &index, const ElementType &value)
Definition TMatrix.h:656
const ElementType & GetAt(const IndexType &index) const
Definition TMatrix.h:628
Contains the 3D objects.
Definition CMatrix3d.h:15

© Witold Gantzke and Kirill Lepskiy