13 #ifndef OGLPLUS_MATRIX_1107121519_HPP
14 #define OGLPLUS_MATRIX_1107121519_HPP
16 #include <oglplus/config/compiler.hpp>
21 #if !OGLPLUS_NO_INITIALIZER_LISTS
22 #include <initializer_list>
33 template <
typename T, std::
size_t Rows, std::
size_t Cols>
36 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_FLOAT)
92 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_DOUBLE)
149 struct Matrix_spec_ctr_tag { };
153 template <
typename T, std::
size_t Rows, std::
size_t Cols>
162 typedef aux::Matrix_spec_ctr_tag _spec_ctr;
168 void operator()(
Matrix& t)
const
170 for(std::size_t i=0; i!=
Rows; ++i)
171 for(std::size_t j=0; j!=
Cols; ++j)
172 t._m._elem[i][j] = -a._m._elem[i][j];
181 void operator()(
Matrix& t)
const
183 for(std::size_t i=0; i!=
Rows; ++i)
184 for(std::size_t j=0; j!=
Cols; ++j)
196 void operator()(
Matrix& t)
const
198 for(std::size_t i=0; i!=
Rows; ++i)
199 for(std::size_t j=0; j!=
Cols; ++j)
206 template <std::
size_t N>
209 const Matrix<T, Rows, N>& a;
210 const Matrix<T, N, Cols>& b;
212 void operator()(
Matrix& t)
const
214 for(std::size_t i=0; i!=
Rows; ++i)
215 for(std::size_t j=0; j!=
Cols; ++j)
217 t._m._elem[i][j] = a.At(i, 0)* b.At(0, j);
218 for(std::size_t k=1; k!=N; ++k)
236 for(std::size_t i=0; i!=
Rows; ++i)
237 for(std::size_t j=0; j!=
Cols; ++j)
238 t._m._elem[i][j] = a._m._elem[i][j] * v;
244 const Matrix<T, Cols, Rows>& a;
246 void operator()(
Matrix& t)
const
248 for(std::size_t i=0; i!=
Rows; ++i)
249 for(std::size_t j=0; j!=
Cols; ++j)
250 t._m._elem[i][j] = a._m._elem[j][i];
254 template <std::
size_t I, std::
size_t J, std::
size_t R, std::
size_t C>
259 void operator()(Matrix<T, R, C>& t)
const
263 "Invalid row for this matrix type"
267 "Invalid column for this matrix type"
269 for(std::size_t i=0; i!=
R; ++i)
270 for(std::size_t j=0; j!=C; ++j)
271 t.Set(i, j, a.At(I+i, J+j));
275 template <
typename U, std::
size_t R, std::
size_t C>
278 const Matrix<U, R, C>& a;
280 void operator()(
Matrix& t)
const
284 "Invalid row for this matrix type"
288 "Invalid column for this matrix type"
290 for(std::size_t i=0; i!=
Rows; ++i)
291 for(std::size_t j=0; j!=
Cols; ++j)
292 t._m._elem[i][j] =
T(a.At(i, j));
296 void _init_row(std::size_t r,
const T* data, std::size_t cols)
298 assert(cols ==
Cols);
299 std::copy(data, data+cols, _m._elem[r]);
302 void _init_row(std::size_t r,
const Vector<T, Cols>& row)
304 std::copy(row.Data(), row.Data()+
Cols, _m._elem[r]);
312 template <
typename InitOp>
313 explicit Matrix(_spec_ctr, InitOp& init)
321 std::fill(_m._data, _m._data+
Rows*
Cols,
T(0));
322 for(std::size_t i=0, n=
Rows<Cols?
Rows:Cols; i!=n; ++i)
323 this->_m._elem[i][i] =
T(1);
329 std::copy(data, data+n, _m._data);
335 std::copy(data, data+
Rows*Cols, _m._data);
338 #if !OGLPLUS_NO_DEFAULTED_FUNCTIONS
343 template <
typename U, std::
size_t R, std::
size_t C>
346 _op_copy<U, R, C> init = {other};
350 #if OGLPLUS_DOCUMENTATION_ONLY
357 template <
typename ... P>
367 template <
typename ... C>
368 explicit Matrix(
const Vector<T, C> ... row);
369 #elif !OGLPLUS_NO_VARIADIC_TEMPLATES && !OGLPLUS_NO_UNIFIED_INITIALIZATION_SYNTAX
371 #include <oglplus/math/matrix_n_ctr.ipp>
375 #include <oglplus/math/matrix_2_ctr.ipp>
376 #include <oglplus/math/matrix_3_ctr.ipp>
377 #include <oglplus/math/matrix_4_ctr.ipp>
383 std::fill(_m._data, _m._data+
Rows*
Cols, value);
389 return this->_m._data;
398 #if OGLPLUS_DOCUMENTATION_ONLY
403 friend std::size_t
Size(
const Matrix& matrix);
406 friend std::size_t
Rows(
const Matrix& matrix);
409 friend std::size_t
Cols(
const Matrix& matrix);
416 T At(std::size_t i, std::size_t j)
const
419 return this->_m._elem[i][j];
426 void Set(std::size_t i, std::size_t j,
T v)
429 this->_m._elem[i][j] = v;
450 for(std::size_t i=0; i!=
Rows; ++i)
451 v[i] = this->_m._elem[i][j];
458 for(std::size_t i=0; i!=
Rows; ++i)
459 for(std::size_t j=0; j!=
Cols; ++j)
460 if(a._m._elem[i][j] != b._m._elem[i][j])
480 _op_negate init = {a};
481 return Matrix(_spec_ctr(), init);
493 _op_add init = {a, b};
494 return Matrix(_spec_ctr(), init);
506 _op_subtract init = {a, b};
507 return Matrix(_spec_ctr(), init);
517 template <std::
size_t N>
523 _op_multiply<N> init = {a, b};
524 return Matrix(_spec_ctr(), init);
528 template <std::
size_t N>
540 _op_mult_c init = {a, m};
541 return Matrix(_spec_ctr(), init);
559 _op_transpose init = {a};
560 return Matrix(_spec_ctr(), init);
564 template <std::
size_t I, std::
size_t J, std::
size_t R, std::
size_t C>
567 _op_extract<I, J, R, C> init = {*
this};
574 _op_extract<0, 0, 2, 2> init = {a};
581 _op_extract<0, 0, 3, 3> init = {a};
601 for(std::size_t j=0; j!=
Cols; ++j)
602 m._m._elem[i][j] *= k;
610 for(std::size_t j=0; j!=
Cols; ++j)
611 m._m._elem[a][j] += m._m._elem[b][j] * k;
615 template <std::
size_t C>
618 const T zero(0), one(1);
619 for(std::size_t i=0; i!=
Rows; ++i)
621 T d = a._m._elem[i][i];
624 for(std::size_t k=i+1; k!=
Rows; ++k)
626 if(a._m._elem[k][i] != zero)
633 d = a._m._elem[i][i];
635 if(d == zero)
return false;
640 for(std::size_t k=i+1; k!=
Rows; ++k)
642 T c = a._m._elem[k][i];
654 template <std::
size_t C>
657 if(!
Gauss(a, b))
return false;
659 for(std::size_t i=
Rows-1; i!=0; --i)
661 for(std::size_t k=0; k!=i; ++k)
663 T c = a._m._elem[k][i];
683 >
inline Matrix<T, R, C> Submatrix(
const Matrix<T, Rows, Cols>& a)
685 return a.template Submatrix<I, J, R, C>();
688 template <
typename T, std::
size_t R, std::
size_t C>
690 const Matrix<T, R, C>& a,
691 const Matrix<T, R, C>& b,
696 for(std::size_t i=0; i!=R; ++i)
697 for(std::size_t j=0; j!=C; ++j)
702 bool ca = d <= std::abs(u)*eps;
703 bool cb = d <= std::abs(v)*eps;
704 if(!ca && !cb)
return false;
709 template <
typename T>
710 inline void InitMatrix4x4(
711 Matrix<T, 4, 4>& matrix,
712 T v00, T v01, T v02, T v03,
713 T v10, T v11, T v12, T v13,
714 T v20, T v21, T v22, T v23,
715 T v30, T v31, T v32, T v33
718 matrix.Set(0, 0, v00);
719 matrix.Set(0, 1, v01);
720 matrix.Set(0, 2, v02);
721 matrix.Set(0, 3, v03);
723 matrix.Set(1, 0, v10);
724 matrix.Set(1, 1, v11);
725 matrix.Set(1, 2, v12);
726 matrix.Set(1, 3, v13);
728 matrix.Set(2, 0, v20);
729 matrix.Set(2, 1, v21);
730 matrix.Set(2, 2, v22);
731 matrix.Set(2, 3, v23);
733 matrix.Set(3, 0, v30);
734 matrix.Set(3, 1, v31);
735 matrix.Set(3, 2, v32);
736 matrix.Set(3, 3, v33);
739 template <
typename T, std::
size_t R, std::
size_t C>
740 inline const T* Data(
const Matrix<T, R, C>& matrix)
742 return matrix.Data();
745 template <
typename T, std::
size_t R, std::
size_t C>
746 inline std::size_t Size(
const Matrix<T, R, C>&)
751 template <
typename T, std::
size_t R, std::
size_t C>
752 inline std::size_t Rows(
const Matrix<T, R, C>&)
757 template <
typename T, std::
size_t R, std::
size_t C>
758 inline std::size_t Cols(
const Matrix<T, R, C>&)
763 template <
typename T, std::
size_t R, std::
size_t C>
764 inline T At(
const Matrix<T, R, C>& matrix, std::size_t i, std::size_t j)
766 return matrix.At(i, j);
769 template <
typename T, std::
size_t R, std::
size_t C>
770 inline Matrix<T, R, C> Inverse(Matrix<T, R, C> m)
773 if(!GaussJordan(m, i)) i.Fill(T(0));
783 template <
typename T>
799 struct Translation_ { };
802 : Base(oglplus::Nothing())
806 T(1),
T(0),
T(0), dx,
807 T(0),
T(1),
T(0), dy,
808 T(0),
T(0),
T(1), dz,
809 T(0),
T(0),
T(0),
T(1)
840 return ModelMatrix(Translation_(), dp.x(), dp.y(), dp.z());
846 : Base(oglplus::Nothing())
850 sx,
T(0),
T(0),
T(0),
851 T(0), sy,
T(0),
T(0),
852 T(0),
T(0), sz,
T(0),
853 T(0),
T(0),
T(0),
T(1)
863 struct Reflection_ { };
865 ModelMatrix(Reflection_,
bool rx,
bool ry,
bool rz)
866 : Base(oglplus::Nothing())
868 const T _rx = rx ?-
T(1):T(1);
869 const T _ry = ry ?-
T(1):T(1);
870 const T _rz = rz ?-
T(1):T(1);
873 _rx,
T(0),
T(0),
T(0),
874 T(0), _ry,
T(0),
T(0),
875 T(0),
T(0), _rz,
T(0),
876 T(0),
T(0),
T(0),
T(1)
886 struct RotationX_ { };
889 : Base(oglplus::Nothing())
891 const T cosx = Cos(angle);
892 const T sinx = Sin(angle);
895 T(1),
T(0),
T(0),
T(0),
896 T(0), cosx, -sinx,
T(0),
897 T(0), sinx, cosx,
T(0),
898 T(0),
T(0),
T(0),
T(1)
908 struct RotationY_ { };
911 : Base(oglplus::Nothing())
913 const T cosx = Cos(angle);
914 const T sinx = Sin(angle);
917 cosx,
T(0), sinx,
T(0),
918 T(0),
T(1),
T(0),
T(0),
919 -sinx,
T(0), cosx,
T(0),
920 T(0),
T(0),
T(0),
T(1)
930 struct RotationZ_ { };
933 : Base(oglplus::Nothing())
935 const T cosx = Cos(angle);
936 const T sinx = Sin(angle);
939 cosx, -sinx,
T(0),
T(0),
940 sinx, cosx,
T(0),
T(0),
941 T(0),
T(0),
T(1),
T(0),
942 T(0),
T(0),
T(0),
T(1)
952 struct RotationA_ { };
954 ModelMatrix(RotationA_,
const Vector<T,3>& axis, Angle<T> angle)
955 : Base(oglplus::Nothing())
957 const Vector<T, 3> a = Normalized(axis);
958 const T sf = Sin(angle);
959 const T cf = Cos(angle);
960 const T _cf =
T(1) - cf;
961 const T x = a.At(0), y = a.At(1), z = a.At(2);
962 const T xx= x*x, xy= x*y, xz= x*z, yy= y*y, yz= y*z, zz= z*z;
965 xx*_cf + cf, xy*_cf - z*sf, xz*_cf + y*sf,
T(0),
966 xy*_cf + z*sf, yy*_cf + cf, yz*_cf - x*sf,
T(0),
967 xz*_cf - y*sf, yz*_cf + x*sf, zz*_cf + cf,
T(0),
968 T(0),
T(0),
T(0),
T(1)
982 : Base(oglplus::Nothing())
985 const T a = quat.At(0);
986 const T x = quat.At(1);
987 const T y = quat.At(2);
988 const T z = quat.At(3);
991 1-2*y*y-2*z*z, 2*x*y-2*a*z, 2*x*z+2*a*y,
T(0),
992 2*x*y+2*a*z, 1-2*x*x-2*z*z, 2*y*z-2*a*x,
T(0),
993 2*x*z-2*a*y, 2*y*z+2*a*x, 1-2*x*x-2*y*y,
T(0),
994 T(0),
T(0),
T(0),
T(1)
1006 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_FLOAT)
1014 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_DOUBLE)
1028 template <
typename T>
1036 #if OGLPLUS_DOCUMENTATION_ONLY
1041 #if !OGLPLUS_NO_DEFAULTED_FUNCTIONS
1053 return Vector<T,3>(Inverse(*this).Col(3).Data(), 3);
1061 struct Perspective_ { };
1071 ):
Base(oglplus::Nothing())
1073 T m00 = (
T(2) * z_near) / (x_right - x_left);
1074 T m11 = (
T(2) * z_near) / (y_top - y_bottom);
1075 T m22 = -(z_far + z_near) / (z_far - z_near);
1077 T m20 = (x_right + x_left) / (x_right - x_left);
1078 T m21 = (y_top + y_bottom) / (y_top - y_bottom);
1081 T m32 = -(
T(2) * z_far * z_near) / (z_far - z_near);
1085 m00,
T(0), m20,
T(0),
1086 T(0), m11, m21,
T(0),
1087 T(0),
T(0), m22, m32,
1088 T(0),
T(0), m23,
T(0)
1127 assert(aspect >
T(0));
1130 T x_right = z_near * Tan(xfov *
T(0.5));
1131 T x_left = -x_right;
1133 T y_bottom = x_left / aspect;
1134 T y_top = x_right / aspect;
1158 assert(aspect >
T(0));
1161 T y_top = z_near * Tan(yfov *
T(0.5));
1162 T y_bottom = -y_top;
1164 T x_left = y_bottom * aspect;
1165 T x_right = y_top * aspect;
1188 ): Base(oglplus::Nothing())
1190 T m00 =
T(2) / (x_right - x_left);
1191 T m11 =
T(2) / (y_top - y_bottom);
1192 T m22 = -
T(2) / (z_far - z_near);
1194 T m30 = -(x_right + x_left) / (x_right - x_left);
1195 T m31 = -(y_top + y_bottom) / (y_top - y_bottom);
1196 T m32 = -(z_far + z_near) / (z_far - z_near);
1200 m00,
T(0),
T(0), m30,
1201 T(0), m11,
T(0), m31,
1202 T(0),
T(0), m22, m32,
1203 T(0),
T(0),
T(0),
T(1)
1242 assert(aspect >
T(0));
1243 assert(width >
T(0));
1245 T x_right = width /
T(2);
1246 T x_left = -x_right;
1248 T y_bottom = x_left / aspect;
1249 T y_top = x_right / aspect;
1273 assert(aspect >
T(0));
1274 assert(height >
T(0));
1276 T y_top = height /
T(2);
1277 T y_bottom = -y_top;
1279 T x_left = y_bottom * aspect;
1280 T x_right = y_top * aspect;
1293 struct ScreenStretch_ { };
1301 ): Base(oglplus::Nothing())
1303 assert((x_right - x_left) !=
T(0));
1304 assert((y_top - y_bottom) !=
T(0));
1306 T m00 =
T(2) / (x_right - x_left);
1307 T m11 =
T(2) / (y_top - y_bottom);
1309 T m30 = -(x_right + x_left) / (x_right - x_left);
1310 T m31 = -(y_top + y_bottom) / (y_top - y_bottom);
1314 m00,
T(0),
T(0), m30,
1315 T(0), m11,
T(0), m31,
1316 T(0),
T(0),
T(1),
T(0),
1317 T(0),
T(0),
T(0),
T(1)
1360 -
T(1)+
T(2*(x+0))/
T(nx),
1361 -
T(1)+
T(2*(x+1))/
T(nx),
1362 -
T(1)+
T(2*(y+0))/
T(ny),
1363 -
T(1)+
T(2*(y+1))/
T(ny)
1367 struct LookingAt_ { };
1371 const Vector<T, 3>& eye,
1372 const Vector<T, 3>& target
1373 ): Base(oglplus::Nothing())
1375 assert(eye != target);
1376 Vector<T, 3> z = Normalized(eye - target);
1379 Vector<T, 3> t(zz,
T(0), -zx);
1380 Vector<T, 3> y = Normalized(Cross(z, t));
1381 Vector<T, 3> x = Cross(y, z);
1394 T(0),
T(0),
T(0),
T(1)
1412 ): Base(oglplus::Nothing())
1414 assert(eye != target);
1416 T dupz = Dot(up, z);
1417 assert(dupz < 0.9 && dupz >-0.9);
1436 T(0),
T(0),
T(0),
T(1)
1450 struct Orbiting_ { };
1454 const Vector<T, 3>& target,
1461 Cos(elevation) * Cos(azimuth),
1463 Cos(elevation) *-Sin(azimuth)
1470 Vector<T, 3> y = Cross(z, x);
1475 Dot(x, z) * -radius - Dot(x, target),
1478 Dot(y, z) * -radius - Dot(y, target),
1481 Dot(z, z) * -radius - Dot(z, target),
1483 T(0),
T(0),
T(0),
T(1)
1508 : Base(oglplus::Nothing())
1510 const T cosx = Cos(-angle);
1511 const T sinx = Sin(-angle);
1514 T(1),
T(0),
T(0),
T(0),
1515 T(0), cosx, -sinx,
T(0),
1516 T(0), sinx, cosx,
T(0),
1517 T(0),
T(0),
T(0),
T(1)
1535 : Base(oglplus::Nothing())
1537 const T cosx = Cos(-angle);
1538 const T sinx = Sin(-angle);
1541 cosx,
T(0), sinx,
T(0),
1542 T(0),
T(1),
T(0),
T(0),
1543 -sinx,
T(0), cosx,
T(0),
1544 T(0),
T(0),
T(0),
T(1)
1562 : Base(oglplus::Nothing())
1564 const T cosx = Cos(-angle);
1565 const T sinx = Sin(-angle);
1568 cosx, -sinx,
T(0),
T(0),
1569 sinx, cosx,
T(0),
T(0),
1570 T(0),
T(0),
T(1),
T(0),
1571 T(0),
T(0),
T(0),
T(1)
1587 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_FLOAT)
1595 #if OGLPLUS_DOCUMENTATION_ONLY || defined(GL_DOUBLE)
1605 #endif // include guard
static ModelMatrix Translation(T dx, T dy, T dz)
Constructs a translation matrix.
Definition: matrix.hpp:814
static CameraMatrix Roll(Angle< T > angle)
Constructs a Z-axis rotation (Bank/Roll) matrix.
Definition: matrix.hpp:1581
Matrix< GLdouble, 4, 4 > Mat4d
4x4 double-precision matrix
Definition: matrix.hpp:145
Class implementing model transformation matrix named constructors.
Definition: matrix.hpp:784
friend Matrix Multiplied(const Matrix &a, T m)
Multiplication by scalar value.
Definition: matrix.hpp:538
static CameraMatrix PerspectiveX(Angle< T > xfov, T aspect, T z_near, T z_far)
Constructs a perspective projection matrix.
Definition: matrix.hpp:1120
static ModelMatrix RotationA(const Vector< T, 3 > &axis, Angle< T > angle)
Constructs a rotation matrix from a vector and angle.
Definition: matrix.hpp:973
static CameraMatrix LookingAt(const Vector< T, 3 > &eye, const Vector< T, 3 > &target)
Constructs a 'look-at' matrix from eye and target positions.
Definition: matrix.hpp:1399
Template class for quaternions.
Definition: fwd.hpp:59
static CameraMatrix ScreenTile(unsigned x, unsigned y, unsigned nx, unsigned ny)
Constructs a matrix for stretching NDCs after projection.
Definition: matrix.hpp:1348
Matrix< GLfloat, 2, 3 > Mat2x3f
2x3 float matrix
Definition: matrix.hpp:47
Matrix< GLdouble, 4, 3 > Mat4x3d
4x3 double-precision matrix
Definition: matrix.hpp:139
static ModelMatrix RotationX(Angle< T > angle)
Constructs a X-axis rotation matrix.
Definition: matrix.hpp:903
friend void RowAdd(Matrix &m, std::size_t a, std::size_t b, T k)
Adds row b multipled by coeficient k to row a.
Definition: matrix.hpp:606
Vector< T, Rows > Col(std::size_t j) const
Return the j-th column of this matrix.
Definition: matrix.hpp:446
Class implementing planar angle-related functionality.
Definition: fwd.hpp:24
Definition: vector.hpp:14
friend std::size_t Rows(const Matrix &matrix)
Returns the number of rows of the matrix.
friend bool GaussJordan(Matrix &a, Matrix< T, Rows, C > &b)
The Gauss-Jordan matrix elimination.
Definition: matrix.hpp:655
static CameraMatrix Yaw(Angle< T > angle)
Constructs a Y-axis rotation (Heading/Yaw) matrix.
Definition: matrix.hpp:1554
friend Matrix Negated(const Matrix &a)
Element negation function.
Definition: matrix.hpp:478
friend Matrix Added(const Matrix &a, const Matrix &b)
Matrix addition.
Definition: matrix.hpp:491
static ModelMatrix TranslationY(T dy)
Constructs a translation matrix.
Definition: matrix.hpp:826
friend bool Equal(const Matrix &a, const Matrix &b)
Equality comparison function.
Definition: matrix.hpp:456
static ModelMatrix RotationZ(Angle< T > angle)
Constructs a Z-axis rotation matrix.
Definition: matrix.hpp:947
friend Matrix Subtracted(const Matrix &a, const Matrix &b)
Matrix subtraction.
Definition: matrix.hpp:504
friend Matrix operator*(const Matrix< T, Rows, N > &a, const Matrix< T, N, Cols > &b)
Matrix multiplication operator.
Definition: matrix.hpp:529
static CameraMatrix ScreenStretch(T x_left, T x_right, T y_bottom, T y_top)
Constructs a matrix for stretching NDCs after projection.
Definition: matrix.hpp:1325
Matrix< GLfloat, 4, 3 > Mat4x3f
4x3 float matrix
Definition: matrix.hpp:83
static CameraMatrix LookingAt(const Vector< T, 3 > &eye, const Vector< T, 3 > &target, const Vector< T, 3 > &up)
Constructs 'look-at' matrix from eye and target positions and up vector.
Definition: matrix.hpp:1441
friend Matrix operator+(const Matrix &a, const Matrix &b)
Matrix addition operator.
Definition: matrix.hpp:498
Matrix< GLfloat, 3, 2 > Mat3x2f
3x2 float matrix
Definition: matrix.hpp:59
Matrix< GLdouble, 3, 3 > Mat3d
3x3 double-precision matrix
Definition: matrix.hpp:121
friend Matrix operator-(const Matrix &a)
Element negation operator.
Definition: matrix.hpp:485
static CameraMatrix OrthoY(T height, T aspect, T z_near, T z_far)
Constructs an orthographic projection matrix.
Definition: matrix.hpp:1266
ModelMatrix< GLfloat > ModelMatrixf
Model transformation float matrix.
Definition: matrix.hpp:1011
static CameraMatrix Ortho(T x_left, T x_right, T y_bottom, T y_top, T z_near, T z_far)
Constructs an orthographic projection matrix.
Definition: matrix.hpp:1211
friend Matrix Transposed(const Matrix< T, Cols, Rows > &a)
Matrix transposition.
Definition: matrix.hpp:557
static CameraMatrix PerspectiveY(Angle< T > yfov, T aspect, T z_near, T z_far)
Constructs a perspective projection matrix.
Definition: matrix.hpp:1151
static CameraMatrix OrthoX(T width, T aspect, T z_near, T z_far)
Constructs an orthographic projection matrix.
Definition: matrix.hpp:1235
Quaternion & Normalize(void)
Normalizes this quaternion.
Definition: quaternion.hpp:152
friend Matrix Multiplied(const Matrix< T, Rows, N > &a, const Matrix< T, N, Cols > &b)
Matrix multiplication.
Definition: matrix.hpp:518
Matrix< GLdouble, 3, 2 > Mat3x2d
3x2 double-precision matrix
Definition: matrix.hpp:115
static ModelMatrix Translation(const Vector< T, 3 > &dp)
Constructs a translation matrix.
Definition: matrix.hpp:838
friend bool Gauss(Matrix &a, Matrix< T, Rows, C > &b)
The gaussian matrix elimination.
Definition: matrix.hpp:616
static CameraMatrix Perspective(T x_left, T x_right, T y_bottom, T y_top, T z_near, T z_far)
Constructs a perspective projection matrix.
Definition: matrix.hpp:1096
static CameraMatrix Orbiting(const Vector< T, 3 > &target, T radius, Angle< T > azimuth, Angle< T > elevation)
Constructs a matrix from target, radius, azimuth and elevation.
Definition: matrix.hpp:1489
void Set(std::size_t i, std::size_t j, T v)
Sets the value of the element at position i, j.
Definition: matrix.hpp:426
Matrix(const T(&data)[Rows *Cols])
Constructuion from static array.
Definition: matrix.hpp:333
static ModelMatrix TranslationZ(T dz)
Constructs a translation matrix.
Definition: matrix.hpp:832
friend bool operator!=(const Matrix &a, const Matrix &b)
Unequality comparison operator.
Definition: matrix.hpp:472
Matrix< GLfloat, 3, 4 > Mat3x4f
3x4 float matrix
Definition: matrix.hpp:71
Matrix< GLdouble, 2, 4 > Mat2x4d
2x4 double-precision matrix
Definition: matrix.hpp:109
Matrix< GLdouble, 2, 2 > Mat2d
2x2 double-precision matrix
Definition: matrix.hpp:97
Matrix< GLfloat, 4, 2 > Mat4x2f
4x2 float matrix
Definition: matrix.hpp:77
CameraMatrix< GLdouble > CamMatrixd
Camera matrix using double precition numbers.
Definition: matrix.hpp:1600
T At(std::size_t i, std::size_t j) const
Returns the value of the element at position i, j.
Definition: matrix.hpp:416
Matrix(const T *data, std::size_t n)
Constructuion from raw data.
Definition: matrix.hpp:327
friend void RowMultiply(Matrix &m, std::size_t i, T k)
Multiplies row i with coeficient k.
Definition: matrix.hpp:598
Matrix< GLfloat, 3, 3 > Mat3f
3x3 float matrix
Definition: matrix.hpp:65
Matrix< GLdouble, 3, 4 > Mat3x4d
3x4 double-precision matrix
Definition: matrix.hpp:127
static ModelMatrix RotationQ(const Quaternion< T > &quat)
Constructs a rotation matrix from a quaternion.
Definition: matrix.hpp:999
friend void RowSwap(Matrix &m, std::size_t a, std::size_t b)
Swaps two rows of the Matrix.
Definition: matrix.hpp:586
Matrix< GLfloat, 2, 2 > Mat2f
2x2 float matrix
Definition: matrix.hpp:34
ModelMatrix< GLdouble > ModelMatrixd
Model transformation double precision matrix.
Definition: matrix.hpp:1019
Class implementing camera matrix named constructors.
Definition: matrix.hpp:1029
Base template for Matrix.
Definition: fwd.hpp:63
friend bool operator==(const Matrix &a, const Matrix &b)
Equality comparison operator.
Definition: matrix.hpp:466
static ModelMatrix Reflection(bool rx, bool ry, bool rz)
Constructs a reflection matrix.
Definition: matrix.hpp:881
const T * Data(void) const
Returns a pointer to the matrix elements in row major order.
Definition: matrix.hpp:387
std::size_t Size(void) const
Returns the number of elements of the matrix.
Definition: matrix.hpp:393
Matrix< T, R, C > Submatrix(void) const
Submatrix extraction.
Definition: matrix.hpp:565
friend Matrix< T, 3, 3 > Sub3x3(const Matrix &a)
3x3 submatrix extraction
Definition: matrix.hpp:579
Matrix< GLfloat, 2, 4 > Mat2x4f
2x4 float matrix
Definition: matrix.hpp:53
CameraMatrix< GLfloat > CamMatrixf
Camera matrix using float numbers.
Definition: matrix.hpp:1592
static ModelMatrix RotationY(Angle< T > angle)
Constructs a Y-axis rotation matrix.
Definition: matrix.hpp:925
ModelMatrix(void)
Constructs an identity matrix.
Definition: matrix.hpp:791
Vector< T, Cols > Row(std::size_t i) const
Returns the i-th row of this matrix.
Definition: matrix.hpp:436
Matrix(void)
Default construction (identity matrix)
Definition: matrix.hpp:319
Matrix< GLdouble, 2, 3 > Mat2x3d
2x3 double-precision matrix
Definition: matrix.hpp:103
Basic template for vector types.
Definition: fwd.hpp:43
friend std::size_t Cols(const Matrix &matrix)
Returns the number of columns of the matrix.
Matrix< GLdouble, 4, 2 > Mat4x2d
4x2 double-precision matrix
Definition: matrix.hpp:133
friend Matrix< T, 2, 2 > Sub2x2(const Matrix &a)
2x2 submatrix extraction
Definition: matrix.hpp:572
CameraMatrix(void)
Constructs an identity matrix.
Matrix< GLfloat, 4, 4 > Mat4f
4x4 float matrix
Definition: matrix.hpp:89
static CameraMatrix Pitch(Angle< T > angle)
Constructs a X-axis rotation (Pitch/Elevation) matrix.
Definition: matrix.hpp:1527
static ModelMatrix TranslationX(T dx)
Constructs a translation matrix.
Definition: matrix.hpp:820
static ModelMatrix Scale(T sx, T sy, T sz)
Constructs a scale matrix.
Definition: matrix.hpp:858