FastUIDraw
matrix.hpp
Go to the documentation of this file.
1 /*!
2  * \file matrix.hpp
3  * \brief file matrix.hpp
4  *
5  * Adapted from: matrixGL.hpp of WRATH:
6  *
7  * Copyright 2013 by Nomovok Ltd.
8  * Contact: info@nomovok.com
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@nomovok.com>
16  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
17  *
18  */
19 
20 
21 #ifndef FASTUIDRAW_MATRIX_HPP
22 #define FASTUIDRAW_MATRIX_HPP
23 
24 #include <fastuidraw/util/math.hpp>
25 #include <fastuidraw/util/vecN.hpp>
26 
27 namespace fastuidraw {
28 
29 /*!\addtogroup Utility
30  * @{
31  */
32 
33 /*!
34  * \brief
35  * A generic matrix class. The operator() is overloaded
36  * to access elements of the matrix as follows:
37  * \verbatim
38  * matrix(0 , 0) matrix(0 , 1) matrix(0 , 2) ... matrix(0 , M - 1)
39  * matrix(1 , 0) matrix(1 , 1) matrix(1 , 2) ... matrix(1 , M - 1)
40  * .
41  * .
42  * .
43  * matrix(N - 2, 0) matrix(N - 2, 1) matrix(N - 1, 2) ... matrix(N - 2, M - 1)
44  * matrix(N - 1, 0) matrix(N - 1, 1) matrix(N - 1, 2) ... matrix(N - 1, M - 1)
45  * \endverbatim
46  *
47  * The data is represented internally with a 1-dimensional array with the
48  * packing order
49  *
50  * \code
51  * matrix(row, color) <--> raw_data()[row + N * col]
52  * \endcode
53  *
54  *\tparam N height of matrix
55  *\tparam M width of matrix
56  *\tparam T matrix entry type
57  */
58 template<size_t N, size_t M, typename T=float>
59 class matrixNxM
60 {
61 private:
62  vecN<T, N * M> m_data;
63 
64 public:
65  /*!
66  * \brief
67  * Typedef to underlying vecN that holds
68  * the matrix data.
69  */
71 
72  enum
73  {
74  /*!
75  * Enumeration value for size of the matrix.
76  */
78 
79  /*!
80  * Enumeration value for size of the matrix.
81  */
83  };
84 
85  /*!
86  * Copy-constructor for a NxN matrix.
87  * \param obj matrix to copy
88  */
89  matrixNxM(const matrixNxM &obj):
90  m_data(obj.m_data)
91  {}
92 
93  /*!
94  * Ctor.
95  * Initializes an NxN matrix as diagnols are 1
96  * and other values are 0, for square matrices,
97  * that is the identity matrix.
98  */
99  matrixNxM(void)
100  {
101  reset();
102  }
103 
104  /*!
105  * Set matrix as identity.
106  */
107  void
108  reset(void)
109  {
110  for(unsigned int i = 0; i < M; ++i)
111  {
112  for(unsigned int j = 0; j < N; ++j)
113  {
114  m_data[N * i + j] = (i == j) ? T(1): T(0);
115  }
116  }
117  }
118 
119  /*!
120  * Swaps the values between this and the parameter matrix.
121  * \param obj matrix to swap values with
122  */
123  void
125  {
126  m_data.swap(obj.m_data);
127  }
128 
129  /*!
130  * Returns a c-style pointer to the data.
131  */
132  T*
133  c_ptr(void) { return m_data.c_ptr(); }
134 
135  /*!
136  * Returns a constant c-style pointer to the data.
137  */
138  const T*
139  c_ptr(void) const { return m_data.c_ptr(); }
140 
141  /*!
142  * Returns a reference to raw data vector in the matrix.
143  */
145  raw_data(void) { return m_data; }
146 
147  /*!
148  * Returns a const reference to the raw data vectors in the matrix.
149  */
150  const vecN<T, N * M>&
151  raw_data(void) const { return m_data; }
152 
153  /*!
154  * Returns the named entry of the matrix
155  * \param row row(vertical coordinate) in the matrix
156  * \param col column(horizontal coordinate) in the matrix
157  */
158  T&
159  operator()(unsigned int row, unsigned int col)
160  {
161  FASTUIDRAWassert(row < N);
162  FASTUIDRAWassert(col < M);
163  return m_data[N * col + row];
164  }
165 
166  /*!
167  * Returns the named entry of the matrix
168  * \param row row(vertical coordinate) in the matrix
169  * \param col column(horizontal coordinate) in the matrix
170  */
171  const T&
172  operator()(unsigned int row, unsigned int col) const
173  {
174  FASTUIDRAWassert(row < N);
175  FASTUIDRAWassert(col < M);
176  return m_data[N * col + row];
177  }
178 
179  /*!
180  * Returns the named entry of the matrix; provided
181  * as a conveniance to interface with systems where
182  * access of elements is column then row or to more
183  * easily access the transpose of the matrix.
184  * \param col column(horizontal coordinate) in the matrix
185  * \param row row(vertical coordinate) in the matrix
186  */
187  T&
188  col_row(unsigned int col, unsigned row)
189  {
190  FASTUIDRAWassert(row < N);
191  FASTUIDRAWassert(col < M);
192  return m_data[N * col + row];
193  }
194 
195  /*!
196  * Returns the named entry of the matrix; provided
197  * as a conveniance to interface with systems where
198  * access of elements is column then row or to more
199  * easily access the transpose of the matrix.
200  * \param col column(horizontal coordinate) in the matrix
201  * \param row row(vertical coordinate) in the matrix
202  */
203  const T&
204  col_row(unsigned int col, unsigned row) const
205  {
206  FASTUIDRAWassert(row < N);
207  FASTUIDRAWassert(col < M);
208  return m_data[N * col + row];
209  }
210 
211  /*!
212  * Compute the transpose of the matrix
213  * \param retval location to which to write the transpose
214  */
215  void
217  {
218  for(unsigned int i = 0; i < N; ++i)
219  {
220  for(unsigned int j = 0; j < M; ++j)
221  {
222  retval.operator()(i,j) = operator()(j,i);
223  }
224  }
225  }
226 
227  /*!
228  * Returns a transpose of the matrix.
229  */
231  transpose(void) const
232  {
233  matrixNxM<M, N, T> retval;
234  transpose(retval);
235  return retval;
236  }
237 
238  /*!
239  * Operator for adding matrices together.
240  * \param matrix target matrix
241  */
242  matrixNxM
243  operator+(const matrixNxM &matrix) const
244  {
245  matrixNxM out;
246  out.m_data = m_data+matrix.m_data;
247  return out;
248  }
249 
250  /*!
251  * Operator for substracting matrices from each other.
252  * \param matrix target matrix
253  */
254  matrixNxM
255  operator-(const matrixNxM &matrix) const
256  {
257  matrixNxM out;
258  out.m_data = m_data-matrix.m_data;
259  return out;
260  }
261 
262  /*!
263  * Multiplies the matrix with a given scalar.
264  * \param value scalar to multiply with
265  */
266  matrixNxM
267  operator*(T value) const
268  {
269  matrixNxM out;
270  out.m_data = m_data*value;
271  return out;
272  }
273 
274  /*!
275  * Multiplies the given matrix with the given scalar
276  * and returns the resulting matrix.
277  * \param value scalar to multiply with
278  * \param matrix target matrix to multiply
279  */
280  friend
281  matrixNxM
282  operator*(T value, const matrixNxM &matrix)
283  {
284  matrixNxM out;
285  out.m_data = matrix.m_data*value;
286  return out;
287  }
288 
289  /*!
290  * Multiplies this matrix with the given matrix.
291  * \param matrix target matrix
292  */
293  template<size_t K>
295  operator*(const matrixNxM<M, K, T> &matrix) const
296  {
297  unsigned int i,j,k;
298  matrixNxM<N,K, T> out;
299 
300  for(i = 0; i < N; ++i)
301  {
302  for(j = 0; j < K; ++j)
303  {
304  out.operator()(i,j) = T(0);
305  for(k = 0; k < M; ++k)
306  {
307  out.operator()(i,j) += operator()(i,k) * matrix.operator()(k,j);
308  }
309  }
310  }
311  return out;
312  }
313 
314  /*!
315  * Computes the value of \ref matrixNxM * \ref vecN
316  * \param in right operand of multiply
317  */
318  vecN<T, N>
319  operator*(const vecN<T, M> &in) const
320  {
321  vecN<T, N> retval;
322 
323  for(unsigned int i = 0; i < N;++i)
324  {
325  retval[i] = T(0);
326  for(unsigned int j = 0; j < M; ++j)
327  {
328  retval[i] += operator()(i,j) * in[j];
329  }
330  }
331 
332  return retval;
333  }
334 
335  /*!
336  * Computes the value of \ref vecN * \ref matrixNxM
337  * \param in left operand of multiply
338  * \param matrix right operand of multiply
339  */
340  friend
341  vecN<T, M>
342  operator*(const vecN<T, N> &in, const matrixNxM &matrix)
343  {
344  vecN<T, M> retval;
345 
346  for(unsigned int i = 0; i < M; ++i)
347  {
348  retval[i] = T(0);
349  for(unsigned int j = 0; j < N; ++j)
350  {
351  retval[i] += in[j] * matrix.operator()(j,i);
352  }
353  }
354  return retval;
355  }
356 };
357 
358 /*!
359  * \brief
360  * Convenience typedef to matrixNxM<2, float>
361  */
363 
364 /*!
365  * \brief
366  * An orthogonal_projection_params holds the data to describe an
367  * orthogonal projection matrix without perspective.
368  */
369 template<typename T>
371 {
372 public:
373  T m_top; ///< Top edge of the clipping plane
374  T m_bottom; ///< Bottom edge of the clipping plane
375  T m_left; ///< Left edge of the clipping plane
376  T m_right; ///< Right edge of the clipping plane
377 
378  /*!
379  * Default constructor for projection parameters,
380  * values are unitialized.
381  */
383  {}
384 
385  /*!
386  * Creates the projection parameters instance according to the given parameters.
387  * \param l Left
388  * \param r Right
389  * \param t Top
390  * \param b Bottom
391  */
392  orthogonal_projection_params(T l, T r, T b, T t):
393  m_top(t), m_bottom(b), m_left(l), m_right(r)
394  {}
395 };
396 
397 /*!
398  * \brief
399  * A projection_params holds the data to describe a projection matrix with
400  * perspective.
401  */
402 template<typename T>
404 {
405 public:
406  T m_top; ///< Top edge of the clipping plane
407  T m_bottom; ///< Bottom edge of the clipping plane
408  T m_left; ///< Left edge of the clipping plane
409  T m_right; ///< Right edge of the clipping plane
410  T m_near; ///< Near clipping plane distance
411 
412  /*!
413  * Default constructor for projection parameters,
414  * values are unitialized.
415  */
417  {}
418 
419  /*!
420  * Creates the projection parameters instance according to the given parameters.
421  * \param l Left
422  * \param r Right
423  * \param t Top
424  * \param b Bottom
425  * \param n Near clipping plane
426  */
427  projection_params(T l, T r, T b, T t, T n):
428  m_top(t), m_bottom(b), m_left(l), m_right(r),
429  m_near(n)
430  {}
431 };
432 
433 /*!
434  * \brief
435  * A representation of a 3x3 matrix, that in addition to the NxN
436  * matrix functionality provides function for calculating the
437  * determinant.
438  */
439 template<typename T>
440 class matrix3x3:public matrixNxM<3, 3, T>
441 {
442 public:
443  /*!
444  * \brief
445  * Conveniance typedef to base class, matrixNxM<3, 3, T>
446  */
448 
449  /*!
450  * Initializes the 3x3 matrix as the identity,
451  * i.e. diagnols are 1 and other values are 0.
452  */
453  matrix3x3(void):base_class() {}
454 
455  /*!
456  * Copy-constructor for a 3x3 matrix.
457  * \param obj target matrix to copy.
458  */
459  matrix3x3(const base_class &obj):base_class(obj) {}
460 
461  /*!
462  * Construct a matrix3x3 M so that
463  * - M*vecN<T, 3>(1, 0, 0)=T
464  * - M*vecN<T, 3>(0, 1, 0)=B
465  * - M*vecN<T, 3>(0, 0, 1)=N
466  * \param t first row vector
467  * \param b second row vector
468  * \param n third row vector
469  */
470  matrix3x3(const vecN<T, 3> &t, const vecN<T, 3> &b, const vecN<T, 3> &n)
471  {
472  for(int i=0;i<3;++i)
473  {
474  this->operator()(i, 0) = t[i];
475  this->operator()(i, 1) = b[i];
476  this->operator()(i, 2) = n[i];
477  }
478  }
479 
480  /*!
481  * Initialize the 3x3 matrix with the upper 2x2 corner
482  * coming from a 2x2 martix and the right column
483  * coming from a 2-vector. The bottom is initialized
484  * as 0 in first and second column and bottom right as 1.
485  */
486  matrix3x3(const matrixNxM<2, 2, T> &mat, const vecN<T, 2> &vec = vecN<T, 2>(T(0)))
487  {
488  for(int i = 0; i < 2; ++i)
489  {
490  for(int j = 0; j < 2; ++j)
491  {
492  this->operator()(i,j) = mat(i, j);
493  }
494  this->operator()(2, i) = T(0);
495  this->operator()(i, 2) = vec[i];
496  }
497  this->operator()(2, 2) = T(1);
498  }
499 
500  /*!fn matrix3x3(const orthogonal_projection_params<T>&)
501  * Creates a 3x3 orthogonal projection matrix from the given projection
502  * parameters.
503  * \param P orthogonal projection parameters for the matrix
504  */
506  base_class()
507  {
508  orthogonal_projection_matrix(P);
509  }
510 
511  /*!fn matrix3x3(const orthogonal_projection_params<T>&)
512  * Creates a 3x3 projection matrix from the given projection
513  * parameters.
514  * \param P projection parameters for the matrix
515  */
517  base_class()
518  {
519  projection_matrix(P);
520  }
521 
522  /*!
523  * Apply shear on the right of the matrix, algebraicly equivalent to
524  * \code
525  * matrix3x3 M;
526  * M(0, 0) = sx;
527  * M(1, 1) = sy;
528  * *this = *this * M;
529  * \endcode
530  */
531  void
532  shear(T sx, T sy)
533  {
534  this->operator()(0, 0) *= sx;
535  this->operator()(1, 0) *= sx;
536  this->operator()(2, 0) *= sx;
537 
538  this->operator()(0, 1) *= sy;
539  this->operator()(1, 1) *= sy;
540  this->operator()(2, 1) *= sy;
541  }
542 
543  /*!
544  * Apply scale on the right of the matrix, algebraicly equivalent to
545  * \code
546  * matrix3x3 M;
547  * M(0, 0) = s;
548  * M(1, 1) = s;
549  * *this = *this * M;
550  * \endcode
551  */
552  void
553  scale(T s)
554  {
555  shear(s, s);
556  }
557 
558  /*!
559  * Apply translate on the right of the matrix, algebraicly equivalent to
560  * \code
561  * matrix3x3 M;
562  * M(0, 2) = x;
563  * M(1, 2) = y;
564  * *this = *this * M;
565  * \endcode
566  * \param x amount by which to translate horizontally
567  * \param y amount by which to translate vertically
568  */
569  void
570  translate(T x, T y)
571  {
572  this->operator()(0, 2) += x * this->operator()(0, 0) + y * this->operator()(0, 1);
573  this->operator()(1, 2) += x * this->operator()(1, 0) + y * this->operator()(1, 1);
574  this->operator()(2, 2) += x * this->operator()(2, 0) + y * this->operator()(2, 1);
575  }
576 
577  /*!
578  * Provided as an override conveniance, equivalent to
579  * \code
580  * translate(p.x(), p.y())
581  * \endcode
582  * \param p amount by which to translate
583  */
584  void
586  {
587  translate(p.x(), p.y());
588  }
589 
590  /*!
591  * Apply a rotation matrix on the right of the matrix, algebraicly equivalent to
592  * \code
593  * matrix3x3 M;
594  * s = t_sin(angle);
595  * c = t_cos(angle);
596  * M(0, 0) = c;
597  * M(1, 0) = s;
598  * M(0, 1) = -s;
599  * M(1, 1) = c;
600  * *this = *this * M;
601  * \endcode
602  * \param angle amount by which to rotate in radians.
603  */
604  void
605  rotate(T angle)
606  {
607  matrix3x3 &me(*this);
608  matrixNxM<2, 2, T> tr, temp;
609  T s, c;
610 
611  s = t_sin(angle);
612  c = t_cos(angle);
613 
614  tr(0, 0) = c;
615  tr(1, 0) = s;
616 
617  tr(0, 1) = -s;
618  tr(1, 1) = c;
619 
620  temp(0, 0) = me(0, 0);
621  temp(0, 1) = me(0, 1);
622  temp(1, 0) = me(1, 0);
623  temp(1, 1) = me(1, 1);
624 
625  temp = temp * tr;
626 
627  me(0, 0) = temp(0, 0);
628  me(0, 1) = temp(0, 1);
629  me(1, 0) = temp(1, 0);
630  me(1, 1) = temp(1, 1);
631  }
632 
633  /*!
634  * Sets the matrix variables to correspond an orthogonal projection matrix
635  * determined by the given projection parameters.
636  * \param P orthogonal projection parameters for this matrix
637  */
638  void
640  {
641  this->operator()(0, 0) = T(2) / (P.m_right - P.m_left);
642  this->operator()(1, 0) = T(0);
643  this->operator()(2, 0) = T(0);
644 
645  this->operator()(0, 1) = T(0);
646  this->operator()(1, 1) = T(2) / (P.m_top - P.m_bottom);
647  this->operator()(2, 1) = T(0);
648 
649  this->operator()(0, 2) = (P.m_right + P.m_left) / (P.m_left - P.m_right);
650  this->operator()(1, 2) = (P.m_top + P.m_bottom) / (P.m_bottom - P.m_top);
651  this->operator()(2, 2) = T(1);
652  }
653 
654  /*!
655  * Sets the matrix variables to correspond the inverse to an
656  * orthogonal projection matrix determined by the given projection
657  * parameters.
658  * \param P orthogonal projection parameters for this matrix
659  */
660  void
662  {
663  this->operator()(0, 0) = (P.m_right - P.m_left) / T(2);
664  this->operator()(1, 0) = T(0);
665  this->operator()(2, 0) = T(0);
666 
667  this->operator()(0, 1) = T(0);
668  this->operator()(1, 1) = (P.m_top - P.m_bottom) / T(2);
669  this->operator()(2, 1) = T(0);
670 
671  this->operator()(0, 2) = (P.m_right + P.m_left) / T(2);
672  this->operator()(1, 2) = (P.m_top + P.m_bottom) / T(2);
673  this->operator()(2, 2) = T(1);
674  }
675 
676  /*!
677  * Convenience function to matrix3x3::orthogonal_projection_matrix(const project_params<T>&).
678  * \param l Left
679  * \param r Right
680  * \param b Bottom
681  * \param t Top
682  */
683  void
684  orthogonal_projection_matrix(T l, T r, T b, T t)
685  {
686  orthogonal_projection_matrix(orthogonal_projection_params<T>(l, r, b, t));
687  }
688 
689  /*!
690  * Sets the matrix values to correspond the projection matrix
691  * determined by the given projection parameters.
692  * \param P projection parameters for this matrix
693  */
694  void
696  {
697  this->operator()(0, 0) = T(2) * P.m_near / (P.m_right - P.m_left);
698  this->operator()(1, 0) = T(0);
699  this->operator()(2, 0) = T(0);
700 
701  this->operator()(0, 1) = T(0);
702  this->operator()(1, 1) = T(2) * P.m_near / (P.m_top - P.m_bottom);
703  this->operator()(2, 1) = T(0);
704 
705  this->operator()(0, 2) = T(0);
706  this->operator()(1, 2) = T(0);
707  this->operator()(2, 2) = T(-1);
708  }
709 
710  /*!
711  * Calculates the determinant for the matrix.
712  */
713  T
714  determinate(void) const
715  {
716  const base_class &me(*this);
717  return me(0, 0) * (me(1, 1) * me(2, 2) - me(1, 2) *me(2, 1))
718  - me(1, 0) * (me(0, 1) * me(2, 2) - me(2, 1) * me(0, 2))
719  + me(2, 0) * (me(0, 1) * me(1, 2) - me(1, 1) * me(0, 2)) ;
720  }
721 
722  /*!
723  * Compute the transpose of the cofactor matrix
724  * \param result location to which to place the cofactor matrx
725  */
726  void
728  {
729  const base_class &me(*this);
730  result(0, 0) = (me(1, 1) * me(2, 2) - me(2, 1) * me(1, 2));
731  result(0, 1) = -(me(0, 1) * me(2, 2) - me(0, 2) * me(2, 1));
732  result(0, 2) = (me(0, 1) * me(1, 2) - me(0, 2) * me(1, 1));
733  result(1, 0) = -(me(1, 0) * me(2, 2) - me(1, 2) * me(2, 0));
734  result(1, 1) = (me(0, 0) * me(2, 2) - me(0, 2) * me(2, 0));
735  result(1, 2) = -(me(0, 0) * me(1, 2) - me(1, 0) * me(0, 2));
736  result(2, 0) = (me(1, 0) * me(2, 1) - me(2, 0) * me(1, 1));
737  result(2, 1) = -(me(0, 0) * me(2, 1) - me(2, 0) * me(0, 1));
738  result(2, 2) = (me(0, 0) * me(1, 1) - me(1, 0) * me(0, 1));
739  }
740 
741  /*!
742  * Compute the cofactor matrix
743  * \param result location to which to place the cofactor matrx
744  */
745  void
746  cofactor(matrix3x3 &result) const
747  {
748  const base_class &me(*this);
749  result(0, 0) = (me(1, 1) * me(2, 2) - me(2, 1) * me(1, 2));
750  result(1, 0) = -(me(0, 1) * me(2, 2) - me(0, 2) * me(2, 1));
751  result(2, 0) = (me(0, 1) * me(1, 2) - me(0, 2) * me(1, 1));
752  result(0, 1) = -(me(1, 0) * me(2, 2) - me(1, 2) * me(2, 0));
753  result(1, 1) = (me(0, 0) * me(2, 2) - me(0, 2) * me(2, 0));
754  result(2, 1) = -(me(0, 0) * me(1, 2) - me(1, 0) * me(0, 2));
755  result(0, 2) = (me(1, 0) * me(2, 1) - me(2, 0) * me(1, 1));
756  result(1, 2) = -(me(0, 0) * me(2, 1) - me(2, 0) * me(0, 1));
757  result(2, 2) = (me(0, 0) * me(1, 1) - me(1, 0) * me(0, 1));
758  }
759 
760  /*!
761  * Compute the inverse of a matrix.
762  * \param result location to which to place the inverse matrix
763  */
764  void
765  inverse(matrix3x3 &result) const
766  {
767  T det, recipDet;
768  det = determinate();
769  recipDet = T(1) / det;
770 
771  cofactor_transpose(result);
772  result.raw_data() *= recipDet;
773  }
774 
775  /*!
776  * Compute the inverse transpose of a matrix.
777  * \param result location to which to place the inverse matrix
778  */
779  void
781  {
782  T det, recipDet;
783  det = determinate();
784  recipDet = T(1) / det;
785 
786  cofactor(result);
787  result.raw_data() *= recipDet;
788  }
789 
790  /*!
791  * Checks whether the matrix reverses orientation. This check is equivalent
792  * to determinant < T(0).
793  */
794  bool
796  {
797  return determinate() < T(0);
798  }
799 
800 };
801 
802 /*!
803  * \brief
804  * Convenience typedef to matrix3x3<float>
805  */
807 
808 /*!
809  * \brief
810  * Convenience typedef for projection_params<float>
811  */
813 
814 /*!
815  * \brief
816  * Convenience typedef for orthogonal_projection_params<float>
817  */
819 
820 /*! @} */
821 } //namespace
822 
823 #endif
A representation of a 3x3 matrix, that in addition to the NxN matrix functionality provides function ...
Definition: matrix.hpp:440
T * c_ptr(void)
Definition: vecN.hpp:400
matrix3x3(const projection_params< T > &P)
Definition: matrix.hpp:516
matrixNxM operator+(const matrixNxM &matrix) const
Definition: matrix.hpp:243
float t_cos(float x)
Definition: math.hpp:82
bool reverses_orientation(void) const
Definition: matrix.hpp:795
void inverse(matrix3x3 &result) const
Definition: matrix.hpp:765
An orthogonal_projection_params holds the data to describe an orthogonal projection matrix without pe...
Definition: matrix.hpp:370
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
T m_bottom
Bottom edge of the clipping plane.
Definition: matrix.hpp:407
vecN< T, N *M > & raw_data(void)
Definition: matrix.hpp:145
A generic matrix class. The operator() is overloaded to access elements of the matrix as follows: ...
Definition: matrix.hpp:59
matrix3x3(const orthogonal_projection_params< T > &P)
Definition: matrix.hpp:505
void cofactor_transpose(matrix3x3 &result) const
Definition: matrix.hpp:727
void reset(void)
Definition: matrix.hpp:108
projection_params(T l, T r, T b, T t, T n)
Definition: matrix.hpp:427
void rotate(T angle)
Definition: matrix.hpp:605
void translate(T x, T y)
Definition: matrix.hpp:570
const T & operator()(unsigned int row, unsigned int col) const
Definition: matrix.hpp:172
matrixNxM< 2, 2, float > float2x2
Convenience typedef to matrixNxM<2, float>
Definition: matrix.hpp:362
matrix3x3(const base_class &obj)
Definition: matrix.hpp:459
matrix3x3(const vecN< T, 3 > &t, const vecN< T, 3 > &b, const vecN< T, 3 > &n)
Definition: matrix.hpp:470
T m_top
Top edge of the clipping plane.
Definition: matrix.hpp:373
friend vecN< T, M > operator*(const vecN< T, N > &in, const matrixNxM &matrix)
Definition: matrix.hpp:342
void projection_matrix(const projection_params< T > &P)
Definition: matrix.hpp:695
orthogonal_projection_params(T l, T r, T b, T t)
Definition: matrix.hpp:392
T m_top
Top edge of the clipping plane.
Definition: matrix.hpp:406
T m_near
Near clipping plane distance.
Definition: matrix.hpp:410
file math.hpp
const T & col_row(unsigned int col, unsigned row) const
Definition: matrix.hpp:204
T & col_row(unsigned int col, unsigned row)
Definition: matrix.hpp:188
vecN< T, N > operator*(const vecN< T, M > &in) const
Definition: matrix.hpp:319
T m_left
Left edge of the clipping plane.
Definition: matrix.hpp:408
vecN< T, N *M > raw_data_type
Typedef to underlying vecN that holds the matrix data.
Definition: matrix.hpp:70
matrixNxM(const matrixNxM &obj)
Definition: matrix.hpp:89
orthogonal_projection_params< float > float_orthogonal_projection_params
Convenience typedef for orthogonal_projection_params<float>
Definition: matrix.hpp:818
void swap(matrixNxM &obj)
Definition: matrix.hpp:124
T m_bottom
Bottom edge of the clipping plane.
Definition: matrix.hpp:374
reference y(void)
Definition: vecN.hpp:443
T m_right
Right edge of the clipping plane.
Definition: matrix.hpp:376
float t_sin(float x)
Definition: math.hpp:75
matrixNxM< N, K, T > operator*(const matrixNxM< M, K, T > &matrix) const
Definition: matrix.hpp:295
matrix3x3< float > float3x3
Convenience typedef to matrix3x3<float>
Definition: matrix.hpp:806
projection_params< float > float_projection_params
Convenience typedef for projection_params<float>
Definition: matrix.hpp:812
const T * c_ptr(void) const
Definition: matrix.hpp:139
T determinate(void) const
Definition: matrix.hpp:714
T & operator()(unsigned int row, unsigned int col)
Definition: matrix.hpp:159
file vecN.hpp
void orthogonal_projection_matrix(T l, T r, T b, T t)
Definition: matrix.hpp:684
void orthogonal_projection_matrix(const orthogonal_projection_params< T > &P)
Definition: matrix.hpp:639
A projection_params holds the data to describe a projection matrix with perspective.
Definition: matrix.hpp:403
void inverse_orthogonal_projection_matrix(const orthogonal_projection_params< T > &P)
Definition: matrix.hpp:661
const vecN< T, N *M > & raw_data(void) const
Definition: matrix.hpp:151
matrixNxM operator-(const matrixNxM &matrix) const
Definition: matrix.hpp:255
void translate(const vecN< T, 2 > &p)
Definition: matrix.hpp:585
T m_right
Right edge of the clipping plane.
Definition: matrix.hpp:409
void inverse_transpose(matrix3x3 &result) const
Definition: matrix.hpp:780
reference x(void)
Definition: vecN.hpp:435
void cofactor(matrix3x3 &result) const
Definition: matrix.hpp:746
friend matrixNxM operator*(T value, const matrixNxM &matrix)
Definition: matrix.hpp:282
void transpose(matrixNxM< M, N, T > &retval) const
Definition: matrix.hpp:216
matrixNxM operator*(T value) const
Definition: matrix.hpp:267
void swap(vecN &obj)
Definition: vecN.hpp:388
matrix3x3(const matrixNxM< 2, 2, T > &mat, const vecN< T, 2 > &vec=vecN< T, 2 >(T(0)))
Definition: matrix.hpp:486
matrixNxM< 3, 3, T > base_class
Conveniance typedef to base class, matrixNxM<3, 3, T>
Definition: matrix.hpp:447
#define FASTUIDRAWassert(X)
Definition: util.hpp:99
T m_left
Left edge of the clipping plane.
Definition: matrix.hpp:375
matrixNxM< M, N, T > transpose(void) const
Definition: matrix.hpp:231
void shear(T sx, T sy)
Definition: matrix.hpp:532