Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Matrix3.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Matrix3_INCLUDE_ONCE
33 #define Matrix3_INCLUDE_ONCE
34 
35 #include <vlCore/Vector3.hpp>
36 #include <vlCore/Matrix2.hpp>
37 
38 namespace vl
39 {
40  //-----------------------------------------------------------------------------
41  // Matrix3
42  //-----------------------------------------------------------------------------
47  template<typename T_Scalar>
48  class Matrix3
49  {
50  public:
51  typedef T_Scalar scalar_type;
52  //-----------------------------------------------------------------------------
53  template<typename T>
54  explicit Matrix3(const Matrix3<T>& m)
55  {
56  e(0,0) = (T_Scalar)m.e(0,0); e(1,0) = (T_Scalar)m.e(1,0); e(2,0) = (T_Scalar)m.e(2,0);
57  e(0,1) = (T_Scalar)m.e(0,1); e(1,1) = (T_Scalar)m.e(1,1); e(2,1) = (T_Scalar)m.e(2,1);
58  e(0,2) = (T_Scalar)m.e(0,2); e(1,2) = (T_Scalar)m.e(1,2); e(2,2) = (T_Scalar)m.e(2,2);
59  }
60  //-----------------------------------------------------------------------------
61  Matrix3(const Matrix3& other)
62  {
63  operator=(other);
64  }
65  //-----------------------------------------------------------------------------
67  {
68  setIdentity();
69  }
70  //-----------------------------------------------------------------------------
71  explicit Matrix3(T_Scalar n)
72  {
73  setIdentity();
74  e(0,0) = e(1,1) = e(2,2) = n;
75  }
76  //-----------------------------------------------------------------------------
77  explicit Matrix3(T_Scalar e00, T_Scalar e01, T_Scalar e02,
78  T_Scalar e10, T_Scalar e11, T_Scalar e12,
79  T_Scalar e20, T_Scalar e21, T_Scalar e22)
80  {
81  e(0,0) = e00; e(0,1) = e01; e(0,2) = e02;
82  e(1,0) = e10; e(1,1) = e11; e(1,2) = e12;
83  e(2,0) = e20; e(2,1) = e21; e(2,2) = e22;
84  }
85  //-----------------------------------------------------------------------------
86  Matrix3& fill(T_Scalar val)
87  {
88  e(0,0) = e(1,0) = e(2,0) =
89  e(0,1) = e(1,1) = e(2,1) =
90  e(0,2) = e(1,2) = e(2,2) = val;
91  return *this;
92  }
93  //-----------------------------------------------------------------------------
94  T_Scalar diff(const Matrix3& other) const
95  {
96  T_Scalar err = 0;
97  for(int i=0; i<3; ++i)
98  for(int j=0; j<3; ++j)
99  if (e(j,i) > other.e(j,i)) // avoid fabs/abs
100  err += e(j,i) - other.e(j,i);
101  else
102  err += other.e(j,i) - e(j,i);
103  return err;
104  }
105  //-----------------------------------------------------------------------------
107  {
109  v.x() = e(0,0);
110  v.y() = e(1,0);
111  return v;
112  }
113  //-----------------------------------------------------------------------------
115  {
117  v.x() = e(0,1);
118  v.y() = e(1,1);
119  return v;
120  }
121  //-----------------------------------------------------------------------------
123  {
125  v.x() = e(0,2);
126  v.y() = e(1,2);
127  return v;
128  }
129  //-----------------------------------------------------------------------------
131  {
132  e(0,0) = v.x();
133  e(1,0) = v.y();
134  return *this;
135  }
136  //-----------------------------------------------------------------------------
138  {
139  e(0,1) = v.x();
140  e(1,1) = v.y();
141  return *this;
142  }
143  //-----------------------------------------------------------------------------
145  {
146  e(0,2) = v.x();
147  e(1,2) = v.y();
148  return *this;
149  }
150  //-----------------------------------------------------------------------------
151  bool operator==(const Matrix3& m) const
152  {
153  return memcmp(m.mVec, mVec, sizeof(T_Scalar)*9) == 0;
154  }
155  //-----------------------------------------------------------------------------
156  bool operator!=(const Matrix3& m) const
157  {
158  return !operator==(m);
159  }
160  //-----------------------------------------------------------------------------
162  {
163  memcpy(mVec, m.mVec, sizeof(T_Scalar)*9);
164  return *this;
165  }
166  //-----------------------------------------------------------------------------
167  Matrix3 operator+(const Matrix3& m) const
168  {
169  Matrix3 t;
170  for(int i=0; i<3; ++i)
171  for(int j=0; j<3; ++j)
172  t.e(j,i) = e(j,i) + m.e(j,i);
173  return t;
174  }
175  //-----------------------------------------------------------------------------
177  {
178  for(int i=0; i<3; ++i)
179  for(int j=0; j<3; ++j)
180  e(j,i) += m.e(j,i);
181  return *this;
182  }
183  //-----------------------------------------------------------------------------
184  Matrix3 operator-(const Matrix3& m) const
185  {
186  Matrix3 t;
187  for(int i=0; i<3; ++i)
188  for(int j=0; j<3; ++j)
189  t.e(j,i) = e(j,i) - m.e(j,i);
190  return t;
191  }
192  //-----------------------------------------------------------------------------
194  {
195  for(int i=0; i<3; ++i)
196  for(int j=0; j<3; ++j)
197  e(j,i) -= m.e(j,i);
198  return *this;
199  }
200  //-----------------------------------------------------------------------------
202  {
203  return postMultiply(m);
204  }
205  //-----------------------------------------------------------------------------
207  {
208  Matrix3 t;
209  for(int i=0; i<3; ++i)
210  for(int j=0; j<3; ++j)
211  t.e(j,i) = -e(j,i);
212  return t;
213  }
214  //-----------------------------------------------------------------------------
215  Matrix3 operator+(T_Scalar d) const
216  {
217  Matrix3 t;
218  for(int i=0; i<3; ++i)
219  for(int j=0; j<3; ++j)
220  t.e(j,i) = e(j,i) + d;
221  return t;
222  }
223  //-----------------------------------------------------------------------------
224  Matrix3& operator+=(T_Scalar d)
225  {
226  for(int i=0; i<3; ++i)
227  for(int j=0; j<3; ++j)
228  e(j,i) += d;
229  return *this;
230  }
231  //-----------------------------------------------------------------------------
232  Matrix3 operator-(T_Scalar d) const
233  {
234  Matrix3 t;
235  for(int i=0; i<3; ++i)
236  for(int j=0; j<3; ++j)
237  t.e(j,i) = e(j,i) - d;
238  return t;
239  }
240  //-----------------------------------------------------------------------------
241  Matrix3& operator-=(T_Scalar d)
242  {
243  for(int i=0; i<3; ++i)
244  for(int j=0; j<3; ++j)
245  e(j,i) -= d;
246  return *this;
247  }
248  //-----------------------------------------------------------------------------
249  Matrix3 operator*(T_Scalar d) const
250  {
251  Matrix3 t;
252  for(int i=0; i<3; ++i)
253  for(int j=0; j<3; ++j)
254  t.e(j,i) = e(j,i) * d;
255  return t;
256  }
257  //-----------------------------------------------------------------------------
258  Matrix3& operator*=(T_Scalar d)
259  {
260  for(int i=0; i<3; ++i)
261  for(int j=0; j<3; ++j)
262  e(j,i) *= d;
263  return *this;
264  }
265  //-----------------------------------------------------------------------------
266  Matrix3 operator/(T_Scalar d) const
267  {
268  d = (T_Scalar)1 / d;
269  Matrix3 t;
270  for(int i=0; i<3; ++i)
271  for(int j=0; j<3; ++j)
272  t.e(j,i) = e(j,i) * d;
273  return t;
274  }
275  //-----------------------------------------------------------------------------
276  Matrix3& operator/=(T_Scalar d)
277  {
278  d = (T_Scalar)1 / d;
279  for(int i=0; i<3; ++i)
280  for(int j=0; j<3; ++j)
281  e(j,i) *= d;
282  return *this;
283  }
284  //-----------------------------------------------------------------------------
285  bool isIdentity() const
286  {
287  Matrix3 i;
288  return memcmp(ptr(), i.ptr(), sizeof(T_Scalar)*9) == 0;
289  }
290  //-----------------------------------------------------------------------------
292  {
294  t.e(0,0) = e(0,0); t.e(1,0) = e(1,0);
295  t.e(0,1) = e(0,1); t.e(1,1) = e(1,1);
296  return t;
297  }
298  //-----------------------------------------------------------------------------
300  void set2x2(const Matrix2<T_Scalar>& m)
301  {
302  e(0,0) = m.e(0,0); e(1,0) = m.e(1,0);
303  e(0,1) = m.e(0,1); e(1,1) = m.e(1,1);
304  }
305  //-----------------------------------------------------------------------------
306  T_Scalar* ptr()
307  {
308  return &e(0,0);
309  }
310  //-----------------------------------------------------------------------------
311  const T_Scalar* ptr() const
312  {
313  return &e(0,0);
314  }
315  //-----------------------------------------------------------------------------
317  {
318  T_Scalar tmp;
319  for(int i=0; i<3; ++i)
320  {
321  for(int j=i; j<3; ++j)
322  {
323  tmp = e(j,i);
324  e(j,i) = e(i,j);
325  e(i,j) = tmp;
326  }
327  }
328  return *this;
329  }
330  //-----------------------------------------------------------------------------
332  {
333  Matrix3 m;
334  for(int i=0; i<3; ++i)
335  for(int j=0; j<3; ++j)
336  m.e(j,i) = e(i,j);
337  return m;
338  }
339  //-----------------------------------------------------------------------------
341  {
342  for(int i=0; i<3; ++i)
343  for(int j=0; j<3; ++j)
344  dest.e(j,i) = e(i,j);
345  return dest;
346  }
347  //-----------------------------------------------------------------------------
348  bool isNull() const
349  {
350  for(int i=0; i<3; ++i)
351  for(int j=0; j<3; ++j)
352  if(mVec[j][i] != 0)
353  return false;
354  return true;
355  }
356  //-----------------------------------------------------------------------------
358  {
359  fill(0);
360  return *this;
361  }
362  //-----------------------------------------------------------------------------
363  static Matrix3& getNull(Matrix3& out)
364  {
365  out.fill(0);
366  return out;
367  }
368  //-----------------------------------------------------------------------------
369  static Matrix3 getNull()
370  {
371  return Matrix3().fill(0);
372  }
373  //-----------------------------------------------------------------------------
375  {
376  static const T_Scalar I3d[] =
377  {
378  (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
379  (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
380  (T_Scalar)0, (T_Scalar)0, (T_Scalar)1,
381  };
382  memcpy(mVec, I3d, sizeof(T_Scalar)*9);
383  return *this;
384  }
385  //-----------------------------------------------------------------------------
387  {
388  return Matrix3();
389  }
390  //-----------------------------------------------------------------------------
392  {
393  out.setIdentity();
394  return out;
395  }
396  //-----------------------------------------------------------------------------
397  T_Scalar getInverse(Matrix3& dest) const;
398  //-----------------------------------------------------------------------------
399  Matrix3 getInverse(T_Scalar *determinant=NULL) const
400  {
401  Matrix3 tmp;
402  T_Scalar det = getInverse(tmp);
403  if (determinant)
404  *determinant = det;
405  return tmp;
406  }
407  //-----------------------------------------------------------------------------
408  Matrix3& invert(T_Scalar *determinant=NULL)
409  {
410  T_Scalar det = getInverse(*this);
411  if (determinant)
412  *determinant = det;
413  return *this;
414  }
415  //-----------------------------------------------------------------------------
416  static Matrix3 getRotation(T_Scalar degrees);
417  //-----------------------------------------------------------------------------
418  Matrix3& rotate(T_Scalar degrees)
419  {
420  return preMultiply(getRotation(degrees));
421  }
422  //-----------------------------------------------------------------------------
424  {
425  return getTranslation(out, v.x(), v.y());
426  }
427  //-----------------------------------------------------------------------------
429  {
430  return getTranslation(v.x(), v.y());
431  }
432  //-----------------------------------------------------------------------------
433  static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
434  {
435  Matrix3 m;
436  return getTranslation(m, x, y);
437  }
438  //-----------------------------------------------------------------------------
439  static Matrix3& getTranslation(Matrix3& out, T_Scalar x, T_Scalar y)
440  {
441  out.setIdentity();
442  out.e(0,2) = x;
443  out.e(1,2) = y;
444  return out;
445  }
446  //-----------------------------------------------------------------------------
447  Matrix3& translate(T_Scalar x, T_Scalar y)
448  {
449  return preMultiply(getTranslation(x,y));
450  }
451  //-----------------------------------------------------------------------------
453  {
454  return preMultiply(getTranslation(v));
455  }
456  //-----------------------------------------------------------------------------
457  static Matrix3& getScaling(Matrix3& out, const Vector2<T_Scalar>& v)
458  {
459  return getScaling(out, v.x(), v.y());
460  }
461  //-----------------------------------------------------------------------------
463  {
464  Matrix3 m;
465  return getScaling(m, v.x(), v.y());
466  }
467  //-----------------------------------------------------------------------------
468  static Matrix3 getScaling(T_Scalar x, T_Scalar y)
469  {
470  Matrix3 m;
471  return getScaling(m, x, y);
472  }
473  //-----------------------------------------------------------------------------
474  static Matrix3& getScaling(Matrix3& out, T_Scalar x, T_Scalar y)
475  {
476  out.setIdentity();
477  out.e(0,0) = x;
478  out.e(1,1) = y;
479  return out;
480  }
481  //-----------------------------------------------------------------------------
482  Matrix3& scale(T_Scalar x, T_Scalar y)
483  {
484  return preMultiply(getScaling(x,y));
485  }
486  //-----------------------------------------------------------------------------
488  {
489  return preMultiply(getScaling(v.x(),v.y()));
490  }
491  //-----------------------------------------------------------------------------
492  static Matrix3& multiply(Matrix3& out, const Matrix3& p, const Matrix3& q)
493  {
494  VL_CHECK(out.ptr() != p.ptr() && out.ptr() != q.ptr());
495 
496  out.e(0,0) = q.e(0,0)*p.e(0,0) + q.e(1,0)*p.e(0,1) + q.e(2,0)*p.e(0,2);
497  out.e(0,1) = q.e(0,1)*p.e(0,0) + q.e(1,1)*p.e(0,1) + q.e(2,1)*p.e(0,2);
498  out.e(0,2) = q.e(0,2)*p.e(0,0) + q.e(1,2)*p.e(0,1) + q.e(2,2)*p.e(0,2);
499 
500  out.e(1,0) = q.e(0,0)*p.e(1,0) + q.e(1,0)*p.e(1,1) + q.e(2,0)*p.e(1,2);
501  out.e(1,1) = q.e(0,1)*p.e(1,0) + q.e(1,1)*p.e(1,1) + q.e(2,1)*p.e(1,2);
502  out.e(1,2) = q.e(0,2)*p.e(1,0) + q.e(1,2)*p.e(1,1) + q.e(2,2)*p.e(1,2);
503 
504  out.e(2,0) = q.e(0,0)*p.e(2,0) + q.e(1,0)*p.e(2,1) + q.e(2,0)*p.e(2,2);
505  out.e(2,1) = q.e(0,1)*p.e(2,0) + q.e(1,1)*p.e(2,1) + q.e(2,1)*p.e(2,2);
506  out.e(2,2) = q.e(0,2)*p.e(2,0) + q.e(1,2)*p.e(2,1) + q.e(2,2)*p.e(2,2);
507 
508  return out;
509  }
510  //-----------------------------------------------------------------------------
512  {
514  return *this = multiply(t, *this, m);
515  }
516  //-----------------------------------------------------------------------------
518  {
520  return *this = multiply(t, m, *this);
521  }
522  //-----------------------------------------------------------------------------
523 
524  const T_Scalar& e(int i, int j) const { return mVec[j][i]; }
525  T_Scalar& e(int i, int j) { return mVec[j][i]; }
526 
527  private:
528  const Vector3<T_Scalar>& operator[](unsigned int i) const { VL_CHECK(i<3); return mVec[i]; }
529  Vector3<T_Scalar>& operator[](unsigned int i) { VL_CHECK(i<3); return mVec[i]; }
530 
531  protected:
533  };
534 
535  //-----------------------------------------------------------------------------
536  // OPERATORS
537  //-----------------------------------------------------------------------------
538  template<typename T_Scalar>
540  {
543  return t;
544  }
545  //-----------------------------------------------------------------------------
546  template<typename T_Scalar>
547  inline Matrix3<T_Scalar> operator+(T_Scalar d, const Matrix3<T_Scalar>& m)
548  {
549  return m + d;
550  }
551  //-----------------------------------------------------------------------------
552  template<typename T_Scalar>
553  inline Matrix3<T_Scalar> operator*(T_Scalar d, const Matrix3<T_Scalar>& m)
554  {
555  return m * d;
556  }
557  //-----------------------------------------------------------------------------
559  template<typename T_Scalar>
561  {
563  t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1) + v.z()*m.e(0,2);
564  t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1) + v.z()*m.e(1,2);
565  t.z() = v.x()*m.e(2,0) + v.y()*m.e(2,1) + v.z()*m.e(2,2);
566  return t;
567  }
568  //-----------------------------------------------------------------------------
571  template<typename T_Scalar>
573  {
575  t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1) /*+ 0*m.e(0,2)*/;
576  t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1) /*+ 0*m.e(1,2)*/;
577  return t;
578  }
579  //-----------------------------------------------------------------------------
581  template<typename T_Scalar>
583  {
585  t.x() = v.x()*m.e(0,0) + v.y()*m.e(1,0) + v.z()*m.e(2,0);
586  t.y() = v.x()*m.e(0,1) + v.y()*m.e(1,1) + v.z()*m.e(2,1);
587  t.z() = v.x()*m.e(0,2) + v.y()*m.e(1,2) + v.z()*m.e(2,2);
588  return t;
589  }
590  //-----------------------------------------------------------------------------
593  template<typename T_Scalar>
595  {
597  t.x() = v.x()*m.e(0,0) + v.y()*m.e(1,0) /*+ 0*m.e(2,0)*/;
598  t.y() = v.x()*m.e(0,1) + v.y()*m.e(1,1) /*+ 0*m.e(2,1)*/;
599  return t;
600  }
601  //-----------------------------------------------------------------------------
602  template<typename T_Scalar>
604  {
605  Matrix3<T_Scalar> rot;
606  degrees = degrees * (T_Scalar)dDEG_TO_RAD;
607  T_Scalar s = (T_Scalar) sin(degrees);
608  T_Scalar c = (T_Scalar) cos(degrees);
609  rot.e(0,0) = (T_Scalar)c;
610  rot.e(1,1) = (T_Scalar)c;
611  rot.e(1,0) = (T_Scalar)s;
612  rot.e(0,1) = -(T_Scalar)s;
613  return rot;
614  }
615  //-----------------------------------------------------------------------------
616  template<typename T_Scalar>
618  {
619  if (&dest == this)
620  {
621  Matrix3<T_Scalar> tmp;
622  T_Scalar det = getInverse(tmp);
623  dest = tmp;
624  return det;
625  }
626  else
627  {
628  const T_Scalar& a11 = e(0,0);
629  const T_Scalar& a21 = e(1,0);
630  const T_Scalar& a31 = e(2,0);
631  const T_Scalar& a12 = e(0,1);
632  const T_Scalar& a22 = e(1,1);
633  const T_Scalar& a32 = e(2,1);
634  const T_Scalar& a13 = e(0,2);
635  const T_Scalar& a23 = e(1,2);
636  const T_Scalar& a33 = e(2,2);
637 
638  T_Scalar A = a22*a33 - a32*a23;
639  T_Scalar B = a23*a31 - a33*a21;
640  T_Scalar C = a21*a32 - a31*a22;
641 
642  T_Scalar det = a11*A + a12*B + a13*C;
643 
644  if (det == 0)
645  dest.fill(0);
646  else
647  dest = Matrix3<T_Scalar>(A, a13*a32 - a33*a12, a12*a23 - a22*a13,
648  B, a11*a33 - a31*a13, a13*a21 - a23*a11,
649  C, a12*a31 - a32*a11, a11*a22 - a21*a12) / det;
650  return det;
651  }
652  }
653  //-----------------------------------------------------------------------------
654 
663 
664  #if VL_PIPELINE_PRECISION == 2
665  typedef dmat3 mat3;
667  #else
668  typedef fmat3 mat3;
670  #endif
671 }
672 
673 #endif
Matrix3 getTransposed() const
Definition: Matrix3.hpp:331
Matrix3 & operator/=(T_Scalar d)
Definition: Matrix3.hpp:276
bool operator!=(const Matrix3 &m) const
Definition: Matrix3.hpp:156
Matrix3 & rotate(T_Scalar degrees)
Definition: Matrix3.hpp:418
Vector2< T_Scalar > getX() const
Definition: Matrix3.hpp:106
Matrix3 & operator-=(T_Scalar d)
Definition: Matrix3.hpp:241
Matrix3 & transpose()
Definition: Matrix3.hpp:316
static Matrix3 getNull()
Definition: Matrix3.hpp:369
Matrix3 & setIdentity()
Definition: Matrix3.hpp:374
Vector2< T_Scalar > getY() const
Definition: Matrix3.hpp:114
bool operator==(const Matrix3 &m) const
Definition: Matrix3.hpp:151
Matrix3 operator-(T_Scalar d) const
Definition: Matrix3.hpp:232
Matrix3 & preMultiply(const Matrix3 &m)
Definition: Matrix3.hpp:517
Matrix3(T_Scalar e00, T_Scalar e01, T_Scalar e02, T_Scalar e10, T_Scalar e11, T_Scalar e12, T_Scalar e20, T_Scalar e21, T_Scalar e22)
Definition: Matrix3.hpp:77
static Matrix3 getRotation(T_Scalar degrees)
Definition: Matrix3.hpp:603
T sin(T a)
Definition: glsl_math.hpp:199
Matrix3(const Matrix3< T > &m)
Definition: Matrix3.hpp:54
T degrees(T radians)
Definition: glsl_math.hpp:173
Matrix3 & invert(T_Scalar *determinant=NULL)
Definition: Matrix3.hpp:408
const T_Scalar & z() const
Definition: Vector3.hpp:92
Matrix2< T_Scalar > get2x2() const
Definition: Matrix3.hpp:291
Matrix3 & fill(T_Scalar val)
Definition: Matrix3.hpp:86
static Matrix3 getScaling(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:462
Matrix3 & translate(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:447
Matrix3< unsigned int > umat3
A 3x3 matrix using unsigned int precision.
Definition: Matrix3.hpp:662
static Matrix3 getScaling(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:468
Matrix3 & operator*=(const Matrix3 &m)
Definition: Matrix3.hpp:201
static Matrix3 getTranslation(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:428
The Matrix2 class is a template class that implements a generic 2x2 matrix, see also vl::dmat2...
Definition: Matrix2.hpp:49
T_Scalar getInverse(Matrix3 &dest) const
Definition: Matrix3.hpp:617
Vector2< T_Scalar > getT() const
Definition: Matrix3.hpp:122
bool isIdentity() const
Definition: Matrix3.hpp:285
static Matrix3 & multiply(Matrix3 &out, const Matrix3 &p, const Matrix3 &q)
Definition: Matrix3.hpp:492
Matrix3 & operator+=(T_Scalar d)
Definition: Matrix3.hpp:224
const T_Scalar & e(int i, int j) const
Definition: Matrix3.hpp:524
Matrix3(T_Scalar n)
Definition: Matrix3.hpp:71
Matrix3 & setY(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:137
Matrix3 & operator+=(const Matrix3 &m)
Definition: Matrix3.hpp:176
Matrix3 operator+(T_Scalar d) const
Definition: Matrix3.hpp:215
Matrix3 operator-() const
Definition: Matrix3.hpp:206
Matrix3 operator+(const Matrix3 &m) const
Definition: Matrix3.hpp:167
Visualization Library main namespace.
const double dDEG_TO_RAD
Constant to convert degree into radian using double precision.
Definition: std_types.hpp:66
static Matrix3 & getScaling(Matrix3 &out, const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:457
Matrix3 & translate(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:452
The Matrix3 class is a template class that implements a generic 3x3 matrix, see also vl::dmat3...
Definition: Matrix3.hpp:48
void set2x2(const Matrix2< T_Scalar > &m)
This writes only on the upper 2x2 part of the matrix without touching the last row and column...
Definition: Matrix3.hpp:300
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
Definition: Vector3.hpp:44
T_Scalar * ptr()
Definition: Matrix3.hpp:306
T_Scalar scalar_type
Definition: Matrix3.hpp:51
T_Scalar diff(const Matrix3 &other) const
Definition: Matrix3.hpp:94
Matrix3 operator*(T_Scalar d) const
Definition: Matrix3.hpp:249
Matrix3< double > dmat3
A 3x3 matrix using double precision.
Definition: Matrix3.hpp:656
const T_Scalar & e(int i, int j) const
Definition: Matrix2.hpp:403
static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:433
const T_Scalar * ptr() const
Definition: Matrix3.hpp:311
static Matrix3 & getScaling(Matrix3 &out, T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:474
static Matrix3 & getNull(Matrix3 &out)
Definition: Matrix3.hpp:363
const T_Scalar & y() const
Definition: Vector3.hpp:91
Matrix3< int > imat3
A 3x3 matrix using int precision.
Definition: Matrix3.hpp:660
static Matrix3 & getTranslation(Matrix3 &out, const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:423
Matrix3 & setT(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:144
static Matrix3 & getTranslation(Matrix3 &out, T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:439
Matrix3 operator/(T_Scalar d) const
Definition: Matrix3.hpp:266
#define NULL
Definition: OpenGLDefs.hpp:81
Matrix3(const Matrix3 &other)
Definition: Matrix3.hpp:61
Matrix3 & operator-=(const Matrix3 &m)
Definition: Matrix3.hpp:193
Vector3< T_Scalar > mVec[3]
Definition: Matrix3.hpp:532
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
Definition: Vector2.hpp:97
Matrix3< float > fmat3
A 3x3 matrix using float precision.
Definition: Matrix3.hpp:658
static Matrix3 getIdentity()
Definition: Matrix3.hpp:386
Matrix3 & scale(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:482
Matrix3 getInverse(T_Scalar *determinant=NULL) const
Definition: Matrix3.hpp:399
T cos(T a)
Definition: glsl_math.hpp:225
fmat3 mat3
Defined as: &#39;typedef fmat3 mat3&#39;. See also VL_PIPELINE_PRECISION.
Definition: Matrix3.hpp:669
const T_Scalar & x() const
Definition: Vector3.hpp:90
Matrix3 & scale(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:487
const T_Scalar & x() const
Definition: Vector2.hpp:133
Matrix3 & operator=(const Matrix3 &m)
Definition: Matrix3.hpp:161
T_Scalar & e(int i, int j)
Definition: Matrix3.hpp:525
Matrix3 & setNull()
Definition: Matrix3.hpp:357
const T_Scalar & y() const
Definition: Vector2.hpp:134
Matrix3 & operator*=(T_Scalar d)
Definition: Matrix3.hpp:258
bool isNull() const
Definition: Matrix3.hpp:348
Matrix3 & postMultiply(const Matrix3 &m)
Definition: Matrix3.hpp:511
#define VL_CHECK(expr)
Definition: checks.hpp:73
Matrix3 operator-(const Matrix3 &m) const
Definition: Matrix3.hpp:184
static Matrix3 & getIdentity(Matrix3 &out)
Definition: Matrix3.hpp:391
Matrix3 & setX(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:130
Matrix3 & getTransposed(Matrix3 &dest) const
Definition: Matrix3.hpp:340