Visualization Library 2.0.0-b3

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-2017, 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  for(int j=i; j<3; ++j)
316  {
317  tmp = e(j,i);
318  e(j,i) = e(i,j);
319  e(i,j) = tmp;
320  }
321  return *this;
322  }
323  //-----------------------------------------------------------------------------
325  {
326  Matrix3 m;
327  for(int i=0; i<3; ++i)
328  for(int j=0; j<3; ++j)
329  m.e(j,i) = e(i,j);
330  return m;
331  }
332  //-----------------------------------------------------------------------------
334  {
335  for(int i=0; i<3; ++i)
336  for(int j=0; j<3; ++j)
337  dest.e(j,i) = e(i,j);
338  return dest;
339  }
340  //-----------------------------------------------------------------------------
341  bool isNull() const
342  {
343  for(int i=0; i<3; ++i)
344  for(int j=0; j<3; ++j)
345  if(mVec[j][i] != 0)
346  return false;
347  return true;
348  }
349  //-----------------------------------------------------------------------------
351  {
352  fill(0);
353  return *this;
354  }
355  //-----------------------------------------------------------------------------
356  static Matrix3& getNull(Matrix3& out)
357  {
358  out.fill(0);
359  return out;
360  }
361  //-----------------------------------------------------------------------------
362  static Matrix3 getNull()
363  {
364  return Matrix3().fill(0);
365  }
366  //-----------------------------------------------------------------------------
368  {
369  static const T_Scalar I3d[] =
370  {
371  (T_Scalar)1, (T_Scalar)0, (T_Scalar)0,
372  (T_Scalar)0, (T_Scalar)1, (T_Scalar)0,
373  (T_Scalar)0, (T_Scalar)0, (T_Scalar)1,
374  };
375  memcpy(mVec, I3d, sizeof(T_Scalar)*9);
376  return *this;
377  }
378  //-----------------------------------------------------------------------------
380  {
381  return Matrix3();
382  }
383  //-----------------------------------------------------------------------------
385  {
386  out.setIdentity();
387  return out;
388  }
389  //-----------------------------------------------------------------------------
390  T_Scalar getInverse(Matrix3& dest) const;
391  //-----------------------------------------------------------------------------
392  Matrix3 getInverse(T_Scalar *determinant=NULL) const
393  {
394  Matrix3 tmp;
395  T_Scalar det = getInverse(tmp);
396  if (determinant)
397  *determinant = det;
398  return tmp;
399  }
400  //-----------------------------------------------------------------------------
401  Matrix3& invert(T_Scalar *determinant=NULL)
402  {
403  T_Scalar det = getInverse(*this);
404  if (determinant)
405  *determinant = det;
406  return *this;
407  }
408  //-----------------------------------------------------------------------------
409  static Matrix3 getRotation(T_Scalar degrees);
410  //-----------------------------------------------------------------------------
411  Matrix3& rotate(T_Scalar degrees)
412  {
413  return preMultiply(getRotation(degrees));
414  }
415  //-----------------------------------------------------------------------------
417  {
418  return getTranslation(out, v.x(), v.y());
419  }
420  //-----------------------------------------------------------------------------
422  {
423  return getTranslation(v.x(), v.y());
424  }
425  //-----------------------------------------------------------------------------
426  static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
427  {
428  Matrix3 m;
429  return getTranslation(m, x, y);
430  }
431  //-----------------------------------------------------------------------------
432  static Matrix3& getTranslation(Matrix3& out, T_Scalar x, T_Scalar y)
433  {
434  out.setIdentity();
435  out.e(0,2) = x;
436  out.e(1,2) = y;
437  return out;
438  }
439  //-----------------------------------------------------------------------------
440  Matrix3& translate(T_Scalar x, T_Scalar y)
441  {
442  return preMultiply(getTranslation(x,y));
443  }
444  //-----------------------------------------------------------------------------
446  {
447  return preMultiply(getTranslation(v));
448  }
449  //-----------------------------------------------------------------------------
450  static Matrix3& getScaling(Matrix3& out, const Vector2<T_Scalar>& v)
451  {
452  return getScaling(out, v.x(), v.y());
453  }
454  //-----------------------------------------------------------------------------
456  {
457  Matrix3 m;
458  return getScaling(m, v.x(), v.y());
459  }
460  //-----------------------------------------------------------------------------
461  static Matrix3 getScaling(T_Scalar x, T_Scalar y)
462  {
463  Matrix3 m;
464  return getScaling(m, x, y);
465  }
466  //-----------------------------------------------------------------------------
467  static Matrix3& getScaling(Matrix3& out, T_Scalar x, T_Scalar y)
468  {
469  out.setIdentity();
470  out.e(0,0) = x;
471  out.e(1,1) = y;
472  return out;
473  }
474  //-----------------------------------------------------------------------------
475  Matrix3& scale(T_Scalar x, T_Scalar y)
476  {
477  return preMultiply(getScaling(x,y));
478  }
479  //-----------------------------------------------------------------------------
481  {
482  return preMultiply(getScaling(v.x(),v.y()));
483  }
484  //-----------------------------------------------------------------------------
485  static Matrix3& multiply(Matrix3& out, const Matrix3& p, const Matrix3& q)
486  {
487  VL_CHECK(out.ptr() != p.ptr() && out.ptr() != q.ptr());
488 
489  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);
490  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);
491  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);
492 
493  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);
494  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);
495  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);
496 
497  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);
498  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);
499  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);
500 
501  return out;
502  }
503  //-----------------------------------------------------------------------------
505  {
507  return *this = multiply(t, *this, m);
508  }
509  //-----------------------------------------------------------------------------
511  {
513  return *this = multiply(t, m, *this);
514  }
515  //-----------------------------------------------------------------------------
516 
517  const T_Scalar& e(int i, int j) const { return mVec[j][i]; }
518  T_Scalar& e(int i, int j) { return mVec[j][i]; }
519 
520  private:
521  const Vector3<T_Scalar>& operator[](unsigned int i) const { VL_CHECK(i<3); return mVec[i]; }
522  Vector3<T_Scalar>& operator[](unsigned int i) { VL_CHECK(i<3); return mVec[i]; }
523 
524  protected:
526  };
527 
528  //-----------------------------------------------------------------------------
529  // OPERATORS
530  //-----------------------------------------------------------------------------
531  template<typename T_Scalar>
533  {
536  return t;
537  }
538  //-----------------------------------------------------------------------------
539  template<typename T_Scalar>
540  inline Matrix3<T_Scalar> operator+(T_Scalar d, const Matrix3<T_Scalar>& m)
541  {
542  return m + d;
543  }
544  //-----------------------------------------------------------------------------
545  template<typename T_Scalar>
546  inline Matrix3<T_Scalar> operator*(T_Scalar d, const Matrix3<T_Scalar>& m)
547  {
548  return m * d;
549  }
550  //-----------------------------------------------------------------------------
552  template<typename T_Scalar>
554  {
556  t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1) + v.z()*m.e(0,2);
557  t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1) + v.z()*m.e(1,2);
558  t.z() = v.x()*m.e(2,0) + v.y()*m.e(2,1) + v.z()*m.e(2,2);
559  return t;
560  }
561  //-----------------------------------------------------------------------------
564  template<typename T_Scalar>
566  {
568  t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1) /*+ 0*m.e(0,2)*/;
569  t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1) /*+ 0*m.e(1,2)*/;
570  return t;
571  }
572  //-----------------------------------------------------------------------------
574  template<typename T_Scalar>
576  {
578  t.x() = v.x()*m.e(0,0) + v.y()*m.e(1,0) + v.z()*m.e(2,0);
579  t.y() = v.x()*m.e(0,1) + v.y()*m.e(1,1) + v.z()*m.e(2,1);
580  t.z() = v.x()*m.e(0,2) + v.y()*m.e(1,2) + v.z()*m.e(2,2);
581  return t;
582  }
583  //-----------------------------------------------------------------------------
586  template<typename T_Scalar>
588  {
590  t.x() = v.x()*m.e(0,0) + v.y()*m.e(1,0) /*+ 0*m.e(2,0)*/;
591  t.y() = v.x()*m.e(0,1) + v.y()*m.e(1,1) /*+ 0*m.e(2,1)*/;
592  return t;
593  }
594  //-----------------------------------------------------------------------------
595  template<typename T_Scalar>
597  {
598  Matrix3<T_Scalar> rot;
599  degrees = degrees * (T_Scalar)dDEG_TO_RAD;
600  T_Scalar s = (T_Scalar) sin(degrees);
601  T_Scalar c = (T_Scalar) cos(degrees);
602  rot.e(0,0) = (T_Scalar)c;
603  rot.e(1,1) = (T_Scalar)c;
604  rot.e(1,0) = (T_Scalar)s;
605  rot.e(0,1) = -(T_Scalar)s;
606  return rot;
607  }
608  //-----------------------------------------------------------------------------
609  template<typename T_Scalar>
611  {
612  if (&dest == this)
613  {
614  Matrix3<T_Scalar> tmp;
615  T_Scalar det = getInverse(tmp);
616  dest = tmp;
617  return det;
618  }
619  else
620  {
621  const T_Scalar& a11 = e(0,0);
622  const T_Scalar& a21 = e(1,0);
623  const T_Scalar& a31 = e(2,0);
624  const T_Scalar& a12 = e(0,1);
625  const T_Scalar& a22 = e(1,1);
626  const T_Scalar& a32 = e(2,1);
627  const T_Scalar& a13 = e(0,2);
628  const T_Scalar& a23 = e(1,2);
629  const T_Scalar& a33 = e(2,2);
630 
631  T_Scalar A = a22*a33 - a32*a23;
632  T_Scalar B = a23*a31 - a33*a21;
633  T_Scalar C = a21*a32 - a31*a22;
634 
635  T_Scalar det = a11*A + a12*B + a13*C;
636 
637  if (det == 0)
638  dest.fill(0);
639  else
640  dest = Matrix3<T_Scalar>(A, a13*a32 - a33*a12, a12*a23 - a22*a13,
641  B, a11*a33 - a31*a13, a13*a21 - a23*a11,
642  C, a12*a31 - a32*a11, a11*a22 - a21*a12) / det;
643  return det;
644  }
645  }
646  //-----------------------------------------------------------------------------
647 
656 
657  #if VL_PIPELINE_PRECISION == 2
658  typedef dmat3 mat3;
660  #else
661  typedef fmat3 mat3;
663  #endif
664 }
665 
666 #endif
Matrix3 getTransposed() const
Definition: Matrix3.hpp:324
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:411
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:362
Matrix3 & setIdentity()
Definition: Matrix3.hpp:367
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:510
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:596
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:401
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:455
Matrix3 & translate(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:440
Matrix3< unsigned int > umat3
A 3x3 matrix using unsigned int precision.
Definition: Matrix3.hpp:655
static Matrix3 getScaling(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:461
Matrix3 & operator*=(const Matrix3 &m)
Definition: Matrix3.hpp:196
static Matrix3 getTranslation(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:421
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:610
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:485
Matrix3 & operator+=(T_Scalar d)
Definition: Matrix3.hpp:219
const T_Scalar & e(int i, int j) const
Definition: Matrix3.hpp:517
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:450
Matrix3 & translate(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:445
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:649
const T_Scalar & e(int i, int j) const
Definition: Matrix2.hpp:396
static Matrix3 getTranslation(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:426
const T_Scalar * ptr() const
Definition: Matrix3.hpp:306
static Matrix3 & getScaling(Matrix3 &out, T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:467
static Matrix3 & getNull(Matrix3 &out)
Definition: Matrix3.hpp:356
const T_Scalar & y() const
Definition: Vector3.hpp:90
Matrix3< int > imat3
A 3x3 matrix using int precision.
Definition: Matrix3.hpp:653
static Matrix3 & getTranslation(Matrix3 &out, const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:416
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:432
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:525
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:651
static Matrix3 getIdentity()
Definition: Matrix3.hpp:379
Matrix3 & scale(T_Scalar x, T_Scalar y)
Definition: Matrix3.hpp:475
Matrix3 getInverse(T_Scalar *determinant=NULL) const
Definition: Matrix3.hpp:392
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:662
const T_Scalar & x() const
Definition: Vector3.hpp:89
Matrix3 & scale(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:480
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:518
Matrix3 & setNull()
Definition: Matrix3.hpp:350
const T_Scalar & y() const
Definition: Vector2.hpp:133
Matrix3 & operator*=(T_Scalar d)
Definition: Matrix3.hpp:253
bool isNull() const
Definition: Matrix3.hpp:341
Matrix3 & postMultiply(const Matrix3 &m)
Definition: Matrix3.hpp:504
#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:384
Matrix3 & setX(const Vector2< T_Scalar > &v)
Definition: Matrix3.hpp:125
Matrix3 & getTransposed(Matrix3 &dest) const
Definition: Matrix3.hpp:333