21 #ifndef FASTUIDRAW_MATRIX_HPP 22 #define FASTUIDRAW_MATRIX_HPP 58 template<
size_t N,
size_t M,
typename T=
float>
110 for(
unsigned int i = 0; i < M; ++i)
112 for(
unsigned int j = 0; j < N; ++j)
114 m_data[N * i + j] = (i == j) ? T(1): T(0);
126 m_data.
swap(obj.m_data);
163 return m_data[N * col + row];
176 return m_data[N * col + row];
192 return m_data[N * col + row];
208 return m_data[N * col + row];
218 for(
unsigned int i = 0; i < N; ++i)
220 for(
unsigned int j = 0; j < M; ++j)
222 retval.operator()(i,j) =
operator()(j,i);
246 out.m_data = m_data+matrix.m_data;
258 out.m_data = m_data-matrix.m_data;
270 out.m_data = m_data*value;
285 out.m_data = matrix.m_data*value;
300 for(i = 0; i < N; ++i)
302 for(j = 0; j < K; ++j)
304 out.operator()(i,j) = T(0);
305 for(k = 0; k < M; ++k)
307 out.operator()(i,j) +=
operator()(i,k) * matrix.operator()(k,j);
323 for(
unsigned int i = 0; i < N;++i)
326 for(
unsigned int j = 0; j < M; ++j)
346 for(
unsigned int i = 0; i < M; ++i)
349 for(
unsigned int j = 0; j < N; ++j)
351 retval[i] += in[j] * matrix.operator()(j,i);
393 m_top(t), m_bottom(b), m_left(l), m_right(r)
428 m_top(t), m_bottom(b), m_left(l), m_right(r),
488 for(
int i = 0; i < 2; ++i)
490 for(
int j = 0; j < 2; ++j)
508 orthogonal_projection_matrix(P);
519 projection_matrix(P);
587 translate(p.
x(), p.
y());
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);
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);
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)) ;
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));
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));
769 recipDet = T(1) / det;
771 cofactor_transpose(result);
784 recipDet = T(1) / det;
797 return determinate() < T(0);
A representation of a 3x3 matrix, that in addition to the NxN matrix functionality provides function ...
matrix3x3(const projection_params< T > &P)
matrixNxM operator+(const matrixNxM &matrix) const
bool reverses_orientation(void) const
void inverse(matrix3x3 &result) const
An orthogonal_projection_params holds the data to describe an orthogonal projection matrix without pe...
all classes and functions of FastUIDraw are in the namespace fastuidraw.
T m_bottom
Bottom edge of the clipping plane.
vecN< T, N *M > & raw_data(void)
A generic matrix class. The operator() is overloaded to access elements of the matrix as follows: ...
matrix3x3(const orthogonal_projection_params< T > &P)
void cofactor_transpose(matrix3x3 &result) const
projection_params(T l, T r, T b, T t, T n)
const T & operator()(unsigned int row, unsigned int col) const
matrixNxM< 2, 2, float > float2x2
Convenience typedef to matrixNxM<2, float>
matrix3x3(const base_class &obj)
matrix3x3(const vecN< T, 3 > &t, const vecN< T, 3 > &b, const vecN< T, 3 > &n)
T m_top
Top edge of the clipping plane.
friend vecN< T, M > operator*(const vecN< T, N > &in, const matrixNxM &matrix)
void projection_matrix(const projection_params< T > &P)
orthogonal_projection_params(T l, T r, T b, T t)
T m_top
Top edge of the clipping plane.
T m_near
Near clipping plane distance.
const T & col_row(unsigned int col, unsigned row) const
T & col_row(unsigned int col, unsigned row)
vecN< T, N > operator*(const vecN< T, M > &in) const
T m_left
Left edge of the clipping plane.
vecN< T, N *M > raw_data_type
Typedef to underlying vecN that holds the matrix data.
matrixNxM(const matrixNxM &obj)
orthogonal_projection_params< float > float_orthogonal_projection_params
Convenience typedef for orthogonal_projection_params<float>
void swap(matrixNxM &obj)
T m_bottom
Bottom edge of the clipping plane.
T m_right
Right edge of the clipping plane.
matrixNxM< N, K, T > operator*(const matrixNxM< M, K, T > &matrix) const
matrix3x3< float > float3x3
Convenience typedef to matrix3x3<float>
projection_params< float > float_projection_params
Convenience typedef for projection_params<float>
const T * c_ptr(void) const
T determinate(void) const
T & operator()(unsigned int row, unsigned int col)
void orthogonal_projection_matrix(T l, T r, T b, T t)
void orthogonal_projection_matrix(const orthogonal_projection_params< T > &P)
A projection_params holds the data to describe a projection matrix with perspective.
void inverse_orthogonal_projection_matrix(const orthogonal_projection_params< T > &P)
const vecN< T, N *M > & raw_data(void) const
matrixNxM operator-(const matrixNxM &matrix) const
void translate(const vecN< T, 2 > &p)
T m_right
Right edge of the clipping plane.
void inverse_transpose(matrix3x3 &result) const
void cofactor(matrix3x3 &result) const
friend matrixNxM operator*(T value, const matrixNxM &matrix)
void transpose(matrixNxM< M, N, T > &retval) const
matrixNxM operator*(T value) const
matrix3x3(const matrixNxM< 2, 2, T > &mat, const vecN< T, 2 > &vec=vecN< T, 2 >(T(0)))
matrixNxM< 3, 3, T > base_class
Conveniance typedef to base class, matrixNxM<3, 3, T>
#define FASTUIDRAWassert(X)
T m_left
Left edge of the clipping plane.
matrixNxM< M, N, T > transpose(void) const
orthogonal_projection_params(void)