Visualization Library 2.0.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  //-----------------------------------------------------------------------------
62  {
63  setIdentity();
64  }
65  //-----------------------------------------------------------------------------
66  explicit Matrix3(T_Scalar n)
67  {
68  setIdentity();
69  e(0,0) = e(1,1) = e(2,2) = n;
70  }
71  //-----------------------------------------------------------------------------
72  explicit Matrix3(T_Scalar e00, T_Scalar e01, T_Scalar e02,
73  T_Scalar e10, T_Scalar e11, T_Scalar e12,
74  T_Scalar e20, T_Scalar e21, T_Scalar e22)
75  {
76  e(0,0) = e00; e(0,1) = e01; e(0,2) = e02;
77  e(1,0) = e10; e(1,1) = e11; e(1,2) = e12;
78  e(2,0) = e20; e(2,1) = e21; e(2,2) = e22;
79  }
80  //-----------------------------------------------------------------------------
81  Matrix3& fill(T_Scalar val)
82  {
83  e(0,0) = e(1,0) = e(2,0) =
84  e(0,1) = e(1,1) = e(2,1) =
85  e(0,2) = e(1,2) = e(2,2) = val;
86  return *this;
87  }
88  //-----------------------------------------------------------------------------
89  T_Scalar diff(const Matrix3& other) const
90  {
91  T_Scalar err = 0;
92  for(int i=0; i<3; ++i)
93  for(int j=0; j<3; ++j)
94  if (e(j,i) > other.e(j,i)) // avoid fabs/abs
95  err += e(j,i) - other.e(j,i);
96  else
97  err += other.e(j,i) - e(j,i);
98  return err;
99  }
100  //-----------------------------------------------------------------------------
102  {
104  v.x() = e(0,0);
105  v.y() = e(1,0);
106  return v;
107  }
108  //-----------------------------------------------------------------------------
110  {
112  v.x() = e(0,1);
113  v.y() = e(1,1);
114  return v;
115  }
116  //-----------------------------------------------------------------------------
118  {
120  v.x() = e(0,2);
121  v.y() = e(1,2);
122  return v;
123  }
124  //-----------------------------------------------------------------------------
126  {
127  e(0,0) = v.x();
128  e(1,0) = v.y();
129  return *this;
130  }
131  //-----------------------------------------------------------------------------
133  {
134  e(0,1) = v.x();
135  e(1,1) = v.y();
136  return *this;
137  }
138  //-----------------------------------------------------------------------------
140  {
141  e(0,2) = v.x();
142  e(1,2) = v.y();
143  return *this;
144  }
145  //-----------------------------------------------------------------------------
146  bool operator==(const Matrix3& m) const
147  {
148  return memcmp(m.mVec, mVec, sizeof(T_Scalar)*9) == 0;
149  }
150  //-----------------------------------------------------------------------------
151  bool operator!=(const Matrix3& m) const
152  {
153  return !operator==(m);
154  }
155  //-----------------------------------------------------------------------------
157  {
158  memcpy(mVec, m.mVec, sizeof(T_Scalar)*9);
159  return *this;
160  }
161  //-----------------------------------------------------------------------------
162  Matrix3 operator+(const Matrix3& m) const
163  {
164  Matrix3 t;
165  for(int i=0; i<3; ++i)
166  for(int j=0; j<3; ++j)
167  t.e(j,i) = e(j,i) + m.e(j,i);
168  return t;
169  }
170  //-----------------------------------------------------------------------------
172  {
173  for(int i=0; i<3; ++i)
174  for(int j=0; j<3; ++j)
175  e(j,i) += m.e(j,i);
176  return *this;
177  }
178  //-----------------------------------------------------------------------------
179  Matrix3 operator-(const Matrix3& m) const
180  {
181  Matrix3 t;
182  for(int i=0; i<3; ++i)
183  for(int j=0; j<3; ++j)
184  t.e(j,i) = e(j,i) - m.e(j,i);
185  return t;
186  }
187  //-----------------------------------------------------------------------------
189  {
190  for(int i=0; i<3; ++i)
191  for(int j=0; j<3; ++j)
192  e(j,i) -= m.e(j,i);
193  return *this;
194  }
195  //-----------------------------------------------------------------------------
197  {
198  return postMultiply(m);
199  }
200  //-----------------------------------------------------------------------------
202  {
203  Matrix3 t;
204  for(int i=0; i<3; ++i)
205  for(int j=0; j<3; ++j)
206  t.e(j,i) = -e(j,i);
207  return t;
208  }
209  //-----------------------------------------------------------------------------
210  Matrix3 operator+(T_Scalar d) const
211  {
212  Matrix3 t;
213  for(int i=0; i<3; ++i)
214  for(int j=0; j<3; ++j)
215  t.e(j,i) = e(j,i) + d;
216  return t;
217  }
218  //-----------------------------------------------------------------------------
219  Matrix3& operator+=(T_Scalar d)
220  {
221  for(int i=0; i<3; ++i)
222  for(int j=0; j<3; ++j)
223  e(j,i) += d;
224  return *this;
225  }
226  //-----------------------------------------------------------------------------
227  Matrix3 operator-(T_Scalar d) const
228  {
229  Matrix3 t;
230  for(int i=0; i<3; ++i)
231  for(int j=0; j<3; ++j)
232  t.e(j,i) = e(j,i) - d;
233  return t;
234  }
235  //-----------------------------------------------------------------------------
236  Matrix3& operator-=(T_Scalar d)
237  {
238  for(int i=0; i<3; ++i)
239  for(int j=0; j<3; ++j)
240  e(j,i) -= d;
241  return *this;
242  }
243  //-----------------------------------------------------------------------------
244  Matrix3 operator*(T_Scalar d) const
245  {
246  Matrix3 t;
247  for(int i=0; i<3; ++i)
248  for(int j=0; j<3; ++j)
249  t.e(j,i) = e(j,i) * d;
250  return t;
251  }
252  //-----------------------------------------------------------------------------
253  Matrix3& operator*=(T_Scalar d)
254  {
255  for(int i=0; i<3; ++i)
256  for(int j=0; j<3; ++j)
257  e(j,i) *= d;
258  return *this;
259  }
260  //-----------------------------------------------------------------------------
261  Matrix3 operator/(T_Scalar d) const
262  {
263  d = (T_Scalar)1 / d;
264  Matrix3 t;
265  for(int i=0; i<3; ++i)
266  for(int j=0; j<3; ++j)
267  t.e(j,i) = e(j,i) * d;
268  return t;
269  }
270  //-----------------------------------------------------------------------------
271  Matrix3& operator/=(T_Scalar d)
272  {
273  d = (T_Scalar)1 / d;
274  for(int i=0; i<3; ++i)
275  for(int j=0; j<3; ++j)
276  e(j,i) *= d;
277  return *this;
278  }
279  //-----------------------------------------------------------------------------
280  bool isIdentity() const
281  {
282  Matrix3 i;
283  return memcmp(ptr(), i.ptr(), sizeof(T_Scalar)*9) == 0;
284  }
285  //-----------------------------------------------------------------------------
287  {
289  t.e(0,0) = e(0,0); t.e(1,0) = e(1,0);
290  t.e(0,1) = e(0,1); t.e(1,1) = e(1,1);
291  return t;
292  }
293  //-----------------------------------------------------------------------------
295  void set2x2(const Matrix2<T_Scalar>& m)
296  {
297  e(0,0) = m.e(0,0); e(1,0) = m.e(1,0);
298  e(0,1) = m.e(0,1); e(1,1) = m.e(1,1);
299  }
300  //-----------------------------------------------------------------------------
301  T_Scalar* ptr()
302  {
303  return &e(0,0);
304  }
305  //-----------------------------------------------------------------------------
306  const T_Scalar* ptr() const
307  {
308  return &e(0,0);
309  }
310  //-----------------------------------------------------------------------------
312  {
313  T_Scalar tmp;
314  for(int i=0; i<3; ++i)
315  {
316  for(int j=i; j<3; ++j)
317  {
318  tmp = e(j,i);
319  e(j,i) = e(i,j);
320  e(i,j) = tmp;
321  }
322  }
323  return *this;
324  }
325  //-----------------------------------------------------------------------------
327  {
328  Matrix3 m;
329  for(int i=0; i<3; ++i)
330  for(int j=0; j<3; ++j)
331  m.e(j,i) = e(i,j);
332  return m;
333  }
334  //-----------------------------------------------------------------------------
336  {
337  for(int i=0; i<3; ++i)
338  for(int j=0; j<3; ++j)
339  dest.e(j,i) = e(i,j);
340  return dest;
341  }
342  //-----------------------------------------------------------------------------
343  bool isNull() const
344  {
345  for(int i=0; i<3; ++i)
346  for(int j=0; j<3; ++j)
347  if(mVec[j][i] != 0)
348  return false;
349  return true;
350  }
351  //-----------------------------------------------------------------------------
353  {
354  fill(0);
355  return *this;
356  }
357  //-----------------------------------------------------------------------------
358  static Matrix3& getNull(Matrix3& out)
359  {
360  out.fill(0);
361  return out;
362  }
363  //-----------------------------------------------------------------------------
364  static Matrix3 getNull()
365  {
366  return Matrix3().fill(0);
367  }
368  //-----------------------------------------------------------------------------
370  {
371  static const T_Scalar I3d[] =
372  {
373  (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
374  (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
375  (T_Scalar)0, (T_Scalar)0, (T_Scalar)1,
376  };
377  memcpy(mVec, I3d, sizeof(T_Scalar)*9);
378  return *this;
379  }
380  //-----------------------------------------------------------------------------
382  {
383  return Matrix3();
384  }
385  //-----------------------------------------------------------------------------
387  {
388  out.setIdentity();
389  return out;
390  }
391  //-----------------------------------------------------------------------------
392  T_Scalar getInverse(Matrix3& dest) const;
393  //-----------------------------------------------------------------------------
394  Matrix3 getInverse(T_Scalar *determinant=NULL) const
395  {
396  Matrix3 tmp;
397  T_Scalar det = getInverse(tmp);
398  if (determinant)
399  *determinant = det;
400  return tmp;
401  }
402  //-----------------------------------------------------------------------------
403  Matrix3& invert(T_Scalar *determinant=NULL)
404  {
405  T_Scalar det = getInverse(*this);
406  if (determinant)
407  *determinant = det;
408  return *this;
409  }
410  //-----------------------------------------------------------------------------
411  static Matrix3 getRotation(T_Scalar degrees);
412  //-----------------------------------------------------------------------------
413  Matrix3& rotate(T_Scalar degrees)
414  {
415  return preMultiply(getRotation(degrees));
416  }
417  //-----------------------------------------------------------------------------
419  {
420  return getTranslation(out, v.x(), v.y());
421  }
422  //-----------------------------------------------------------------------------
424  {
425  return getTranslation(v.x(), v.y());
426  }
427  //-----------------------------------------------------------------------------
428  static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
429  {
430  Matrix3 m;
431  return getTranslation(m, x, y);
432  }
433  //-----------------------------------------------------------------------------
434  static Matrix3& getTranslation(Matrix3& out, T_Scalar x, T_Scalar y)
435  {
436  out.setIdentity();
437  out.e(0,2) = x;
438  out.e(1,2) = y;
439  return out;
440  }
441  //-----------------------------------------------------------------------------
442  Matrix3& translate(T_Scalar x, T_Scalar y)
443  {
444  return preMultiply(getTranslation(x,y));
445  }
446  //-----------------------------------------------------------------------------
448  {
449  return preMultiply(getTranslation(v));
450  }
451  //-----------------------------------------------------------------------------
452  static Matrix3& getScaling(Matrix3& out, const Vector2<T_Scalar>& v)
453  {
454  return getScaling(out, v.x(), v.y());
455  }
456  //-----------------------------------------------------------------------------
458  {
459  Matrix3 m;
460  return getScaling(m, v.x(), v.y());
461  }
462  //-----------------------------------------------------------------------------
463  static Matrix3 getScaling(T_Scalar x, T_Scalar y)
464  {
465  Matrix3 m;
466  return getScaling(m, x, y);
467  }
468  //-----------------------------------------------------------------------------
469  static Matrix3& getScaling(Matrix3& out, T_Scalar x, T_Scalar y)
470  {
471  out.setIdentity();
472  out.e(0,0) = x;
473  out.e(1,1) = y;
474  return out;
475  }
476  //-----------------------------------------------------------------------------
477  Matrix3& scale(T_Scalar x, T_Scalar y)
478  {
479  return preMultiply(getScaling(x,y));
480  }
481  //-----------------------------------------------------------------------------
483  {
484  return preMultiply(getScaling(v.x(),v.y()));
485  }
486  //-----------------------------------------------------------------------------
487  static Matrix3& multiply(Matrix3& out, const Matrix3& p, const Matrix3& q)
488  {
489  VL_CHECK(out.ptr() != p.ptr() && out.ptr() != q.ptr());
490 
491  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);
492  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);
493  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);
494 
495  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);
496  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);
497  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);
498 
499  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);
500  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);
501  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);
502 
503  return out;
504  }
505  //-----------------------------------------------------------------------------
507  {
509  return *this = multiply(t, *this, m);
510  }
511  //-----------------------------------------------------------------------------
513  {
515  return *this = multiply(t, m, *this);
516  }
517  //-----------------------------------------------------------------------------
518 
519  const T_Scalar& e(int i, int j) const { return mVec[j][i]; }
520  T_Scalar& e(int i, int j) { return mVec[j][i]; }
521 
522  private:
523  const Vector3<T_Scalar>& operator[](unsigned int i) const { VL_CHECK(i<3); return mVec[i]; }
524  Vector3<T_Scalar>& operator[](unsigned int i) { VL_CHECK(i<3); return mVec[i]; }
525 
526  protected:
528  };
529 
530  //-----------------------------------------------------------------------------
531  // OPERATORS
532  //-----------------------------------------------------------------------------
533  template<typename T_Scalar>
535  {
538  return t;
539  }
540  //-----------------------------------------------------------------------------
541  template<typename T_Scalar>
542  inline Matrix3<T_Scalar> operator+(T_Scalar d, const Matrix3<T_Scalar>& m)
543  {
544  return m + d;
545  }
546  //-----------------------------------------------------------------------------
547  template<typename T_Scalar>
548  inline Matrix3<T_Scalar> operator*(T_Scalar d, const Matrix3<T_Scalar>& m)
549  {
550  return m * d;
551  }
552  //-----------------------------------------------------------------------------
554  template<typename T_Scalar>
556  {
558  t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1) + v.z()*m.e(0,2);
559  t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1) + v.z()*m.e(1,2);
560  t.z() = v.x()*m.e(2,0) + v.y()*m.e(2,1) + v.z()*m.e(2,2);
561  return t;
562  }
563  //-----------------------------------------------------------------------------
566  template<typename T_Scalar>
568  {
570  t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1) /*+ 0*m.e(0,2)*/;
571  t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1) /*+ 0*m.e(1,2)*/;
572  return t;
573  }
574  //-----------------------------------------------------------------------------
576  template<typename T_Scalar>
578  {
580  t.x() = v.x()*m.e(0,0) + v.y()*m.e(1,0) + v.z()*m.e(2,0);
581  t.y() = v.x()*m.e(0,1) + v.y()*m.e(1,1) + v.z()*m.e(2,1);
582  t.z() = v.x()*m.e(0,2) + v.y()*m.e(1,2) + v.z()*m.e(2,2);
583  return t;
584  }
585  //-----------------------------------------------------------------------------
588  template<typename T_Scalar>
590  {
592  t.x() = v.x()*m.e(0,0) + v.y()*m.e(1,0) /*+ 0*m.e(2,0)*/;
593  t.y() = v.x()*m.e(0,1) + v.y()*m.e(1,1) /*+ 0*m.e(2,1)*/;
594  return t;
595  }
596  //-----------------------------------------------------------------------------
597  template<typename T_Scalar>
599  {
600  Matrix3<T_Scalar> rot;
601  degrees = degrees * (T_Scalar)dDEG_TO_RAD;
602  T_Scalar s = (T_Scalar) sin(degrees);
603  T_Scalar c = (T_Scalar) cos(degrees);
604  rot.e(0,0) = (T_Scalar)c;
605  rot.e(1,1) = (T_Scalar)c;
606  rot.e(1,0) = (T_Scalar)s;
607  rot.e(0,1) = -(T_Scalar)s;
608  return rot;
609  }
610  //-----------------------------------------------------------------------------
611  template<typename T_Scalar>
613  {
614  if (&dest == this)
615  {
616  Matrix3<T_Scalar> tmp;
617  T_Scalar det = getInverse(tmp);
618  dest = tmp;
619  return det;
620  }
621  else
622  {
623  const T_Scalar& a11 = e(0,0);
624  const T_Scalar& a21 = e(1,0);
625  const T_Scalar& a31 = e(2,0);
626  const T_Scalar& a12 = e(0,1);
627  const T_Scalar& a22 = e(1,1);
628  const T_Scalar& a32 = e(2,1);
629  const T_Scalar& a13 = e(0,2);
630  const T_Scalar& a23 = e(1,2);
631  const T_Scalar& a33 = e(2,2);
632 
633  T_Scalar A = a22*a33 - a32*a23;
634  T_Scalar B = a23*a31 - a33*a21;
635  T_Scalar C = a21*a32 - a31*a22;
636 
637  T_Scalar det = a11*A + a12*B + a13*C;
638 
639  if (det == 0)
640  dest.fill(0);
641  else
642  dest = Matrix3<T_Scalar>(A, a13*a32 - a33*a12, a12*a23 - a22*a13,
643  B, a11*a33 - a31*a13, a13*a21 - a23*a11,
644  C, a12*a31 - a32*a11, a11*a22 - a21*a12) / det;
645  return det;
646  }
647  }
648  //-----------------------------------------------------------------------------
649 
658 
659  #if VL_PIPELINE_PRECISION == 2
660  typedef dmat3 mat3;
662  #else
663  typedef fmat3 mat3;
665  #endif
666 }
667 
668 #endif
Matrix3 getTransposed() const
Definition: Matrix3.hpp:326
Matrix3 & operator/=(T_Scalar d)
Definition: Matrix3.hpp:271
bool operator!=(const Matrix3 &m) const
Definition: Matrix3.hpp:151
Matrix3 & rotate(T_Scalar degrees)
Definition: Matrix3.hpp:413
Vector2< T_Scalar > getX() const
Definition: Matrix3.hpp:101
Matrix3 & operator-=(T_Scalar d)
Definition: Matrix3.hpp:236
Matrix3 & transpose()
Definition: Matrix3.hpp:311
static Matrix3 getNull()
Definition: Matrix3.hpp:364
Matrix3 & setIdentity()
Definition: Matrix3.hpp:369
Vector2< T_Scalar > getY() const
Definition: Matrix3.hpp:109
bool operator==(const Matrix3 &m) const
Definition: Matrix3.hpp:146
Matrix3 operator-(T_Scalar d) const
Definition: Matrix3.hpp:227
Matrix3 & preMultiply(const Matrix3 &m)
Definition: Matrix3.hpp:512
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:72
static Matrix3 getRotation(T_Scalar degrees)
Definition: Matrix3.hpp:598
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:403
const T_Scalar & z() const
Definition: Vector3.hpp:91
Matrix2< T_Scalar > get2x2() const
Definition: Matrix3.hpp:286
Matrix3 & fill(T_Scalar val)
Definition: Matrix3.hpp:81
static Matrix3 getScaling(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:457
Matrix3 & translate(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:442
Matrix3< unsigned int > umat3
A 3x3 matrix using unsigned int precision.
Definition: Matrix3.hpp:657
static Matrix3 getScaling(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:463
Matrix3 & operator*=(const Matrix3 &m)
Definition: Matrix3.hpp:196
static Matrix3 getTranslation(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:423
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:612
Vector2< T_Scalar > getT() const
Definition: Matrix3.hpp:117
bool isIdentity() const
Definition: Matrix3.hpp:280
static Matrix3 & multiply(Matrix3 &out, const Matrix3 &p, const Matrix3 &q)
Definition: Matrix3.hpp:487
Matrix3 & operator+=(T_Scalar d)
Definition: Matrix3.hpp:219
const T_Scalar & e(int i, int j) const
Definition: Matrix3.hpp:519
Matrix3(T_Scalar n)
Definition: Matrix3.hpp:66
Matrix3 & setY(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:132
Matrix3 & operator+=(const Matrix3 &m)
Definition: Matrix3.hpp:171
Matrix3 operator+(T_Scalar d) const
Definition: Matrix3.hpp:210
Matrix3 operator-() const
Definition: Matrix3.hpp:201
Matrix3 operator+(const Matrix3 &m) const
Definition: Matrix3.hpp:162
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:452
Matrix3 & translate(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:447
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:295
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:301
T_Scalar scalar_type
Definition: Matrix3.hpp:51
T_Scalar diff(const Matrix3 &other) const
Definition: Matrix3.hpp:89
Matrix3 operator*(T_Scalar d) const
Definition: Matrix3.hpp:244
Matrix3< double > dmat3
A 3x3 matrix using double precision.
Definition: Matrix3.hpp:651
const T_Scalar & e(int i, int j) const
Definition: Matrix2.hpp:398
static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:428
const T_Scalar * ptr() const
Definition: Matrix3.hpp:306
static Matrix3 & getScaling(Matrix3 &out, T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:469
static Matrix3 & getNull(Matrix3 &out)
Definition: Matrix3.hpp:358
const T_Scalar & y() const
Definition: Vector3.hpp:90
Matrix3< int > imat3
A 3x3 matrix using int precision.
Definition: Matrix3.hpp:655
static Matrix3 & getTranslation(Matrix3 &out, const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:418
Matrix3 & setT(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:139
static Matrix3 & getTranslation(Matrix3 &out, T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:434
Matrix3 operator/(T_Scalar d) const
Definition: Matrix3.hpp:261
#define NULL
Definition: OpenGLDefs.hpp:81
Matrix3 & operator-=(const Matrix3 &m)
Definition: Matrix3.hpp:188
Vector3< T_Scalar > mVec[3]
Definition: Matrix3.hpp:527
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:653
static Matrix3 getIdentity()
Definition: Matrix3.hpp:381
Matrix3 & scale(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:477
Matrix3 getInverse(T_Scalar *determinant=NULL) const
Definition: Matrix3.hpp:394
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:664
const T_Scalar & x() const
Definition: Vector3.hpp:89
Matrix3 & scale(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:482
const T_Scalar & x() const
Definition: Vector2.hpp:132
Matrix3 & operator=(const Matrix3 &m)
Definition: Matrix3.hpp:156
T_Scalar & e(int i, int j)
Definition: Matrix3.hpp:520
Matrix3 & setNull()
Definition: Matrix3.hpp:352
const T_Scalar & y() const
Definition: Vector2.hpp:133
Matrix3 & operator*=(T_Scalar d)
Definition: Matrix3.hpp:253
bool isNull() const
Definition: Matrix3.hpp:343
Matrix3 & postMultiply(const Matrix3 &m)
Definition: Matrix3.hpp:506
#define VL_CHECK(expr)
Definition: checks.hpp:73
Matrix3 operator-(const Matrix3 &m) const
Definition: Matrix3.hpp:179
static Matrix3 & getIdentity(Matrix3 &out)
Definition: Matrix3.hpp:386
Matrix3 & setX(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:125
Matrix3 & getTransposed(Matrix3 &dest) const
Definition: Matrix3.hpp:335