CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
TrVisMatrix.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23// Matrix definition
24
25#ifndef ODTRVISMATRIX
26#define ODTRVISMATRIX
27
28#include "TD_PackPush.h"
29
30#include "TrVisVector.h"
31
32#include "Ge/GeMatrix3d.h"
33#include "OdArray.h"
34
39template <typename DataType, typename VectorType>
41{
42 const VectorType &_vec;
43 OdTrVisMatDefVecTypeAdaptor(const VectorType &vec) : _vec(vec) {}
44 DataType operator [](int nAxis) const { return (DataType)((!nAxis) ? _vec.x : ((nAxis == 1) ? _vec.y : _vec.z)); }
45};
46
51template <typename DataType>
53{
54 // Represent data as rows and columns.
55 DataType entry[3][3];
56 // We doesn't provide constructors and copy operators. Initially data willn't be initialized.
57 // Instead of constructors we provide setters which return reference to our object.
58 typedef DataType EntryType;
59 struct Copier
60 { static inline void copy(DataType *pTo, const DataType *pFrom)
61 { pTo[0] = pFrom[0]; pTo[1] = pFrom[1]; pTo[2] = pFrom[2]; }
62 };
63 // Set from linear array.
64 OdTrVisMatrix3x3Impl &set(const DataType *pVals)
65 {
66 Copier::copy(entry[0], pVals);
67 Copier::copy(entry[1], pVals + 3);
68 Copier::copy(entry[2], pVals + 6);
69 return *this;
70 }
71 // Set from function arguments.
72 OdTrVisMatrix3x3Impl &set(DataType e00 = 1.0f, DataType e01 = 0.0f, DataType e02 = 0.0f,
73 DataType e10 = 0.0f, DataType e11 = 1.0f, DataType e12 = 0.0f,
74 DataType e20 = 0.0f, DataType e21 = 0.0f, DataType e22 = 1.0f)
75 {
76 entry[0][0] = e00; entry[0][1] = e01; entry[0][2] = e02;
77 entry[1][0] = e10; entry[1][1] = e11; entry[1][2] = e12;
78 entry[2][0] = e20; entry[2][1] = e21; entry[2][2] = e22;
79 return *this;
80 }
81 // Set to identity.
83 {
84 entry[0][0] = 1.0f; entry[0][1] = 0.0f; entry[0][2] = 0.0f;
85 entry[1][0] = 0.0f; entry[1][1] = 1.0f; entry[1][2] = 0.0f;
86 entry[2][0] = 0.0f; entry[2][1] = 0.0f; entry[2][2] = 1.0f;
87 return *this;
88 }
89 // Getters.
90 const DataType *getArray(int nRow = 0) const { return entry[nRow]; }
91 DataType *getArray(int nRow = 0) { return entry[nRow]; }
92 DataType operator()(int i, int j) const { return entry[i][j]; }
93 // Rows/columns accessor.
95 { return OdTrVisMiniVec3d<DataType>(entry[n][0], entry[n][1], entry[n][2]); }
97 { return OdTrVisMiniVec3d<DataType>(entry[0][n], entry[1][n], entry[2][n]); }
98 // Matrix multiplication.
101 for (int i = 0; i < 3; i++)
102 { for (int j = 0; j < 3; j++)
103 rv.entry[i][j] = entry[i][0] * m.entry[0][j] + entry[i][1] * m.entry[1][j] + entry[i][2] * m.entry[2][j];
104 }
105 return rv;
106 }
108 { return *this = *this * m; }
109 // To be completely correct we must have inverse multiplication.
112 for (int i = 0; i < 3; i++)
113 { for (int j = 0; j < 3; j++)
114 rv.entry[i][j] = entry[0][i] * m.entry[0][j] + entry[1][i] * m.entry[1][j] + entry[2][i] * m.entry[2][j];
115 }
116 return rv;
117 }
119 { return *this = *this ^ m; }
120 // Inverse operator.
121 OdTrVisMatrix3x3Impl &invert(const DataType eps = 1.e-8f)
122 { const DataType det = entry[0][0] * (entry[1][1] * entry[2][2] - entry[2][1] * entry[1][2]) -
123 entry[0][1] * (entry[1][0] * entry[2][2] - entry[1][2] * entry[2][0]) +
124 entry[0][2] * (entry[1][0] * entry[2][1] - entry[1][1] * entry[2][0]);
125 if (det < eps)
126 transpose();
127 else
128 { const OdTrVisMatrix3x3Impl src(*this);
129 const DataType invdet = 1.0f / det;
130 entry[0][0] = (src.entry[1][1] * src.entry[2][2] - src.entry[2][1] * src.entry[1][2]) * invdet;
131 entry[0][1] = (src.entry[0][2] * src.entry[2][1] - src.entry[0][1] * src.entry[2][2]) * invdet;
132 entry[0][2] = (src.entry[0][1] * src.entry[1][2] - src.entry[0][2] * src.entry[1][1]) * invdet;
133 entry[1][0] = (src.entry[1][2] * src.entry[2][0] - src.entry[1][0] * src.entry[2][2]) * invdet;
134 entry[1][1] = (src.entry[0][0] * src.entry[2][2] - src.entry[0][2] * src.entry[2][0]) * invdet;
135 entry[1][2] = (src.entry[1][0] * src.entry[0][2] - src.entry[0][0] * src.entry[1][2]) * invdet;
136 entry[2][0] = (src.entry[1][0] * src.entry[2][1] - src.entry[2][0] * src.entry[1][1]) * invdet;
137 entry[2][1] = (src.entry[2][0] * src.entry[0][1] - src.entry[0][0] * src.entry[2][1]) * invdet;
138 entry[2][2] = (src.entry[0][0] * src.entry[1][1] - src.entry[1][0] * src.entry[0][1]) * invdet;
139 }
140 return *this;
141 }
143 { return OdTrVisMatrix3x3Impl(*this).invert(); }
144 // Transpose operator.
146 { DataType *src = getArray();
147 std::swap(src[1], src[3]);
148 std::swap(src[2], src[6]);
149 std::swap(src[5], src[7]);
150 return *this;
151 }
153 { return OdTrVisMatrix3x3Impl(*this).transpose(); }
154 // Scale operators.
155 template <typename VectorType>
156 static OdTrVisMatrix3x3Impl &scaleMatrix(OdTrVisMatrix3x3Impl &m, const VectorType &v, bool bInverse = false)
157 { m.setIdentity();
158 if (!bInverse)
159 m.entry[0][0] = v[0], m.entry[1][1] = v[1], m.entry[2][2] = v[2];
160 else
161 m.entry[0][0] = 1.0f / v[0], m.entry[1][1] = 1.0f / v[1], m.entry[2][2] = 1.0f / v[2];
162 return m;
163 }
164 template <typename VectorType>
165 OdTrVisMatrix3x3Impl scale(const VectorType &v) const
167 return *this * scaleMatrix(s, v);
168 }
169 template <typename VectorType>
170 OdTrVisMatrix3x3Impl &setScale(const VectorType &v)
172 return *this * scaleMatrix(s, v);
173 }
174 template <typename VectorType>
175 OdTrVisMatrix3x3Impl recipScale(const VectorType &v) const
177 return *this * scaleMatrix(s, v, true);
178 }
179 template <typename VectorType>
182 return *this * scaleMatrix(s, v, true);
183 }
184 // Orthogonal scale.
185 static OdTrVisMatrix3x3Impl &scaleMatrix(OdTrVisMatrix3x3Impl &m, DataType s, bool bInverse = false)
186 { m.setIdentity();
187 if (!bInverse)
188 m.entry[0][0] = m.entry[1][1] = m.entry[2][2] = s;
189 else
190 m.entry[0][0] = m.entry[1][1] = m.entry[2][2] = 1.0f / s;
191 return m;
192 }
195 return m * scaleMatrix(s, n);
196 }
199 return scaleMatrix(s, n) * m;
200 }
203 return *this *= scaleMatrix(s, n);
204 }
207 return m * scaleMatrix(s, n, true);
208 }
211 return scaleMatrix(s, n, true) * m;
212 }
215 return *this *= scaleMatrix(s, n, true);
216 }
217 // Rotation operators.
218 template <typename VectorType>
220 { // Performs rotation in local coordinates system.
221 const DataType cos_b = (DataType)cos(angles[0]), sin_b = (DataType)sin(angles[0]);
222 const DataType cos_c = (DataType)cos(angles[1]), sin_c = (DataType)sin(angles[1]);
223 const DataType cos_a = (DataType)cos(angles[2]), sin_a = (DataType)sin(angles[2]);
224 // First matrix row
225 m.entry[0][0] = cos_a * cos_c - sin_a * sin_b * sin_c;
226 m.entry[0][1] = sin_a * cos_c + cos_a * sin_b * sin_c;
227 m.entry[0][2] = cos_b * sin_c;
228 // Second matrix row
229 m.entry[1][0] = -sin_a * cos_b;
230 m.entry[1][1] = cos_a * cos_b;
231 m.entry[1][2] = -sin_b;
232 // Third matrix row
233 m.entry[2][0] = -cos_a * sin_c - sin_a * sin_b * cos_c;
234 m.entry[2][1] = -sin_a * sin_c + cos_a * sin_b * cos_c;
235 m.entry[2][2] = cos_b * cos_c;
236 return m;
237 }
238 template <typename VectorType>
239 OdTrVisMatrix3x3Impl &localRotate(const VectorType &angles)
241 return *this *= localRotationMatrix(r, angles); }
242 // This is OpenGL-compatible version of rotation.
243 template <typename VectorType>
244 static OdTrVisMatrix3x3Impl &rotationMatrix(OdTrVisMatrix3x3Impl &m, DataType angle, const VectorType &v, const DataType eps = 1.e-8f)
245 { DataType xx, yy, zz, xy, yz, zx, xs, ys, zs;
246 const DataType x = v[0], y = v[1], z = v[2];
247 const DataType s = (DataType)sin(-angle), c = (DataType)cos(-angle);
248 const DataType mag = (DataType)sqrt(x * x + y * y + z * z);
249 if (mag < eps)
250 return m.setIdentity();
251 x /= mag; y /= mag; z /= mag;
252
253 xx = x * x; yy = y * y; zz = z * z;
254 xy = x * y; yz = y * z; zx = z * x;
255 xs = x * s; ys = y * s; zs = z * s;
256
257 const DataType one_c = 1.0f - c;
258 DataType *pMat = m.getArray();
259
260 pMat[0] = (one_c * xx) + c;
261 pMat[1] = (one_c * xy) - zs;
262 pMat[2] = (one_c * zx) + ys;
263
264 pMat[3] = (one_c * xy) + zs;
265 pMat[4] = (one_c * yy) + c;
266 pMat[5] = (one_c * yz) - xs;
267
268 pMat[6] = (one_c * zx) - ys;
269 pMat[7] = (one_c * yz) + xs;
270 pMat[8] = (one_c * zz) + c;
271
272 return m;
273 }
274 template <typename VectorType>
275 OdTrVisMatrix3x3Impl &rotate(DataType angle, const VectorType &v, const DataType eps = 1.e-8f)
277 return *this *= rotationMatrix(r, angle, v, eps); }
278 // Additional scaling operators.
280 {
281 const DataType x = fabs(entry[0][0]) + fabs(entry[0][1]) + fabs(entry[0][2]);
282 const DataType y = fabs(entry[1][0]) + fabs(entry[1][1]) + fabs(entry[1][2]);
283 const DataType z = fabs(entry[2][0]) + fabs(entry[2][1]) + fabs(entry[2][2]);
284 entry[0][0] /= x; entry[0][1] /= x; entry[0][2] /= x;
285 entry[1][0] /= y; entry[1][1] /= y; entry[1][2] /= y;
286 entry[2][0] /= z; entry[2][1] /= z; entry[2][2] /= z;
287 }
289 { return OdTrVisMiniVec3d<DataType>((DataType)(fabs(entry[0][0]) + fabs(entry[0][1]) + fabs(entry[0][2])),
290 (DataType)(fabs(entry[1][0]) + fabs(entry[1][1]) + fabs(entry[1][2])),
291 (DataType)(fabs(entry[2][0]) + fabs(entry[2][1]) + fabs(entry[2][2]))); }
292 // Vector transformation operators
293 template <typename VectorType>
294 VectorType &transform(VectorType &vec, DataType /*w*/ = 0.0f) const
295 { return vec.set(entry[0][0] * vec.x + entry[1][0] * vec.y + entry[2][0] * vec.z,
296 entry[0][1] * vec.x + entry[1][1] * vec.y + entry[2][1] * vec.z,
297 entry[0][2] * vec.x + entry[1][2] * vec.y + entry[2][2] * vec.z); }
298 template <typename VectorType>
299 VectorType transformClone(const VectorType &vec, DataType /*w*/ = 0.0f) const
300 { VectorType tmp(vec); return transform(tmp); }
301 template <typename VectorType>
302 friend VectorType operator *(const OdTrVisMatrix3x3Impl m, const VectorType &v)
303 { VectorType vec(v); return m.transform(vec); }
304 template <typename VectorType>
305 friend VectorType operator *(const VectorType &v, const OdTrVisMatrix3x3Impl m)
306 { VectorType vec(v); return m.transform(vec); }
307 // Inverse transformation
308 template <typename VectorType>
309 VectorType &untransform(VectorType &vec, DataType /*w*/ = 0.0f) const
310 { return vec.set(entry[0][0] * vec.x + entry[0][1] * vec.y + entry[0][2] * vec.z,
311 entry[1][0] * vec.x + entry[1][1] * vec.y + entry[1][2] * vec.z,
312 entry[2][0] * vec.x + entry[2][1] * vec.y + entry[2][2] * vec.z); }
313 template <typename VectorType>
314 VectorType untransformClone(const VectorType &vec, DataType /*w*/ = 0.0f) const
315 { VectorType tmp(vec); return untransform(tmp); }
316 template <typename VectorType>
317 friend VectorType operator ^(const OdTrVisMatrix3x3Impl m, const VectorType &v)
318 { VectorType vec(v); return m.untransform(vec); }
319 template <typename VectorType>
320 friend VectorType operator ^(const VectorType &v, const OdTrVisMatrix3x3Impl m)
321 { VectorType vec(v); return m.untransform(vec); }
322};
323
328template <typename DataType>
330{
331 // Represent data as rows and columns.
332 DataType entry[4][4];
333 // We doesn't provide constructors and copy operators. Initially data willn't be initialized.
334 // Instead of constructors we provide setters which return reference to our object.
335 typedef DataType EntryType;
336 struct Copier
337 { static void copy(DataType *pTo, const DataType *pFrom)
338 { pTo[0] = pFrom[0]; pTo[1] = pFrom[1]; pTo[2] = pFrom[2]; pTo[3] = pFrom[3]; }
339 };
340 // Set from linear array.
341 OdTrVisMatrix4x4Impl &set(const DataType *pVals)
342 {
343 Copier::copy(entry[0], pVals);
344 Copier::copy(entry[1], pVals + 4);
345 Copier::copy(entry[2], pVals + 8);
346 Copier::copy(entry[3], pVals + 12);
347 return *this;
348 }
349 // Set from Ge matrix.
350 OdTrVisMatrix4x4Impl &set(const OdGeMatrix3d &xMat, bool bTransposed = true)
351 {
352 if (!bTransposed)
353 {
354 entry[0][0] = (DataType)xMat.entry[0][0]; entry[0][1] = (DataType)xMat.entry[0][1];
355 entry[0][2] = (DataType)xMat.entry[0][2]; entry[0][3] = (DataType)xMat.entry[0][3];
356 entry[1][0] = (DataType)xMat.entry[1][0]; entry[1][1] = (DataType)xMat.entry[1][1];
357 entry[1][2] = (DataType)xMat.entry[1][2]; entry[1][3] = (DataType)xMat.entry[1][3];
358 entry[2][0] = (DataType)xMat.entry[2][0]; entry[2][1] = (DataType)xMat.entry[2][1];
359 entry[2][2] = (DataType)xMat.entry[2][2]; entry[2][3] = (DataType)xMat.entry[2][3];
360 entry[3][0] = (DataType)xMat.entry[3][0]; entry[3][1] = (DataType)xMat.entry[3][1];
361 entry[3][2] = (DataType)xMat.entry[3][2]; entry[3][3] = (DataType)xMat.entry[3][3];
362 }
363 else
364 {
365 entry[0][0] = (DataType)xMat.entry[0][0]; entry[1][0] = (DataType)xMat.entry[0][1];
366 entry[2][0] = (DataType)xMat.entry[0][2]; entry[3][0] = (DataType)xMat.entry[0][3];
367 entry[0][1] = (DataType)xMat.entry[1][0]; entry[1][1] = (DataType)xMat.entry[1][1];
368 entry[2][1] = (DataType)xMat.entry[1][2]; entry[3][1] = (DataType)xMat.entry[1][3];
369 entry[0][2] = (DataType)xMat.entry[2][0]; entry[1][2] = (DataType)xMat.entry[2][1];
370 entry[2][2] = (DataType)xMat.entry[2][2]; entry[3][2] = (DataType)xMat.entry[2][3];
371 entry[0][3] = (DataType)xMat.entry[3][0]; entry[1][3] = (DataType)xMat.entry[3][1];
372 entry[2][3] = (DataType)xMat.entry[3][2]; entry[3][3] = (DataType)xMat.entry[3][3];
373 }
374 return *this;
375 }
376 // Set from 3x3 matrix.
377 OdTrVisMatrix4x4Impl &set(const OdTrVisMatrix3x3Impl<DataType> &xMat, bool bExtend = false)
378 {
379 entry[0][0] = xMat.entry[0][0]; entry[0][1] = xMat.entry[0][1]; entry[0][2] = xMat.entry[0][2];
380 entry[1][0] = xMat.entry[1][0]; entry[1][1] = xMat.entry[1][1]; entry[1][2] = xMat.entry[1][2];
381 entry[2][0] = xMat.entry[2][0]; entry[2][1] = xMat.entry[2][1]; entry[2][2] = xMat.entry[2][2];
382 if (bExtend)
383 entry[0][3] = entry[1][3] = entry[2][3] = 0.0f,
384 entry[3][0] = entry[3][1] = entry[3][2] = 0.0f,
385 entry[3][3] = 1.0f;
386 return *this;
387 }
388 // Set from function arguments.
389 OdTrVisMatrix4x4Impl &set(DataType e00 = 1.0f, DataType e01 = 0.0f, DataType e02 = 0.0f, DataType e03 = 0.0f,
390 DataType e10 = 0.0f, DataType e11 = 1.0f, DataType e12 = 0.0f, DataType e13 = 0.0f,
391 DataType e20 = 0.0f, DataType e21 = 0.0f, DataType e22 = 1.0f, DataType e23 = 0.0f,
392 DataType e30 = 0.0f, DataType e31 = 0.0f, DataType e32 = 0.0f, DataType e33 = 1.0f)
393 {
394 entry[0][0] = e00; entry[0][1] = e01; entry[0][2] = e02; entry[0][3] = e03;
395 entry[1][0] = e10; entry[1][1] = e11; entry[1][2] = e12; entry[1][3] = e13;
396 entry[2][0] = e20; entry[2][1] = e21; entry[2][2] = e22; entry[2][3] = e23;
397 entry[3][0] = e30; entry[3][1] = e31; entry[3][2] = e32; entry[3][3] = e33;
398 return *this;
399 }
400 // Set to identity.
402 {
403 entry[0][0] = 1.0f; entry[0][1] = 0.0f; entry[0][2] = 0.0f; entry[0][3] = 0.0f;
404 entry[1][0] = 0.0f; entry[1][1] = 1.0f; entry[1][2] = 0.0f; entry[1][3] = 0.0f;
405 entry[2][0] = 0.0f; entry[2][1] = 0.0f; entry[2][2] = 1.0f; entry[2][3] = 0.0f;
406 entry[3][0] = 0.0f; entry[3][1] = 0.0f; entry[3][2] = 0.0f; entry[3][3] = 1.0f;
407 return *this;
408 }
409 // Get as Ge matrix
410 OdGeMatrix3d &get(OdGeMatrix3d &xMat, bool bTransposed = true) const
411 {
412 if (!bTransposed)
413 {
414 xMat.entry[0][0] = entry[0][0]; xMat.entry[0][1] = entry[0][1]; xMat.entry[0][2] = entry[0][2]; xMat.entry[0][3] = entry[0][3];
415 xMat.entry[1][0] = entry[1][0]; xMat.entry[1][1] = entry[1][1]; xMat.entry[1][2] = entry[1][2]; xMat.entry[1][3] = entry[1][3];
416 xMat.entry[2][0] = entry[2][0]; xMat.entry[2][1] = entry[2][1]; xMat.entry[2][2] = entry[2][2]; xMat.entry[2][3] = entry[2][3];
417 xMat.entry[3][0] = entry[3][0]; xMat.entry[3][1] = entry[3][1]; xMat.entry[3][2] = entry[3][2]; xMat.entry[3][3] = entry[3][3];
418 }
419 else
420 {
421 xMat.entry[0][0] = entry[0][0]; xMat.entry[1][0] = entry[0][1]; xMat.entry[2][0] = entry[0][2]; xMat.entry[3][0] = entry[0][3];
422 xMat.entry[0][1] = entry[1][0]; xMat.entry[1][1] = entry[1][1]; xMat.entry[2][1] = entry[1][2]; xMat.entry[3][1] = entry[1][3];
423 xMat.entry[0][2] = entry[2][0]; xMat.entry[1][2] = entry[2][1]; xMat.entry[2][2] = entry[2][2]; xMat.entry[3][2] = entry[2][3];
424 xMat.entry[0][3] = entry[3][0]; xMat.entry[1][3] = entry[3][1]; xMat.entry[2][3] = entry[3][2]; xMat.entry[3][3] = entry[3][3];
425 }
426 return xMat;
427 }
428 // Get as 3x3 matrix
430 {
431 xMat.entry[0][0] = entry[0][0]; xMat.entry[0][1] = entry[0][1]; xMat.entry[0][2] = entry[0][2];
432 xMat.entry[1][0] = entry[1][0]; xMat.entry[1][1] = entry[1][1]; xMat.entry[1][2] = entry[1][2];
433 xMat.entry[2][0] = entry[2][0]; xMat.entry[2][1] = entry[2][1]; xMat.entry[2][2] = entry[2][2];
434 return xMat;
435 }
438 return getSubMatrix(xMat);
439 }
440 // Getters.
441 const DataType *getArray(int nRow = 0) const { return entry[nRow]; }
442 DataType *getArray(int nRow = 0) { return entry[nRow]; }
443 DataType operator()(int i, int j) const { return entry[i][j]; }
444 // Matrix multiplication.
447 // First row.
448 rv.entry[0][0] = entry[0][0] * m.entry[0][0] + entry[1][0] * m.entry[0][1] + entry[2][0] * m.entry[0][2] + entry[3][0] * m.entry[0][3];
449 rv.entry[0][1] = entry[0][1] * m.entry[0][0] + entry[1][1] * m.entry[0][1] + entry[2][1] * m.entry[0][2] + entry[3][1] * m.entry[0][3];
450 rv.entry[0][2] = entry[0][2] * m.entry[0][0] + entry[1][2] * m.entry[0][1] + entry[2][2] * m.entry[0][2] + entry[3][2] * m.entry[0][3];
451 rv.entry[0][3] = entry[0][3] * m.entry[0][0] + entry[1][3] * m.entry[0][1] + entry[2][3] * m.entry[0][2] + entry[3][3] * m.entry[0][3];
452 // Second row.
453 rv.entry[1][0] = entry[0][0] * m.entry[1][0] + entry[1][0] * m.entry[1][1] + entry[2][0] * m.entry[1][2] + entry[3][0] * m.entry[1][3];
454 rv.entry[1][1] = entry[0][1] * m.entry[1][0] + entry[1][1] * m.entry[1][1] + entry[2][1] * m.entry[1][2] + entry[3][1] * m.entry[1][3];
455 rv.entry[1][2] = entry[0][2] * m.entry[1][0] + entry[1][2] * m.entry[1][1] + entry[2][2] * m.entry[1][2] + entry[3][2] * m.entry[1][3];
456 rv.entry[1][3] = entry[0][3] * m.entry[1][0] + entry[1][3] * m.entry[1][1] + entry[2][3] * m.entry[1][2] + entry[3][3] * m.entry[1][3];
457 // Third row.
458 rv.entry[2][0] = entry[0][0] * m.entry[2][0] + entry[1][0] * m.entry[2][1] + entry[2][0] * m.entry[2][2] + entry[3][0] * m.entry[2][3];
459 rv.entry[2][1] = entry[0][1] * m.entry[2][0] + entry[1][1] * m.entry[2][1] + entry[2][1] * m.entry[2][2] + entry[3][1] * m.entry[2][3];
460 rv.entry[2][2] = entry[0][2] * m.entry[2][0] + entry[1][2] * m.entry[2][1] + entry[2][2] * m.entry[2][2] + entry[3][2] * m.entry[2][3];
461 rv.entry[2][3] = entry[0][3] * m.entry[2][0] + entry[1][3] * m.entry[2][1] + entry[2][3] * m.entry[2][2] + entry[3][3] * m.entry[2][3];
462 // Fourth row.
463 rv.entry[3][0] = entry[0][0] * m.entry[3][0] + entry[1][0] * m.entry[3][1] + entry[2][0] * m.entry[3][2] + entry[3][0] * m.entry[3][3];
464 rv.entry[3][1] = entry[0][1] * m.entry[3][0] + entry[1][1] * m.entry[3][1] + entry[2][1] * m.entry[3][2] + entry[3][1] * m.entry[3][3];
465 rv.entry[3][2] = entry[0][2] * m.entry[3][0] + entry[1][2] * m.entry[3][1] + entry[2][2] * m.entry[3][2] + entry[3][2] * m.entry[3][3];
466 rv.entry[3][3] = entry[0][3] * m.entry[3][0] + entry[1][3] * m.entry[3][1] + entry[2][3] * m.entry[3][2] + entry[3][3] * m.entry[3][3];
467 // Return result matrix.
468 return rv;
469 }
471 { return *this = *this * m; }
472 // To be completely correct we must have inverse multiplication.
474 { return *this * OdTrVisMatrix4x4Impl(m).invert(); }
476 { return *this = *this * OdTrVisMatrix4x4Impl(m).invert(); }
477 // Inverse operator.
478 OdTrVisMatrix4x4Impl &invert(DataType eps = 1.e-8f)
479 { // Premultiplied coefficients.
480 const DataType a2323 = entry[2][2] * entry[3][3] - entry[2][3] * entry[3][2];
481 const DataType a1323 = entry[2][1] * entry[3][3] - entry[2][3] * entry[3][1];
482 const DataType a1223 = entry[2][1] * entry[3][2] - entry[2][2] * entry[3][1];
483 const DataType a0323 = entry[2][0] * entry[3][3] - entry[2][3] * entry[3][0];
484 const DataType a0223 = entry[2][0] * entry[3][2] - entry[2][2] * entry[3][0];
485 const DataType a0123 = entry[2][0] * entry[3][1] - entry[2][1] * entry[3][0];
486 const DataType a2313 = entry[1][2] * entry[3][3] - entry[1][3] * entry[3][2];
487 const DataType a1313 = entry[1][1] * entry[3][3] - entry[1][3] * entry[3][1];
488 const DataType a1213 = entry[1][1] * entry[3][2] - entry[1][2] * entry[3][1];
489 const DataType a2312 = entry[1][2] * entry[2][3] - entry[1][3] * entry[2][2];
490 const DataType a1312 = entry[1][1] * entry[2][3] - entry[1][3] * entry[2][1];
491 const DataType a1212 = entry[1][1] * entry[2][2] - entry[1][2] * entry[2][1];
492 const DataType a0313 = entry[1][0] * entry[3][3] - entry[1][3] * entry[3][0];
493 const DataType a0213 = entry[1][0] * entry[3][2] - entry[1][2] * entry[3][0];
494 const DataType a0312 = entry[1][0] * entry[2][3] - entry[1][3] * entry[2][0];
495 const DataType a0212 = entry[1][0] * entry[2][2] - entry[1][2] * entry[2][0];
496 const DataType a0113 = entry[1][0] * entry[3][1] - entry[1][1] * entry[3][0];
497 const DataType a0112 = entry[1][0] * entry[2][1] - entry[1][1] * entry[2][0];
498 // Compute determinant.
499 const DataType det = entry[0][0] * (entry[1][1] * a2323 - entry[1][2] * a1323 + entry[1][3] * a1223)
500 - entry[0][1] * (entry[1][0] * a2323 - entry[1][2] * a0323 + entry[1][3] * a0223)
501 + entry[0][2] * (entry[1][0] * a1323 - entry[1][1] * a0323 + entry[1][3] * a0123)
502 - entry[0][3] * (entry[1][0] * a1223 - entry[1][1] * a0223 + entry[1][2] * a0123);
503 if (det < eps)
504 transpose();
505 else
506 { const OdTrVisMatrix4x4Impl src(*this);
507 const DataType invdet = 1.0f / det;
508 entry[0][0] = invdet * (src.entry[1][1] * a2323 - src.entry[1][2] * a1323 + src.entry[1][3] * a1223);
509 entry[0][1] = invdet * -(src.entry[0][1] * a2323 - src.entry[0][2] * a1323 + src.entry[0][3] * a1223);
510 entry[0][2] = invdet * (src.entry[0][1] * a2313 - src.entry[0][2] * a1313 + src.entry[0][3] * a1213);
511 entry[0][3] = invdet * -(src.entry[0][1] * a2312 - src.entry[0][2] * a1312 + src.entry[0][3] * a1212);
512 entry[1][0] = invdet * -(src.entry[1][0] * a2323 - src.entry[1][2] * a0323 + src.entry[1][3] * a0223);
513 entry[1][1] = invdet * (src.entry[0][0] * a2323 - src.entry[0][2] * a0323 + src.entry[0][3] * a0223);
514 entry[1][2] = invdet * -(src.entry[0][0] * a2313 - src.entry[0][2] * a0313 + src.entry[0][3] * a0213);
515 entry[1][3] = invdet * (src.entry[0][0] * a2312 - src.entry[0][2] * a0312 + src.entry[0][3] * a0212);
516 entry[2][0] = invdet * (src.entry[1][0] * a1323 - src.entry[1][1] * a0323 + src.entry[1][3] * a0123);
517 entry[2][1] = invdet * -(src.entry[0][0] * a1323 - src.entry[0][1] * a0323 + src.entry[0][3] * a0123);
518 entry[2][2] = invdet * (src.entry[0][0] * a1313 - src.entry[0][1] * a0313 + src.entry[0][3] * a0113);
519 entry[2][3] = invdet * -(src.entry[0][0] * a1312 - src.entry[0][1] * a0312 + src.entry[0][3] * a0112);
520 entry[3][0] = invdet * -(src.entry[1][0] * a1223 - src.entry[1][1] * a0223 + src.entry[1][2] * a0123);
521 entry[3][1] = invdet * (src.entry[0][0] * a1223 - src.entry[0][1] * a0223 + src.entry[0][2] * a0123);
522 entry[3][2] = invdet * -(src.entry[0][0] * a1213 - src.entry[0][1] * a0213 + src.entry[0][2] * a0113);
523 entry[3][3] = invdet * (src.entry[0][0] * a1212 - src.entry[0][1] * a0212 + src.entry[0][2] * a0112);
524 }
525 return *this;
526 }
528 { return OdTrVisMatrix4x4Impl(*this).invert(); }
529 // Transpose operator.
531 { const OdTrVisMatrix4x4Impl src(*this);
532 entry[0][1] = src.entry[1][0];
533 entry[0][2] = src.entry[2][0];
534 entry[0][3] = src.entry[3][0];
535 entry[1][2] = src.entry[2][1];
536 entry[1][3] = src.entry[3][1];
537 entry[2][3] = src.entry[3][2];
538 // Second part.
539 entry[1][0] = src.entry[0][1];
540 entry[2][0] = src.entry[0][2];
541 entry[3][0] = src.entry[0][3];
542 entry[2][1] = src.entry[1][2];
543 entry[3][1] = src.entry[1][3];
544 entry[3][2] = src.entry[2][3];
545 return *this;
546 }
548 { return OdTrVisMatrix4x4Impl(*this).transpose(); }
549 // Translation operators.
550 template <typename VectorType>
551 static OdTrVisMatrix4x4Impl &translationMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &v, bool bNegate = false)
552 { DataType *pMat = m.setIdentity().getArray();
553 pMat[12] = v[0], pMat[13] = v[1], pMat[14] = v[2];
554 if (bNegate)
555 pMat[12] = -pMat[12], pMat[13] = -pMat[13], pMat[14] = -pMat[14];
556 return m;
557 }
558 template <typename VectorType>
559 OdTrVisMatrix4x4Impl operator +(const VectorType &v) const
561 return *this * translationMatrix(t, v);
562 }
563 template <typename VectorType>
566 return *this *= translationMatrix(t, v);
567 }
568 template <typename VectorType>
569 OdTrVisMatrix4x4Impl operator -(const VectorType &v) const
571 return *this * translationMatrix(t, v, true);
572 }
573 template <typename VectorType>
576 return *this *= translationMatrix(t, v, true);
577 }
578 // Translation getters.
580 { return OdTrVisMiniVec3d<DataType>(entry[3][0], entry[3][1], entry[3][2]); }
581 // Scale operators.
582 template <typename VectorType>
583 static OdTrVisMatrix4x4Impl &scaleMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &v, bool bInverse = false)
586 }
587 template <typename VectorType>
588 OdTrVisMatrix4x4Impl scale(const VectorType &v) const
590 return *this * scaleMatrix(s, v);
591 }
592 template <typename VectorType>
593 OdTrVisMatrix4x4Impl &setScale(const VectorType &v)
595 return *this * scaleMatrix(s, v);
596 }
597 template <typename VectorType>
598 OdTrVisMatrix4x4Impl recipScale(const VectorType &v) const
600 return *this * scaleMatrix(s, v, true);
601 }
602 template <typename VectorType>
605 return *this * scaleMatrix(s, v, true);
606 }
607 // Orthogonal scale.
608 static OdTrVisMatrix4x4Impl &scaleMatrix(OdTrVisMatrix4x4Impl &m, DataType s, bool bInverse = false)
611 }
614 return m * scaleMatrix(s, n);
615 }
618 return scaleMatrix(s, n) * m;
619 }
622 return *this *= scaleMatrix(s, n);
623 }
626 return m * scaleMatrix(s, n, true);
627 }
630 return scaleMatrix(s, n, true) * m;
631 }
634 return *this *= scaleMatrix(s, n, true);
635 }
636 // Rotation operators.
637 template <typename VectorType>
641 }
642 template <typename VectorType>
643 OdTrVisMatrix4x4Impl &localRotate(const VectorType &angles)
645 return *this *= rotationMatrix(r, angles); }
646 // This is more OpenGL-compatible version of rotation.
647 template <typename VectorType>
648 static OdTrVisMatrix4x4Impl &rotationMatrix(OdTrVisMatrix4x4Impl &m, DataType angle, const VectorType &v, DataType eps = 1.e-8f)
651 }
652 template <typename VectorType>
653 OdTrVisMatrix4x4Impl &rotate(DataType angle, const VectorType &v, DataType eps = 1.e-8f)
655 return *this *= rotationMatrix(r, angle, v, eps); }
656 // Rotation getters.
658 { return OdTrVisMiniVec3d<DataType>(entry[0][0], entry[1][0], entry[2][0]); }
660 { return OdTrVisMiniVec3d<DataType>(entry[0][1], entry[1][1], entry[2][1]); }
662 { return OdTrVisMiniVec3d<DataType>(entry[0][2], entry[1][2], entry[2][2]); }
663 // Vector transformation operators
664 template <typename VectorType>
665 VectorType &transform(VectorType &vec, DataType w = 1.0f) const
666 { return vec.set(entry[0][0] * vec.x + entry[1][0] * vec.y + entry[2][0] * vec.z + entry[3][0] * w,
667 entry[0][1] * vec.x + entry[1][1] * vec.y + entry[2][1] * vec.z + entry[3][1] * w,
668 entry[0][2] * vec.x + entry[1][2] * vec.y + entry[2][2] * vec.z + entry[3][2] * w); }
669 template <typename VectorType>
670 VectorType transformClone(const VectorType &vec, DataType w = 1.0f) const
671 { VectorType tmp(vec); return transform(tmp, w); }
672 template <typename VectorType>
673 friend VectorType operator *(const OdTrVisMatrix4x4Impl m, const VectorType &v)
674 { VectorType vec(v); return m.transform(vec); }
675 template <typename VectorType>
676 friend VectorType operator *(const VectorType &v, const OdTrVisMatrix4x4Impl m)
677 { VectorType vec(v); return m.transform(vec); }
678 // Inverse transformation
679 template <typename VectorType>
680 VectorType &untransform(VectorType &vec, DataType w = 1.0f) const
681 { return vec.set(entry[0][0] * vec.x + entry[0][1] * vec.y + entry[0][2] * vec.z + entry[0][3] * w,
682 entry[1][0] * vec.x + entry[1][1] * vec.y + entry[1][2] * vec.z + entry[1][3] * w,
683 entry[2][0] * vec.x + entry[2][1] * vec.y + entry[2][2] * vec.z + entry[2][3] * w); }
684 template <typename VectorType>
685 VectorType untransformClone(const VectorType &vec, DataType w = 1.0f) const
686 { VectorType tmp(vec); return untransform(tmp, w); }
687 template <typename VectorType>
688 friend VectorType operator ^(const OdTrVisMatrix4x4Impl m, const VectorType &v)
689 { VectorType vec(v); return m.untransform(vec); }
690 template <typename VectorType>
691 friend VectorType operator ^(const VectorType &v, const OdTrVisMatrix4x4Impl m)
692 { VectorType vec(v); return m.untransform(vec); }
693 // Setup matrix to look at specified point.
694 template <typename VectorType, typename VectorType2>
695 static OdTrVisMatrix4x4Impl &lookAtMatrix(OdTrVisMatrix4x4Impl &l, const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps = 1.e-8f)
696 { OdTrVisMiniVec3d<DataType> Xx, Yy, Zz, Ee((DataType)eye[0], (DataType)eye[1], (DataType)eye[2]);
697 // Compute necessary vectors.
698 Zz = -(Ee - OdTrVisMiniVec3d<DataType>((DataType)center[0], (DataType)center[1], (DataType)center[2]));
699 Yy.set((DataType)up[0], (DataType)up[1], (DataType)up[2]);
700 Xx = Yy ^ Zz;
701 Yy = Zz ^ Xx;
702 Xx = Xx.normalize(eps);
703 Yy = Yy.normalize(eps);
704 Zz = Zz.normalize(eps);
705 // Result rotation.
706 l.entry[0][0] = -Xx.x; l.entry[0][1] = -Yy.x; l.entry[0][2] = -Zz.x; l.entry[0][3] = 0.0f;
707 l.entry[1][0] = -Xx.y; l.entry[1][1] = -Yy.y; l.entry[1][2] = -Zz.y; l.entry[1][3] = 0.0f;
708 l.entry[2][0] = -Xx.z; l.entry[2][1] = -Yy.z; l.entry[2][2] = -Zz.z; l.entry[2][3] = 0.0f;
709 // Result translation.
710 l.entry[3][0] = Ee * Xx; l.entry[3][1] = Ee * Yy; l.entry[3][2] = Ee * Zz; l.entry[3][3] = 1.0f;
711 return l;
712 }
713 template <typename VectorType, typename VectorType2>
714 OdTrVisMatrix4x4Impl &lookAt(const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps = 1.e-8f)
716 return *this *= lookAtMatrix(l, eye, center, up, eps);
717 }
718 // Orthographic projection.
719 static OdTrVisMatrix4x4Impl &orthoMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
720 {
721 m.entry[0][0] = 2.0f / (right - left); m.entry[0][1] = 0.0f; m.entry[0][2] = 0.0f; m.entry[0][3] = (right + left) / (right - left);
722 m.entry[1][0] = 0.0f; m.entry[1][1] = 2.0f / (top - bottom); m.entry[1][2] = 0.0f; m.entry[1][3] = (top + bottom) / (top - bottom);
723 m.entry[2][0] = 0.0f; m.entry[2][1] = 0.0f; m.entry[2][2] = -2.0f / (far_ - near_); m.entry[2][3] = -(far_ + near_) / (far_ - near_);
724 m.entry[3][0] = 0.0f; m.entry[3][1] = 0.0f; m.entry[3][2] = 0.0f; m.entry[3][3] = 1.0f;
725 return m;
726 }
727 OdTrVisMatrix4x4Impl &ortho(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
729 return *this *= orthoMatrix(o, left, right, bottom, top, near_, far_); }
730 OdTrVisMatrix4x4Impl &ortho2d(DataType left, DataType right, DataType bottom, DataType top)
732 return *this *= orthoMatrix(o, left, right, bottom, top, -1.0f, 1.0f); }
733 // Perspective projection (frustum).
734 static OdTrVisMatrix4x4Impl &frustumMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
735 { DataType *v = m.getArray();
736 if (near_ <= 0.0f || far_ <= 0.0f)
737 return m.setIdentity();
738 const DataType x = (2.0f * near_) / (right - left);
739 const DataType y = (2.0f * near_) / (top - bottom);
740 const DataType a = (right + left) / (right - left);
741 const DataType b = (top + bottom) / (top - bottom);
742 const DataType c = -(far_ + near_) / (far_ - near_);
743 const DataType d = -(2.0f * far_ * near_) / (far_ - near_);
744 v[0] = x; v[1] = 0.0f; v[2] = 0.0f; v[3] = 0.0f;
745 v[4] = 0.0f; v[5] = y; v[6] = 0.0f; v[7] = 0.0f;
746 v[8] = a; v[9] = b; v[10] = c; v[11] = -1.0f;
747 v[12] = 0.0f; v[13] = 0.0f; v[14] = d; v[15] = 0.0f;
748 return m;
749 }
750 OdTrVisMatrix4x4Impl &frustum(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
752 return *this *= frustumMatrix(f, left, right, bottom, top, near_, far_); }
753 // Perspective projection.
754 static OdTrVisMatrix4x4Impl &perspectiveMatrix(OdTrVisMatrix4x4Impl &m, DataType fov, DataType aspect, DataType near_, DataType far_)
755 {
756 if (fabs(near_ - far_) < 0.001f)
757 return m.setIdentity();
758 if (fabs(sin(fov / 2.0f)) < 0.001f)
759 return m.setIdentity();
760 const DataType h = cos(fov / 2.0f) / sin(fov / 2.0f);
761 const DataType w = aspect * h;
762 const DataType Q = far_ / (far_ - near_);
763 m.entry[0][0] = w; m.entry[0][1] = 0.0f; m.entry[0][2] = 0.0f; m.entry[0][3] = 0.0f;
764 m.entry[1][0] = 0.0f; m.entry[1][1] = h; m.entry[1][2] = 0.0f; m.entry[1][3] = 0.0f;
765 m.entry[2][0] = 0.0f; m.entry[2][1] = 0.0f; m.entry[2][2] = Q; m.entry[2][3] = 1.0f;
766 m.entry[3][0] = 0.0f; m.entry[3][1] = 0.0f; m.entry[3][2] = -Q * near_; m.entry[3][3] = 0.0f;
767 return m;
768 }
769 OdTrVisMatrix4x4Impl &perspective(DataType fov, DataType aspect, DataType near_, DataType far_)
771 return *this *= perspectiveMatrix(p, fov, aspect, near_, far_); }
772 OdTrVisMatrix4x4Impl &perspective2a(DataType fovX, DataType fovY, DataType near_, DataType far_)
774 return *this *= perspectiveMatrix(p, fovY, fovX / fovY, near_, far_); }
775};
776
777// Type definitions.
778
781
784
785// Current main matrix definition.
786
789
791
792#include "TD_PackPop.h"
793
794#endif // ODTRVISMATRIX
OdTrVisMatrix4x4f OdTrVisMatrix
Definition: TrVisMatrix.h:787
OdTrVisMatrix3x3Impl< double > OdTrVisMatrix3x3d
Definition: TrVisMatrix.h:780
OdTrVisMatrix3x3f OdTrVisSubMat
Definition: TrVisMatrix.h:788
OdTrVisMatrix4x4Impl< double > OdTrVisMatrix4x4d
Definition: TrVisMatrix.h:783
OdArray< OdTrVisMatrix, OdMemoryAllocator< OdTrVisMatrix > > OdTrVisMatrixArray
Definition: TrVisMatrix.h:790
OdTrVisMatrix4x4Impl< float > OdTrVisMatrix4x4f
Definition: TrVisMatrix.h:782
OdTrVisMatrix3x3Impl< float > OdTrVisMatrix3x3f
Definition: TrVisMatrix.h:779
double entry[4][4]
Definition: GeMatrix3d.h:852
GLfloat f
Definition: gles2_ext.h:564
GLfloat GLfloat GLfloat z
Definition: gles2_ext.h:318
GLfloat GLfloat GLfloat GLfloat w
Definition: gles2_ext.h:320
const GLfloat * v
Definition: gles2_ext.h:315
GLfloat x
Definition: gles2_ext.h:314
GLfloat GLfloat y
Definition: gles2_ext.h:316
OdTrVisMatDefVecTypeAdaptor(const VectorType &vec)
Definition: TrVisMatrix.h:43
DataType operator[](int nAxis) const
Definition: TrVisMatrix.h:44
const VectorType & _vec
Definition: TrVisMatrix.h:42
static void copy(DataType *pTo, const DataType *pFrom)
Definition: TrVisMatrix.h:60
OdTrVisMatrix3x3Impl & operator/=(DataType n)
Definition: TrVisMatrix.h:213
static OdTrVisMatrix3x3Impl & scaleMatrix(OdTrVisMatrix3x3Impl &m, DataType s, bool bInverse=false)
Definition: TrVisMatrix.h:185
OdTrVisMatrix3x3Impl & set(DataType e00=1.0f, DataType e01=0.0f, DataType e02=0.0f, DataType e10=0.0f, DataType e11=1.0f, DataType e12=0.0f, DataType e20=0.0f, DataType e21=0.0f, DataType e22=1.0f)
Definition: TrVisMatrix.h:72
OdTrVisMatrix3x3Impl operator~() const
Definition: TrVisMatrix.h:142
OdTrVisMatrix3x3Impl & rotate(DataType angle, const VectorType &v, const DataType eps=1.e-8f)
Definition: TrVisMatrix.h:275
static OdTrVisMatrix3x3Impl & localRotationMatrix(OdTrVisMatrix3x3Impl &m, const VectorType &angles)
Definition: TrVisMatrix.h:219
static OdTrVisMatrix3x3Impl & scaleMatrix(OdTrVisMatrix3x3Impl &m, const VectorType &v, bool bInverse=false)
Definition: TrVisMatrix.h:156
OdTrVisMatrix3x3Impl & setScale(const VectorType &v)
Definition: TrVisMatrix.h:170
OdTrVisMatrix3x3Impl & operator^=(const OdTrVisMatrix3x3Impl &m)
Definition: TrVisMatrix.h:118
OdTrVisMatrix3x3Impl & setRecipScale(const VectorType &v)
Definition: TrVisMatrix.h:180
DataType * getArray(int nRow=0)
Definition: TrVisMatrix.h:91
OdTrVisMatrix3x3Impl & set(const DataType *pVals)
Definition: TrVisMatrix.h:64
OdTrVisMatrix3x3Impl & localRotate(const VectorType &angles)
Definition: TrVisMatrix.h:239
OdTrVisMatrix3x3Impl operator-() const
Definition: TrVisMatrix.h:152
VectorType transformClone(const VectorType &vec, DataType=0.0f) const
Definition: TrVisMatrix.h:299
DataType operator()(int i, int j) const
Definition: TrVisMatrix.h:92
OdTrVisMatrix3x3Impl recipScale(const VectorType &v) const
Definition: TrVisMatrix.h:175
OdTrVisMatrix3x3Impl & setIdentity()
Definition: TrVisMatrix.h:82
friend OdTrVisMatrix3x3Impl operator/(const OdTrVisMatrix3x3Impl &m, DataType n)
Definition: TrVisMatrix.h:205
static OdTrVisMatrix3x3Impl & rotationMatrix(OdTrVisMatrix3x3Impl &m, DataType angle, const VectorType &v, const DataType eps=1.e-8f)
Definition: TrVisMatrix.h:244
DataType entry[3][3]
Definition: TrVisMatrix.h:55
OdTrVisMatrix3x3Impl scale(const VectorType &v) const
Definition: TrVisMatrix.h:165
OdTrVisMiniVec3d< DataType > getScale() const
Definition: TrVisMatrix.h:288
OdTrVisMatrix3x3Impl & operator*=(const OdTrVisMatrix3x3Impl &m)
Definition: TrVisMatrix.h:107
friend OdTrVisMatrix3x3Impl operator*(const OdTrVisMatrix3x3Impl &m, DataType n)
Definition: TrVisMatrix.h:193
VectorType & transform(VectorType &vec, DataType=0.0f) const
Definition: TrVisMatrix.h:294
OdTrVisMiniVec3d< DataType > row(int n) const
Definition: TrVisMatrix.h:94
VectorType untransformClone(const VectorType &vec, DataType=0.0f) const
Definition: TrVisMatrix.h:314
VectorType & untransform(VectorType &vec, DataType=0.0f) const
Definition: TrVisMatrix.h:309
const DataType * getArray(int nRow=0) const
Definition: TrVisMatrix.h:90
friend VectorType operator^(const OdTrVisMatrix3x3Impl m, const VectorType &v)
Definition: TrVisMatrix.h:317
OdTrVisMiniVec3d< DataType > column(int n) const
Definition: TrVisMatrix.h:96
OdTrVisMatrix3x3Impl & invert(const DataType eps=1.e-8f)
Definition: TrVisMatrix.h:121
OdTrVisMatrix3x3Impl & transpose()
Definition: TrVisMatrix.h:145
static void copy(DataType *pTo, const DataType *pFrom)
Definition: TrVisMatrix.h:337
static OdTrVisMatrix4x4Impl & localRotationMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &angles)
Definition: TrVisMatrix.h:638
VectorType transformClone(const VectorType &vec, DataType w=1.0f) const
Definition: TrVisMatrix.h:670
OdTrVisMiniVec3d< DataType > getRotationZAxis() const
Definition: TrVisMatrix.h:661
OdTrVisMatrix4x4Impl & operator*=(const OdTrVisMatrix4x4Impl &m)
Definition: TrVisMatrix.h:470
static OdTrVisMatrix4x4Impl & lookAtMatrix(OdTrVisMatrix4x4Impl &l, const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps=1.e-8f)
Definition: TrVisMatrix.h:695
OdTrVisMatrix4x4Impl operator-() const
Definition: TrVisMatrix.h:547
OdTrVisMatrix4x4Impl & set(const OdGeMatrix3d &xMat, bool bTransposed=true)
Definition: TrVisMatrix.h:350
OdTrVisMatrix4x4Impl & rotate(DataType angle, const VectorType &v, DataType eps=1.e-8f)
Definition: TrVisMatrix.h:653
DataType entry[4][4]
Definition: TrVisMatrix.h:332
OdTrVisMiniVec3d< DataType > getRotationXAxis() const
Definition: TrVisMatrix.h:657
OdTrVisMatrix4x4Impl & operator/=(DataType n)
Definition: TrVisMatrix.h:632
OdTrVisMiniVec3d< DataType > getTranslation() const
Definition: TrVisMatrix.h:579
OdTrVisMatrix4x4Impl & invert(DataType eps=1.e-8f)
Definition: TrVisMatrix.h:478
const DataType * getArray(int nRow=0) const
Definition: TrVisMatrix.h:441
OdTrVisMatrix4x4Impl & setRecipScale(const VectorType &v)
Definition: TrVisMatrix.h:603
OdTrVisMatrix4x4Impl scale(const VectorType &v) const
Definition: TrVisMatrix.h:588
static OdTrVisMatrix4x4Impl & scaleMatrix(OdTrVisMatrix4x4Impl &m, DataType s, bool bInverse=false)
Definition: TrVisMatrix.h:608
OdTrVisMatrix4x4Impl & operator+=(const VectorType &v)
Definition: TrVisMatrix.h:564
OdTrVisMatrix4x4Impl recipScale(const VectorType &v) const
Definition: TrVisMatrix.h:598
DataType operator()(int i, int j) const
Definition: TrVisMatrix.h:443
friend OdTrVisMatrix4x4Impl operator*(const OdTrVisMatrix4x4Impl &m, DataType n)
Definition: TrVisMatrix.h:612
OdTrVisMatrix4x4Impl & ortho2d(DataType left, DataType right, DataType bottom, DataType top)
Definition: TrVisMatrix.h:730
OdTrVisMatrix4x4Impl operator+(const VectorType &v) const
Definition: TrVisMatrix.h:559
OdTrVisMatrix4x4Impl & operator-=(const VectorType &v)
Definition: TrVisMatrix.h:574
OdTrVisMatrix4x4Impl & set(const DataType *pVals)
Definition: TrVisMatrix.h:341
VectorType & untransform(VectorType &vec, DataType w=1.0f) const
Definition: TrVisMatrix.h:680
OdTrVisMatrix4x4Impl & lookAt(const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps=1.e-8f)
Definition: TrVisMatrix.h:714
OdGeMatrix3d & get(OdGeMatrix3d &xMat, bool bTransposed=true) const
Definition: TrVisMatrix.h:410
OdTrVisMatrix4x4Impl & localRotate(const VectorType &angles)
Definition: TrVisMatrix.h:643
OdTrVisMatrix4x4Impl & perspective(DataType fov, DataType aspect, DataType near_, DataType far_)
Definition: TrVisMatrix.h:769
friend VectorType operator^(const OdTrVisMatrix4x4Impl m, const VectorType &v)
Definition: TrVisMatrix.h:688
OdTrVisMatrix4x4Impl & operator^=(const OdTrVisMatrix4x4Impl &m)
Definition: TrVisMatrix.h:475
VectorType & transform(VectorType &vec, DataType w=1.0f) const
Definition: TrVisMatrix.h:665
OdTrVisMatrix4x4Impl & set(DataType e00=1.0f, DataType e01=0.0f, DataType e02=0.0f, DataType e03=0.0f, DataType e10=0.0f, DataType e11=1.0f, DataType e12=0.0f, DataType e13=0.0f, DataType e20=0.0f, DataType e21=0.0f, DataType e22=1.0f, DataType e23=0.0f, DataType e30=0.0f, DataType e31=0.0f, DataType e32=0.0f, DataType e33=1.0f)
Definition: TrVisMatrix.h:389
OdTrVisMatrix3x3Impl< DataType > & getSubMatrix(OdTrVisMatrix3x3Impl< DataType > &xMat) const
Definition: TrVisMatrix.h:429
static OdTrVisMatrix4x4Impl & frustumMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
Definition: TrVisMatrix.h:734
OdTrVisMatrix3x3Impl< DataType > getSubMatrix() const
Definition: TrVisMatrix.h:436
static OdTrVisMatrix4x4Impl & translationMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &v, bool bNegate=false)
Definition: TrVisMatrix.h:551
OdTrVisMatrix4x4Impl & frustum(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
Definition: TrVisMatrix.h:750
OdTrVisMiniVec3d< DataType > getRotationYAxis() const
Definition: TrVisMatrix.h:659
OdTrVisMatrix4x4Impl & set(const OdTrVisMatrix3x3Impl< DataType > &xMat, bool bExtend=false)
Definition: TrVisMatrix.h:377
VectorType untransformClone(const VectorType &vec, DataType w=1.0f) const
Definition: TrVisMatrix.h:685
friend OdTrVisMatrix4x4Impl operator/(const OdTrVisMatrix4x4Impl &m, DataType n)
Definition: TrVisMatrix.h:624
static OdTrVisMatrix4x4Impl & rotationMatrix(OdTrVisMatrix4x4Impl &m, DataType angle, const VectorType &v, DataType eps=1.e-8f)
Definition: TrVisMatrix.h:648
static OdTrVisMatrix4x4Impl & orthoMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
Definition: TrVisMatrix.h:719
OdTrVisMatrix4x4Impl operator~() const
Definition: TrVisMatrix.h:527
OdTrVisMatrix4x4Impl & setScale(const VectorType &v)
Definition: TrVisMatrix.h:593
OdTrVisMatrix4x4Impl & perspective2a(DataType fovX, DataType fovY, DataType near_, DataType far_)
Definition: TrVisMatrix.h:772
DataType * getArray(int nRow=0)
Definition: TrVisMatrix.h:442
static OdTrVisMatrix4x4Impl & perspectiveMatrix(OdTrVisMatrix4x4Impl &m, DataType fov, DataType aspect, DataType near_, DataType far_)
Definition: TrVisMatrix.h:754
OdTrVisMatrix4x4Impl & transpose()
Definition: TrVisMatrix.h:530
OdTrVisMatrix4x4Impl & ortho(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
Definition: TrVisMatrix.h:727
static OdTrVisMatrix4x4Impl & scaleMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &v, bool bInverse=false)
Definition: TrVisMatrix.h:583
OdTrVisMatrix4x4Impl & setIdentity()
Definition: TrVisMatrix.h:401
OdTrVisMiniVec3d & normalize(DataType eps=1.e-8f)
Definition: TrVisVector.h:252
OdTrVisMiniVec3d & set(DataType _x, DataType _y, DataType _z)
Definition: TrVisVector.h:169