CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
TrVisMatrix.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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 }
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 }
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 }
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.
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 }
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 }
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.
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>
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.
663
664 template <typename VectorDataType = DataType>
666 {
668 static_cast<VectorDataType>(entry[0][0]),
669 static_cast<VectorDataType>(entry[1][0]),
670 static_cast<VectorDataType>(entry[2][0]),
671 static_cast<VectorDataType>(entry[3][0]));
672 }
673 template <typename VectorDataType = DataType>
675 {
677 static_cast<VectorDataType>(entry[0][1]),
678 static_cast<VectorDataType>(entry[1][1]),
679 static_cast<VectorDataType>(entry[2][1]),
680 static_cast<VectorDataType>(entry[3][1]));
681 }
682 template <typename VectorDataType = DataType>
684 {
686 static_cast<VectorDataType>(entry[0][2]),
687 static_cast<VectorDataType>(entry[1][2]),
688 static_cast<VectorDataType>(entry[2][2]),
689 static_cast<VectorDataType>(entry[3][2]));
690 }
691 template <typename VectorDataType = DataType>
693 {
695 static_cast<VectorDataType>(entry[0][3]),
696 static_cast<VectorDataType>(entry[1][3]),
697 static_cast<VectorDataType>(entry[2][3]),
698 static_cast<VectorDataType>(entry[3][3]));
699 }
700
701 // Vector transformation operators
702 template <typename VectorType>
703 VectorType &transform(VectorType &vec, DataType w = 1.0f) const
704 { return vec.set(entry[0][0] * vec.x + entry[1][0] * vec.y + entry[2][0] * vec.z + entry[3][0] * w,
705 entry[0][1] * vec.x + entry[1][1] * vec.y + entry[2][1] * vec.z + entry[3][1] * w,
706 entry[0][2] * vec.x + entry[1][2] * vec.y + entry[2][2] * vec.z + entry[3][2] * w); }
707
708 template <typename VectorDataType>
710 { return vec.set(entry[0][0] * vec.x + entry[1][0] * vec.y + entry[2][0] * vec.z + entry[3][0] * vec.w,
711 entry[0][1] * vec.x + entry[1][1] * vec.y + entry[2][1] * vec.z + entry[3][1] * vec.w,
712 entry[0][2] * vec.x + entry[1][2] * vec.y + entry[2][2] * vec.z + entry[3][2] * vec.w,
713 entry[0][3] * vec.x + entry[1][3] * vec.y + entry[2][3] * vec.z + entry[3][2] * vec.w); }
714
715 template <typename VectorType>
716 VectorType transformClone(const VectorType &vec, DataType w = 1.0f) const
717 { VectorType tmp(vec); return transform(tmp, w); }
718 template <typename VectorType>
719 friend VectorType operator *(const OdTrVisMatrix4x4Impl m, const VectorType &v)
720 { VectorType vec(v); return m.transform(vec); }
721 template <typename VectorType>
722 friend VectorType operator *(const VectorType &v, const OdTrVisMatrix4x4Impl m)
723 { VectorType vec(v); return m.transform(vec); }
724 // Inverse transformation
725 template <typename VectorType>
726 VectorType &untransform(VectorType &vec, DataType w = 1.0f) const
727 { return vec.set(entry[0][0] * vec.x + entry[0][1] * vec.y + entry[0][2] * vec.z + entry[0][3] * w,
728 entry[1][0] * vec.x + entry[1][1] * vec.y + entry[1][2] * vec.z + entry[1][3] * w,
729 entry[2][0] * vec.x + entry[2][1] * vec.y + entry[2][2] * vec.z + entry[2][3] * w); }
730 template <typename VectorType>
731 VectorType untransformClone(const VectorType &vec, DataType w = 1.0f) const
732 { VectorType tmp(vec); return untransform(tmp, w); }
733 template <typename VectorType>
734 friend VectorType operator ^(const OdTrVisMatrix4x4Impl m, const VectorType &v)
735 { VectorType vec(v); return m.untransform(vec); }
736 template <typename VectorType>
737 friend VectorType operator ^(const VectorType &v, const OdTrVisMatrix4x4Impl m)
738 { VectorType vec(v); return m.untransform(vec); }
739 // Setup matrix to look at specified point.
740 template <typename VectorType, typename VectorType2>
741 static OdTrVisMatrix4x4Impl &lookAtMatrix(OdTrVisMatrix4x4Impl &l, const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps = 1.e-8f)
742 { OdTrVisMiniVec3d<DataType> Xx, Yy, Zz, Ee((DataType)eye[0], (DataType)eye[1], (DataType)eye[2]);
743 // Compute necessary vectors.
744 Zz = -(Ee - OdTrVisMiniVec3d<DataType>((DataType)center[0], (DataType)center[1], (DataType)center[2]));
745 Yy.set((DataType)up[0], (DataType)up[1], (DataType)up[2]);
746 Xx = Yy ^ Zz;
747 Yy = Zz ^ Xx;
748 Xx = Xx.normalize(eps);
749 Yy = Yy.normalize(eps);
750 Zz = Zz.normalize(eps);
751 // Result rotation.
752 l.entry[0][0] = -Xx.x; l.entry[0][1] = -Yy.x; l.entry[0][2] = -Zz.x; l.entry[0][3] = 0.0f;
753 l.entry[1][0] = -Xx.y; l.entry[1][1] = -Yy.y; l.entry[1][2] = -Zz.y; l.entry[1][3] = 0.0f;
754 l.entry[2][0] = -Xx.z; l.entry[2][1] = -Yy.z; l.entry[2][2] = -Zz.z; l.entry[2][3] = 0.0f;
755 // Result translation.
756 l.entry[3][0] = Ee * Xx; l.entry[3][1] = Ee * Yy; l.entry[3][2] = Ee * Zz; l.entry[3][3] = 1.0f;
757 return l;
758 }
759 template <typename VectorType, typename VectorType2>
760 OdTrVisMatrix4x4Impl &lookAt(const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps = 1.e-8f)
762 return *this *= lookAtMatrix(l, eye, center, up, eps);
763 }
764 // Orthographic projection.
765 static OdTrVisMatrix4x4Impl &orthoMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
766 {
767 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);
768 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);
769 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_);
770 m.entry[3][0] = 0.0f; m.entry[3][1] = 0.0f; m.entry[3][2] = 0.0f; m.entry[3][3] = 1.0f;
771 return m;
772 }
773 OdTrVisMatrix4x4Impl &ortho(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
775 return *this *= orthoMatrix(o, left, right, bottom, top, near_, far_); }
776 OdTrVisMatrix4x4Impl &ortho2d(DataType left, DataType right, DataType bottom, DataType top)
778 return *this *= orthoMatrix(o, left, right, bottom, top, -1.0f, 1.0f); }
779 // Perspective projection (frustum).
780 static OdTrVisMatrix4x4Impl &frustumMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
781 { DataType *v = m.getArray();
782 if (near_ <= 0.0f || far_ <= 0.0f)
783 return m.setIdentity();
784 const DataType x = (2.0f * near_) / (right - left);
785 const DataType y = (2.0f * near_) / (top - bottom);
786 const DataType a = (right + left) / (right - left);
787 const DataType b = (top + bottom) / (top - bottom);
788 const DataType c = -(far_ + near_) / (far_ - near_);
789 const DataType d = -(2.0f * far_ * near_) / (far_ - near_);
790 v[0] = x; v[1] = 0.0f; v[2] = 0.0f; v[3] = 0.0f;
791 v[4] = 0.0f; v[5] = y; v[6] = 0.0f; v[7] = 0.0f;
792 v[8] = a; v[9] = b; v[10] = c; v[11] = -1.0f;
793 v[12] = 0.0f; v[13] = 0.0f; v[14] = d; v[15] = 0.0f;
794 return m;
795 }
796 OdTrVisMatrix4x4Impl &frustum(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
798 return *this *= frustumMatrix(f, left, right, bottom, top, near_, far_); }
799 // Perspective projection.
800 static OdTrVisMatrix4x4Impl &perspectiveMatrix(OdTrVisMatrix4x4Impl &m, DataType fov, DataType aspect, DataType near_, DataType far_)
801 {
802 if (fabs(near_ - far_) < 0.001f)
803 return m.setIdentity();
804 if (fabs(sin(fov / 2.0f)) < 0.001f)
805 return m.setIdentity();
806 const DataType h = cos(fov / 2.0f) / sin(fov / 2.0f);
807 const DataType w = aspect * h;
808 const DataType Q = far_ / (far_ - near_);
809 m.entry[0][0] = w; m.entry[0][1] = 0.0f; m.entry[0][2] = 0.0f; m.entry[0][3] = 0.0f;
810 m.entry[1][0] = 0.0f; m.entry[1][1] = h; m.entry[1][2] = 0.0f; m.entry[1][3] = 0.0f;
811 m.entry[2][0] = 0.0f; m.entry[2][1] = 0.0f; m.entry[2][2] = Q; m.entry[2][3] = 1.0f;
812 m.entry[3][0] = 0.0f; m.entry[3][1] = 0.0f; m.entry[3][2] = -Q * near_; m.entry[3][3] = 0.0f;
813 return m;
814 }
815 OdTrVisMatrix4x4Impl &perspective(DataType fov, DataType aspect, DataType near_, DataType far_)
817 return *this *= perspectiveMatrix(p, fov, aspect, near_, far_); }
818 OdTrVisMatrix4x4Impl &perspective2a(DataType fovX, DataType fovY, DataType near_, DataType far_)
820 return *this *= perspectiveMatrix(p, fovY, fovX / fovY, near_, far_); }
821};
822
823// Type definitions.
824
827
830
831// Current main matrix definition.
832
835
837
838#include "TD_PackPop.h"
839
840#endif // ODTRVISMATRIX
OdTrVisMatrix4x4f OdTrVisMatrix
OdTrVisMatrix3x3Impl< double > OdTrVisMatrix3x3d
OdTrVisMatrix3x3f OdTrVisSubMat
OdTrVisMatrix4x4Impl< double > OdTrVisMatrix4x4d
OdArray< OdTrVisMatrix, OdMemoryAllocator< OdTrVisMatrix > > OdTrVisMatrixArray
OdTrVisMatrix4x4Impl< float > OdTrVisMatrix4x4f
OdTrVisMatrix3x3Impl< float > OdTrVisMatrix3x3f
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)
static OdTrVisMatrix3x3Impl & scaleMatrix(OdTrVisMatrix3x3Impl &m, DataType s, bool bInverse=false)
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
OdTrVisMatrix3x3Impl & rotate(DataType angle, const VectorType &v, const DataType eps=1.e-8f)
static OdTrVisMatrix3x3Impl & localRotationMatrix(OdTrVisMatrix3x3Impl &m, const VectorType &angles)
static OdTrVisMatrix3x3Impl & scaleMatrix(OdTrVisMatrix3x3Impl &m, const VectorType &v, bool bInverse=false)
OdTrVisMatrix3x3Impl & setScale(const VectorType &v)
OdTrVisMatrix3x3Impl & operator^=(const OdTrVisMatrix3x3Impl &m)
OdTrVisMatrix3x3Impl operator^(const OdTrVisMatrix3x3Impl &m) const
OdTrVisMatrix3x3Impl & setRecipScale(const VectorType &v)
DataType * getArray(int nRow=0)
Definition TrVisMatrix.h:91
OdTrVisMatrix3x3Impl & set(const DataType *pVals)
Definition TrVisMatrix.h:64
OdTrVisMatrix3x3Impl & localRotate(const VectorType &angles)
OdTrVisMatrix3x3Impl operator-() const
VectorType transformClone(const VectorType &vec, DataType=0.0f) const
DataType operator()(int i, int j) const
Definition TrVisMatrix.h:92
OdTrVisMatrix3x3Impl recipScale(const VectorType &v) const
OdTrVisMatrix3x3Impl & setIdentity()
Definition TrVisMatrix.h:82
friend OdTrVisMatrix3x3Impl operator/(const OdTrVisMatrix3x3Impl &m, DataType n)
OdTrVisMatrix3x3Impl operator*(const OdTrVisMatrix3x3Impl &m) const
Definition TrVisMatrix.h:99
static OdTrVisMatrix3x3Impl & rotationMatrix(OdTrVisMatrix3x3Impl &m, DataType angle, const VectorType &v, const DataType eps=1.e-8f)
OdTrVisMatrix3x3Impl scale(const VectorType &v) const
OdTrVisMiniVec3d< DataType > getScale() const
OdTrVisMatrix3x3Impl & operator*=(const OdTrVisMatrix3x3Impl &m)
VectorType & transform(VectorType &vec, DataType=0.0f) const
OdTrVisMiniVec3d< DataType > row(int n) const
Definition TrVisMatrix.h:94
VectorType untransformClone(const VectorType &vec, DataType=0.0f) const
VectorType & untransform(VectorType &vec, DataType=0.0f) const
const DataType * getArray(int nRow=0) const
Definition TrVisMatrix.h:90
OdTrVisMiniVec3d< DataType > column(int n) const
Definition TrVisMatrix.h:96
OdTrVisMatrix3x3Impl & invert(const DataType eps=1.e-8f)
OdTrVisMatrix3x3Impl & transpose()
static void copy(DataType *pTo, const DataType *pFrom)
static OdTrVisMatrix4x4Impl & localRotationMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &angles)
VectorType transformClone(const VectorType &vec, DataType w=1.0f) const
OdTrVisMiniVec4d< VectorDataType > getRotationXAxis4() const
OdTrVisMiniVec3d< DataType > getRotationZAxis() const
OdTrVisMatrix4x4Impl & operator*=(const OdTrVisMatrix4x4Impl &m)
OdTrVisMiniVec4d< VectorDataType > getTranslation4() const
static OdTrVisMatrix4x4Impl & lookAtMatrix(OdTrVisMatrix4x4Impl &l, const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps=1.e-8f)
OdTrVisMatrix4x4Impl operator-() const
OdTrVisMatrix4x4Impl & set(const OdGeMatrix3d &xMat, bool bTransposed=true)
OdTrVisMatrix4x4Impl & rotate(DataType angle, const VectorType &v, DataType eps=1.e-8f)
OdTrVisMiniVec4d< VectorDataType > & transform(OdTrVisMiniVec4d< VectorDataType > &vec)
OdTrVisMiniVec3d< DataType > getRotationXAxis() const
OdTrVisMiniVec4d< VectorDataType > getRotationYAxis4() const
OdTrVisMatrix4x4Impl & operator/=(DataType n)
OdTrVisMiniVec3d< DataType > getTranslation() const
OdTrVisMatrix4x4Impl & invert(DataType eps=1.e-8f)
OdTrVisMiniVec4d< VectorDataType > getRotationZAxis4() const
const DataType * getArray(int nRow=0) const
OdTrVisMatrix4x4Impl & setRecipScale(const VectorType &v)
OdTrVisMatrix4x4Impl scale(const VectorType &v) const
static OdTrVisMatrix4x4Impl & scaleMatrix(OdTrVisMatrix4x4Impl &m, DataType s, bool bInverse=false)
OdTrVisMatrix4x4Impl & operator+=(const VectorType &v)
OdTrVisMatrix4x4Impl recipScale(const VectorType &v) const
DataType operator()(int i, int j) const
OdTrVisMatrix4x4Impl & ortho2d(DataType left, DataType right, DataType bottom, DataType top)
OdTrVisMatrix4x4Impl operator+(const VectorType &v) const
OdTrVisMatrix4x4Impl & operator-=(const VectorType &v)
OdTrVisMatrix4x4Impl operator^(const OdTrVisMatrix4x4Impl &m) const
OdTrVisMatrix4x4Impl & set(const DataType *pVals)
VectorType & untransform(VectorType &vec, DataType w=1.0f) const
OdTrVisMatrix4x4Impl & lookAt(const VectorType &eye, const VectorType &center, const VectorType2 &up, DataType eps=1.e-8f)
OdGeMatrix3d & get(OdGeMatrix3d &xMat, bool bTransposed=true) const
OdTrVisMatrix4x4Impl & localRotate(const VectorType &angles)
OdTrVisMatrix4x4Impl & perspective(DataType fov, DataType aspect, DataType near_, DataType far_)
OdTrVisMatrix4x4Impl & operator^=(const OdTrVisMatrix4x4Impl &m)
VectorType & transform(VectorType &vec, DataType w=1.0f) const
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)
OdTrVisMatrix3x3Impl< DataType > & getSubMatrix(OdTrVisMatrix3x3Impl< DataType > &xMat) const
static OdTrVisMatrix4x4Impl & frustumMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
OdTrVisMatrix3x3Impl< DataType > getSubMatrix() const
static OdTrVisMatrix4x4Impl & translationMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &v, bool bNegate=false)
OdTrVisMatrix4x4Impl & frustum(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
OdTrVisMiniVec3d< DataType > getRotationYAxis() const
OdTrVisMatrix4x4Impl & set(const OdTrVisMatrix3x3Impl< DataType > &xMat, bool bExtend=false)
OdTrVisMatrix4x4Impl operator*(const OdTrVisMatrix4x4Impl &m) const
VectorType untransformClone(const VectorType &vec, DataType w=1.0f) const
friend OdTrVisMatrix4x4Impl operator/(const OdTrVisMatrix4x4Impl &m, DataType n)
static OdTrVisMatrix4x4Impl & rotationMatrix(OdTrVisMatrix4x4Impl &m, DataType angle, const VectorType &v, DataType eps=1.e-8f)
static OdTrVisMatrix4x4Impl & orthoMatrix(OdTrVisMatrix4x4Impl &m, DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
OdTrVisMatrix4x4Impl operator~() const
OdTrVisMatrix4x4Impl & setScale(const VectorType &v)
OdTrVisMatrix4x4Impl & perspective2a(DataType fovX, DataType fovY, DataType near_, DataType far_)
DataType * getArray(int nRow=0)
static OdTrVisMatrix4x4Impl & perspectiveMatrix(OdTrVisMatrix4x4Impl &m, DataType fov, DataType aspect, DataType near_, DataType far_)
OdTrVisMatrix4x4Impl & transpose()
OdTrVisMatrix4x4Impl & ortho(DataType left, DataType right, DataType bottom, DataType top, DataType near_, DataType far_)
static OdTrVisMatrix4x4Impl & scaleMatrix(OdTrVisMatrix4x4Impl &m, const VectorType &v, bool bInverse=false)
OdTrVisMatrix4x4Impl & setIdentity()
OdTrVisMiniVec3d & normalize(DataType eps=1.e-8f)
OdTrVisMiniVec3d & set(DataType _x, DataType _y, DataType _z)
void set(const DataType *v)