NAVTOR SDK  v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
matrix4x4.h
Go to the documentation of this file.
1 #ifndef SDK_MATRIX_4X4_H_
11 #define SDK_MATRIX_4X4_H_
12 
13 #include <cmath>
16 #include "matrix_base_types.h"
17 
18 namespace sdk {
19 
34 template <class _SDKMatrix4X4>
35 class Matrix4X4T : public _SDKMatrix4X4 {
37 public:
38  typedef _SDKMatrix4X4 SDKMatrix4X4;
39  typedef typename SDKMatrix4X4::coordinate_type coordinate_type;
40  // Constructors
41  // Uninitialized matrix
42  Matrix4X4T() noexcept
43  {
44  SetIdentity();
45  }
46  // Constructs a matrix from the given 16 floating-point values.
47  // The contents of the array values is assumed to be in row-major order.
48  explicit Matrix4X4T(const float* values) noexcept {
49  for (int row = 0; row < 4; ++row) {
50  for (int col = 0; col < 4; ++col) {
51  this->_m[row][col] = coordinate_type(values[row * 4 + col]);
52  }
53  }
54  }
55  explicit Matrix4X4T(const double* values) noexcept {
56  for (int row = 0; row < 4; ++row) {
57  for (int col = 0; col < 4; ++col) {
58  this->_m[row][col] = coordinate_type(values[row * 4 + col]);
59  }
60  }
61  }
62  Matrix4X4T(const SDKMatrixF3X2& m) noexcept {
63  this->_11 = coordinate_type(m._11), this->_12 = coordinate_type(m._12), this->_13 = 0, this->_14 = 0;
64  this->_21 = coordinate_type(m._21), this->_22 = coordinate_type(m._22), this->_23 = 0, this->_24 = 0;
65  this->_31 = coordinate_type(m._31), this->_32 = coordinate_type(m._32), this->_33 = 1, this->_34 = 0;
66  this->_41 = 0, this->_42 = 0, this->_43 = 0, this->_44 = 1;
67  }
68  Matrix4X4T(const SDKMatrixD3X2& m) noexcept {
69  this->_11 = coordinate_type(m._11), this->_12 = coordinate_type(m._12), this->_13 = 0, this->_14 = 0;
70  this->_21 = coordinate_type(m._21), this->_22 = coordinate_type(m._22), this->_23 = 0, this->_24 = 0;
71  this->_31 = coordinate_type(m._31), this->_32 = coordinate_type(m._32), this->_33 = 1, this->_34 = 0;
72  this->_41 = 0, this->_42 = 0, this->_43 = 0, this->_44 = 1;
73  }
74  Matrix4X4T(const SDKMatrixF3X3& m) noexcept {
75  this->_11 = coordinate_type(m._11), this->_12 = coordinate_type(m._12), this->_13 = coordinate_type(m._13), this->_14 = 0;
76  this->_21 = coordinate_type(m._21), this->_22 = coordinate_type(m._22), this->_23 = coordinate_type(m._23), this->_24 = 0;
77  this->_31 = coordinate_type(m._31), this->_32 = coordinate_type(m._32), this->_33 = coordinate_type(m._33), this->_34 = 0;
78  this->_41 = 0, this->_42 = 0, this->_43 = 0, this->_44 = 1;
79  }
80  Matrix4X4T(const SDKMatrixD3X3& m) noexcept {
81  this->_11 = coordinate_type(m._11), this->_12 = coordinate_type(m._12), this->_13 = coordinate_type(m._13), this->_14 = 0;
82  this->_21 = coordinate_type(m._21), this->_22 = coordinate_type(m._22), this->_23 = coordinate_type(m._23), this->_24 = 0;
83  this->_31 = coordinate_type(m._31), this->_32 = coordinate_type(m._32), this->_33 = coordinate_type(m._33), this->_34 = 0;
84  this->_41 = 0, this->_42 = 0, this->_43 = 0, this->_44 = 1;
85  }
86  // Copy constructor
87  Matrix4X4T(const SDKMatrixF4X4& m) noexcept {
88  *this = m;
89  }
90  Matrix4X4T(const SDKMatrixD4X4& m) noexcept {
91  *this = m;
92  }
93 
94  Matrix4X4T& operator=(const SDKMatrixF4X4& m) noexcept
95  {
96  for (int row = 0; row < 4; ++row) {
97  this->_m[row][0] = coordinate_type(m._m[row][0]);
98  this->_m[row][1] = coordinate_type(m._m[row][1]);
99  this->_m[row][2] = coordinate_type(m._m[row][2]);
100  this->_m[row][3] = coordinate_type(m._m[row][3]);
101  }
102  return *this;
103  }
104 
105  Matrix4X4T& operator=(const SDKMatrixD4X4& m) noexcept
106  {
107  for (int row = 0; row < 4; ++row) {
108  this->_m[row][0] = coordinate_type(m._m[row][0]);
109  this->_m[row][1] = coordinate_type(m._m[row][1]);
110  this->_m[row][2] = coordinate_type(m._m[row][2]);
111  this->_m[row][3] = coordinate_type(m._m[row][3]);
112  }
113  return *this;
114  }
115 
116  //operator const Matrix4X4T&() const noexcept { return *this; }
117  //operator const SDKMatrix4X4&() const noexcept { return get(); }
118  const SDKMatrix4X4& get() const { return *this; }
119  SDKMatrix4X4& get() { return *this; }
120 
121  //bool operator!=(const matrix4x4t& m) const noexcept {return !operator==(m);}
122  //bool operator!=(const sdkmatrix4x4& m) const noexcept {return !operator==(m); }
123  //bool operator==(const matrix4x4t& m) const noexcept {return operator==(m.get());}
124  //bool operator==(const sdkmatrix4x4& m) const noexcept
125  //{
126  // if ( this->_11 == m._11 && this->_12 == m._12 && this->_13 == m._13 && this->_14 == m._14
127  // && this->_21 == m._21 && this->_22 == m._22 && this->_23 == m._23 && this->_24 == m._24
128  // && this->_31 == m._31 && this->_32 == m._32 && this->_33 == m._33 && this->_34 == m._34
129  // && this->_41 == m._41 && this->_42 == m._42 && this->_43 == m._43 && this->_44 == m._44)
130  // return true;
131 
132  // return false;
133  //}
134 
137  {
138  this->_11 = this->_22 = this->_33 = this->_44 = 1;
139  this->_12 = this->_13 = this->_14 = this->_21 = 0;
140  this->_23 = this->_24 = this->_31 = this->_32 = 0;
141  this->_34 = this->_41 = this->_42 = this->_43 = 0;
142  return *this;
143  }
144 
145  _MyType& Transpose() noexcept
146  {
147  double v;
148  v = this->_12; this->_12 = this->_21; this->_21 = coordinate_type(v);
149  v = this->_13; this->_13 = this->_31; this->_31 = coordinate_type(v);
150  v = this->_14; this->_14 = this->_41; this->_41 = coordinate_type(v);
151  v = this->_23; this->_23 = this->_32; this->_32 = coordinate_type(v);
152  v = this->_24; this->_24 = this->_42; this->_42 = coordinate_type(v);
153  v = this->_34; this->_34 = this->_43; this->_43 = coordinate_type(v);
154  return *this;
155  }
156 
158  double Determinant() const noexcept;
159 
164  _MyType& LookAt(const PointF3D& camera_pos, const PointF3D& look_pos,
165  const PointF3D& camera_up) noexcept
166  {
167  SetIdentity();
168 
169  auto dot = [](const PointF3D& a, const PointF3D& b) -> float
170  { return a.x * b.x + a.y * b.y + a.z * b.z; };
171 
172  auto normalize = [](const PointF3D& v) -> PointF3D
173  {
174  const float len = sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
175  return (len <= 0.0)
176  ? PointF3D(0.0f, 0.0f, 0.0f)
177  : PointF3D(v.x / len, v.y / len, v.z / len);
178  };
179  auto cross = [](const PointF3D& a, const PointF3D& b) -> PointF3D
180  {
181  return PointF3D(
182  a.y * b.z - b.y * a.z,
183  a.z * b.x - b.z * a.x,
184  a.x * b.y - b.x * a.y);
185  };
186 
187  const PointF3D f = normalize(PointF3D(
188  look_pos.x - camera_pos.x,
189  look_pos.y - camera_pos.y,
190  look_pos.z - camera_pos.z));
191  const PointF3D s = normalize(cross(f, camera_up));
192  const PointF3D u = cross(s, f);
193 
194  this->_11 = s.x;
195  this->_21 = s.y;
196  this->_31 = s.z;
197  this->_12 = u.x;
198  this->_22 = u.y;
199  this->_32 = u.z;
200  this->_13 = -f.x;
201  this->_23 = -f.y;
202  this->_33 = -f.z;
203  this->_41 = -dot(s, camera_pos);
204  this->_42 = -dot(u, camera_pos);
205  this->_43 = dot(f, camera_pos);
206 
207  return *this;
208  }
209  inline _MyType& LookAt(const PointF3D& camera_pos, const PointF3D& look_pos) noexcept
210  { return LookAt(camera_pos, look_pos, PointF3D(0.0f, 0.0f, 1.0f)); }
211 
215  _MyType& Rotate(const coordinate_type angle_deg) noexcept
216  {
217  return RotateAroundZ(angle_deg);
218  }
219 
220  _MyType& RotateAroundX(const coordinate_type angle_deg) noexcept
221  {
222  SetIdentity();
223 
224  double angle_rad = (angle_deg / 180.0) * kPI;
225  using std::sin;
226  using std::cos;
227  const double s = sin(angle_rad);
228  const double c = cos(angle_rad);
229 
230  this->_22 = coordinate_type(c);
231  this->_23 = coordinate_type(s);
232  this->_32 = coordinate_type(-s);
233  this->_33 = coordinate_type(c);
234 
235  return *this;
236  }
237 
238  _MyType& RotateAroundY(const coordinate_type angle_deg) noexcept
239  {
240  SetIdentity();
241 
242  double angle_rad = (angle_deg / 180.0) * kPI;
243  using std::sin;
244  using std::cos;
245  const double s = sin(angle_rad);
246  const double c = cos(angle_rad);
247 
248  this->_33 = coordinate_type(c);
249  this->_31 = coordinate_type(s);
250  this->_13 = coordinate_type(-s);
251  this->_11 = coordinate_type(c);
252 
253  return *this;
254  }
255 
256  _MyType& RotateAroundZ(const coordinate_type angle_deg) noexcept
257  {
258  SetIdentity();
259 
260  double angle_rad = (angle_deg / 180.0) * kPI;
261  using std::sin;
262  using std::cos;
263  const double s = sin(angle_rad);
264  const double c = cos(angle_rad);
265 
266  this->_11 = coordinate_type(c);
267  this->_12 = coordinate_type(s);
268  this->_21 = coordinate_type(-s);
269  this->_22 = coordinate_type(c);
270 
271  return *this;
272  }
273 
276  const coordinate_type scale_x,
277  const coordinate_type scale_y,
278  const coordinate_type scale_z = 1) noexcept
279  {
280  SetIdentity();
281  this->_11 = scale_x;
282  this->_22 = scale_y;
283  this->_33 = scale_z;
284  return *this;
285  }
286 
289  const coordinate_type x,
290  const coordinate_type y,
291  const coordinate_type z = 0) noexcept
292  {
293  SetIdentity();
294  this->_41 = x;
295  this->_42 = y;
296  this->_43 = z;
297  return *this;
298  }
299 
301  _MyType& operator*=(const SDKMatrix4X4& m2)
302  {
303  *this = Multiply(*this, m2);
304  return *this;
305  }
306 
307  _MyType operator*(const SDKMatrix4X4& m2) const
308  {
309  return Multiply(*this, m2);
310  }
311 
313  PointD2D Transform(const SDKPointD2D& point) const
314  {
315  PointD3D vec_3d(point.x, point.y, 0.0);
316  vec_3d = Transform3D(vec_3d);
317  return PointD2D(vec_3d.x, vec_3d.y);
318  }
320  PointF2D Transform(const SDKPointF2D& point) const
321  {
322  PointF3D vec_3d(point.x, point.y, 0.0f);
323  vec_3d = Transform3D(vec_3d);
324  return PointF2D(vec_3d.x, vec_3d.y);
325  }
327  PointI2D Transform(const SDKPointI2D& point) const
328  {
329  PointD3D vec_3d(point.x, point.y, 0);
330  PointD3D res_d = Transform3D(vec_3d);
331  using std::floor;
332  return PointI2D(SDKInt32(floor(res_d.x + 0.5)),
333  SDKInt32(floor(res_d.y + 0.5)));
334  }
335 
337  PointD3D Transform3D(const SDKPointD3D& point) const
338  {
339  double x = (point.x * this->_11 + point.y * this->_21 + point.z * this->_31 + this->_41);
340  double y = (point.x * this->_12 + point.y * this->_22 + point.z * this->_32 + this->_42);
341  double z = (point.x * this->_13 + point.y * this->_23 + point.z * this->_33 + this->_43);
342  double w = (point.x * this->_14 + point.y * this->_24 + point.z * this->_34 + this->_44);
343 
344  x /= w;
345  y /= w;
346  z /= w;
347 
348  return PointD3D(x, y, z);
349  }
351  PointF3D Transform3D(const SDKPointF3D& point) const
352  {
353  PointD3D point_d(point);
354  PointD3D res_d = Transform3D(point_d);
355  return PointF3D(float(res_d.x),
356  float(res_d.y),
357  float(res_d.z));
358  }
359 
360  // Matrix multiplication.
361  static _MyType Multiply(
362  const SDKMatrix4X4& m1, const SDKMatrix4X4& m2) noexcept;
363 
365  bool Invert() noexcept
366  {
367  return this->Invert(*this);
368  }
369  bool Invert(SDKMatrixD4X4& inverted_matrix) const noexcept;
370  bool Invert(SDKMatrixF4X4& inverted_matrix) const noexcept
371  {
372  Matrix4X4T<SDKMatrixD4X4> inv(*this);
373  if (!inv.Invert())
374  return false;
375  inverted_matrix = inv;
376  return true;
377  }
378 };
379 
380 template <class _SDKMatrixD4X4>
382 {
383  double det = 0
384  + double(this->_11)
385  * (double(this->_22) * this->_33 * this->_44
386  - double(this->_22) * this->_34 * this->_43
387  - double(this->_32) * this->_23 * this->_44
388  + double(this->_32) * this->_24 * this->_43
389  + double(this->_42) * this->_23 * this->_34
390  - double(this->_42) * this->_24 * this->_33)
391  - double(this->_12)
392  * (double(this->_21) * this->_33 * this->_44
393  + double(this->_21) * this->_34 * this->_43
394  + double(this->_31) * this->_23 * this->_44
395  + double(this->_31) * this->_24 * this->_43
396  - double(this->_41) * this->_23 * this->_34
397  + double(this->_41) * this->_24 * this->_33)
398  + double(this->_13)
399  * (double(this->_21) * this->_32 * this->_44
400  - double(this->_21) * this->_34 * this->_42
401  - double(this->_31) * this->_22 * this->_44
402  + double(this->_31) * this->_24 * this->_42
403  + double(this->_41) * this->_22 * this->_34
404  - double(this->_41) * this->_24 * this->_32)
405  - double(this->_14)
406  * (double(this->_21) * this->_32 * this->_43
407  + double(this->_21) * this->_33 * this->_42
408  + double(this->_31) * this->_22 * this->_43
409  + double(this->_31) * this->_23 * this->_42
410  - double(this->_41) * this->_22 * this->_33
411  + double(this->_41) * this->_23 * this->_32);
412  return det;
413 }
414 
415 template <class _SDKMatrixD4X4>
417  const SDKMatrix4X4& m1, const SDKMatrix4X4& m2) noexcept
418 {
419  return m1 * m2;
420 }
421 
422 template <class _SDKMatrixD4X4>
423 bool Matrix4X4T<_SDKMatrixD4X4>::Invert(SDKMatrixD4X4& inverted_matrix) const noexcept
424 {
425  SDKMatrixD4X4 inv;
426  // Calculate an adjugate of the matrix.
427  inv._11 = 0
428  + double(this->_22) * this->_33 * this->_44
429  - double(this->_22) * this->_34 * this->_43
430  - double(this->_32) * this->_23 * this->_44
431  + double(this->_32) * this->_24 * this->_43
432  + double(this->_42) * this->_23 * this->_34
433  - double(this->_42) * this->_24 * this->_33;
434  inv._12 = 0
435  - double(this->_12) * this->_33 * this->_44
436  + double(this->_12) * this->_34 * this->_43
437  + double(this->_32) * this->_13 * this->_44
438  - double(this->_32) * this->_14 * this->_43
439  - double(this->_42) * this->_13 * this->_34
440  + double(this->_42) * this->_14 * this->_33;
441  inv._13 = 0
442  + double(this->_12) * this->_23 * this->_44
443  - double(this->_12) * this->_24 * this->_43
444  - double(this->_22) * this->_13 * this->_44
445  + double(this->_22) * this->_14 * this->_43
446  + double(this->_42) * this->_13 * this->_24
447  - double(this->_42) * this->_14 * this->_23;
448  inv._14 = 0
449  - double(this->_12) * this->_23 * this->_34
450  + double(this->_12) * this->_24 * this->_33
451  + double(this->_22) * this->_13 * this->_34
452  - double(this->_22) * this->_14 * this->_33
453  - double(this->_32) * this->_13 * this->_24
454  + double(this->_32) * this->_14 * this->_23;
455 
456  // Calculating determinant
457  //double det = 0
458  // + double(this->_11) * inv._11 + double(this->_12) * inv._21
459  // + double(this->_13) * inv._31 + double(this->_14) * inv._41;
460  double det = 0
461  + this->_11 * inv._11 + this->_21 * inv._12
462  + this->_31 * inv._13 + this->_41 * inv._14;
463  if (0.0 == det)
464  return false;
465  det = 1.0 / det;
466 
467  inv._21 = 0
468  - double(this->_21) * this->_33 * this->_44
469  + double(this->_21) * this->_34 * this->_43
470  + double(this->_31) * this->_23 * this->_44
471  - double(this->_31) * this->_24 * this->_43
472  - double(this->_41) * this->_23 * this->_34
473  + double(this->_41) * this->_24 * this->_33;
474  inv._22 = 0
475  + double(this->_11) * this->_33 * this->_44
476  - double(this->_11) * this->_34 * this->_43
477  - double(this->_31) * this->_13 * this->_44
478  + double(this->_31) * this->_14 * this->_43
479  + double(this->_41) * this->_13 * this->_34
480  - double(this->_41) * this->_14 * this->_33;
481  inv._23 = 0
482  - double(this->_11) * this->_23 * this->_44
483  + double(this->_11) * this->_24 * this->_43
484  + double(this->_21) * this->_13 * this->_44
485  - double(this->_21) * this->_14 * this->_43
486  - double(this->_41) * this->_13 * this->_24
487  + double(this->_41) * this->_14 * this->_23;
488  inv._24 = 0
489  + double(this->_11) * this->_23 * this->_34
490  - double(this->_11) * this->_24 * this->_33
491  - double(this->_21) * this->_13 * this->_34
492  + double(this->_21) * this->_14 * this->_33
493  + double(this->_31) * this->_13 * this->_24
494  - double(this->_31) * this->_14 * this->_23;
495 
496  inv._31 = 0
497  + double(this->_21) * this->_32 * this->_44
498  - double(this->_21) * this->_34 * this->_42
499  - double(this->_31) * this->_22 * this->_44
500  + double(this->_31) * this->_24 * this->_42
501  + double(this->_41) * this->_22 * this->_34
502  - double(this->_41) * this->_24 * this->_32;
503  inv._32 = 0
504  - double(this->_11) * this->_32 * this->_44
505  + double(this->_11) * this->_34 * this->_42
506  + double(this->_31) * this->_12 * this->_44
507  - double(this->_31) * this->_14 * this->_42
508  - double(this->_41) * this->_12 * this->_34
509  + double(this->_41) * this->_14 * this->_32;
510  inv._33 = 0
511  + double(this->_11) * this->_22 * this->_44
512  - double(this->_11) * this->_24 * this->_42
513  - double(this->_21) * this->_12 * this->_44
514  + double(this->_21) * this->_14 * this->_42
515  + double(this->_41) * this->_12 * this->_24
516  - double(this->_41) * this->_14 * this->_22;
517  inv._34 = 0
518  - double(this->_11) * this->_22 * this->_34
519  + double(this->_11) * this->_24 * this->_32
520  + double(this->_21) * this->_12 * this->_34
521  - double(this->_21) * this->_14 * this->_32
522  - double(this->_31) * this->_12 * this->_24
523  + double(this->_31) * this->_14 * this->_22;
524 
525  inv._41 = 0
526  - double(this->_21) * this->_32 * this->_43
527  + double(this->_21) * this->_33 * this->_42
528  + double(this->_31) * this->_22 * this->_43
529  - double(this->_31) * this->_23 * this->_42
530  - double(this->_41) * this->_22 * this->_33
531  + double(this->_41) * this->_23 * this->_32;
532  inv._42 = 0
533  + double(this->_11) * this->_32 * this->_43
534  - double(this->_11) * this->_33 * this->_42
535  - double(this->_31) * this->_12 * this->_43
536  + double(this->_31) * this->_13 * this->_42
537  + double(this->_41) * this->_12 * this->_33
538  - double(this->_41) * this->_13 * this->_32;
539  inv._43 = 0
540  - double(this->_11) * this->_22 * this->_43
541  + double(this->_11) * this->_23 * this->_42
542  + double(this->_21) * this->_12 * this->_43
543  - double(this->_21) * this->_13 * this->_42
544  - double(this->_41) * this->_12 * this->_23
545  + double(this->_41) * this->_13 * this->_22;
546  inv._44 = 0
547  + double(this->_11) * this->_22 * this->_33
548  - double(this->_11) * this->_23 * this->_32
549  - double(this->_21) * this->_12 * this->_33
550  + double(this->_21) * this->_13 * this->_32
551  + double(this->_31) * this->_12 * this->_23
552  - double(this->_31) * this->_13 * this->_22;
553 
554  inverted_matrix._11 = inv._11 * det;
555  inverted_matrix._12 = inv._12 * det;
556  inverted_matrix._13 = inv._13 * det;
557  inverted_matrix._14 = inv._14 * det;
558 
559  inverted_matrix._21 = inv._21 * det;
560  inverted_matrix._22 = inv._22 * det;
561  inverted_matrix._23 = inv._23 * det;
562  inverted_matrix._24 = inv._24 * det;
563 
564  inverted_matrix._31 = inv._31 * det;
565  inverted_matrix._32 = inv._32 * det;
566  inverted_matrix._33 = inv._33 * det;
567  inverted_matrix._34 = inv._34 * det;
568 
569  inverted_matrix._41 = inv._41 * det;
570  inverted_matrix._42 = inv._42 * det;
571  inverted_matrix._43 = inv._43 * det;
572  inverted_matrix._44 = inv._44 * det;
573 
574  return true;
575 }
576 
577 typedef Matrix4X4T<SDKMatrix4X4> Matrix4X4, CMatrix4X4;
578 typedef Matrix4X4T<SDKMatrixD4X4> MatrixD4X4, CMatrixD4X4;
579 typedef Matrix4X4T<SDKMatrixF4X4> MatrixF4X4, CMatrixF4X4;
580 
581 } // namespace sdk
582 #endif // SDK_MATRIX_4X4_H_
SDKMatrixD3X2
Matrix 3x2.
Definition: matrix_base_types.h:120
SDKMatrixF3X3
Matrix 3X3.
Definition: matrix_base_types.h:62
geometry_base_types_helpers.h
Geometry types.
sdk::Matrix4X4T::operator*=
_MyType & operator*=(const SDKMatrix4X4 &m2)
Multiplication of this matrix to a specified one.
Definition: matrix4x4.h:301
sdk::PointI2D
A 2-D point.
Definition: geometry_base_types_helpers.h:165
sdk::Matrix4X4T::SetIdentity
_MyType & SetIdentity()
Sets to identity.
Definition: matrix4x4.h:136
sdk::Matrix4X4T::Transform3D
PointF3D Transform3D(const SDKPointF3D &point) const
Transforms a 3D float point by this matrix.
Definition: matrix4x4.h:351
sdk::Matrix4X4T::Transform
PointI2D Transform(const SDKPointI2D &point) const
Transforms a 2D integer point by this matrix.
Definition: matrix4x4.h:327
SDKMatrixD3X3
Matrix 3X3.
Definition: matrix_base_types.h:149
sdk::PointF2D
A 2-D point.
Definition: geometry_base_types_helpers.h:58
sdk::Matrix4X4T::Transform3D
PointD3D Transform3D(const SDKPointD3D &point) const
Transforms a 3D double point by this matrix.
Definition: matrix4x4.h:337
sdk::Matrix4X4T
This class represents a 3D transformation. The matrix is laid out as follows:
Definition: matrix4x4.h:35
sdk::Matrix4X4T::Scale
_MyType & Scale(const coordinate_type scale_x, const coordinate_type scale_y, const coordinate_type scale_z=1) noexcept
Creates the scale transformation matrix.
Definition: matrix4x4.h:275
sdk::PointD2D
A 2-D point.
Definition: geometry_base_types_helpers.h:109
sdk::Matrix4X4T::Translate
_MyType & Translate(const coordinate_type x, const coordinate_type y, const coordinate_type z=0) noexcept
Creates a translation transformation that has the specified x and y displacements.
Definition: matrix4x4.h:288
SDKPointF3D
Single 3D point.
Definition: geometry_base_types.h:101
sdk::Matrix4X4T::LookAt
_MyType & LookAt(const PointF3D &camera_pos, const PointF3D &look_pos, const PointF3D &camera_up) noexcept
Look at position matrix camera_pos - Camera position look_pos - Camera look position camera_up - Came...
Definition: matrix4x4.h:164
SDKPointF2D
Single 2D point.
Definition: geometry_base_types.h:33
sdk::Matrix4X4T::Invert
bool Invert() noexcept
Inverts matrix, if possible.
Definition: matrix4x4.h:365
sdk::Matrix4X4T::Transform
PointD2D Transform(const SDKPointD2D &point) const
Transforms a 2D double point by this matrix.
Definition: matrix4x4.h:313
matrix_base_types.h
Matrix base definitions.
geometry_base_types.h
Geometry base types.
SDKPointI2D
Single 2D point.
Definition: geometry_base_types.h:178
sdk::Matrix4X4T::Transform
PointF2D Transform(const SDKPointF2D &point) const
Transforms a 2D float point by this matrix.
Definition: matrix4x4.h:320
kPI
#define kPI
PI.
Definition: math_const.h:16
SDKMatrixF4X4
Matrix 4X4.
Definition: matrix_base_types.h:91
SDKMatrixF3X2
Matrix 3x2.
Definition: matrix_base_types.h:33
sdk::Matrix4X4T::Determinant
double Determinant() const noexcept
Returns the matrix determinant.
Definition: matrix4x4.h:381
SDKPointD3D
A three dimensional point.
Definition: geometry_base_types.h:306
SDKMatrixD4X4
Matrix 4X4.
Definition: matrix_base_types.h:178
SDKPointD2D
A two dimensional point.
Definition: geometry_base_types.h:242
sdk::Matrix4X4T::Rotate
_MyType & Rotate(const coordinate_type angle_deg) noexcept
Rotate around the center on specified angle. Negative angle - clockwise rotation in SDK coordinate sy...
Definition: matrix4x4.h:215