matrix.hpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /// @ref core
  2. /// @file glm/matrix.hpp
  3. ///
  4. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
  5. ///
  6. /// @defgroup core_func_matrix Matrix functions
  7. /// @ingroup core
  8. ///
  9. /// Provides GLSL matrix functions.
  10. ///
  11. /// Include <glm/matrix.hpp> to use these core features.
  12. #pragma once
  13. // Dependencies
  14. #include "detail/qualifier.hpp"
  15. #include "detail/setup.hpp"
  16. #include "vec2.hpp"
  17. #include "vec3.hpp"
  18. #include "vec4.hpp"
  19. #include "mat2x2.hpp"
  20. #include "mat2x3.hpp"
  21. #include "mat2x4.hpp"
  22. #include "mat3x2.hpp"
  23. #include "mat3x3.hpp"
  24. #include "mat3x4.hpp"
  25. #include "mat4x2.hpp"
  26. #include "mat4x3.hpp"
  27. #include "mat4x4.hpp"
  28. namespace glm {
  29. namespace detail
  30. {
  31. template<length_t C, length_t R, typename T, qualifier Q>
  32. struct outerProduct_trait{};
  33. template<typename T, qualifier Q>
  34. struct outerProduct_trait<2, 2, T, Q>
  35. {
  36. typedef mat<2, 2, T, Q> type;
  37. };
  38. template<typename T, qualifier Q>
  39. struct outerProduct_trait<2, 3, T, Q>
  40. {
  41. typedef mat<3, 2, T, Q> type;
  42. };
  43. template<typename T, qualifier Q>
  44. struct outerProduct_trait<2, 4, T, Q>
  45. {
  46. typedef mat<4, 2, T, Q> type;
  47. };
  48. template<typename T, qualifier Q>
  49. struct outerProduct_trait<3, 2, T, Q>
  50. {
  51. typedef mat<2, 3, T, Q> type;
  52. };
  53. template<typename T, qualifier Q>
  54. struct outerProduct_trait<3, 3, T, Q>
  55. {
  56. typedef mat<3, 3, T, Q> type;
  57. };
  58. template<typename T, qualifier Q>
  59. struct outerProduct_trait<3, 4, T, Q>
  60. {
  61. typedef mat<4, 3, T, Q> type;
  62. };
  63. template<typename T, qualifier Q>
  64. struct outerProduct_trait<4, 2, T, Q>
  65. {
  66. typedef mat<2, 4, T, Q> type;
  67. };
  68. template<typename T, qualifier Q>
  69. struct outerProduct_trait<4, 3, T, Q>
  70. {
  71. typedef mat<3, 4, T, Q> type;
  72. };
  73. template<typename T, qualifier Q>
  74. struct outerProduct_trait<4, 4, T, Q>
  75. {
  76. typedef mat<4, 4, T, Q> type;
  77. };
  78. }//namespace detail
  79. /// @addtogroup core_func_matrix
  80. /// @{
  81. /// Multiply matrix x by matrix y component-wise, i.e.,
  82. /// result[i][j] is the scalar product of x[i][j] and y[i][j].
  83. ///
  84. /// @tparam C Integer between 1 and 4 included that qualify the number a column
  85. /// @tparam R Integer between 1 and 4 included that qualify the number a row
  86. /// @tparam T Floating-point or signed integer scalar types
  87. /// @tparam Q Value from qualifier enum
  88. ///
  89. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/matrixCompMult.xml">GLSL matrixCompMult man page</a>
  90. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
  91. template<length_t C, length_t R, typename T, qualifier Q>
  92. GLM_FUNC_DECL mat<C, R, T, Q> matrixCompMult(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y);
  93. /// Treats the first parameter c as a column vector
  94. /// and the second parameter r as a row vector
  95. /// and does a linear algebraic matrix multiply c * r.
  96. ///
  97. /// @tparam C Integer between 1 and 4 included that qualify the number a column
  98. /// @tparam R Integer between 1 and 4 included that qualify the number a row
  99. /// @tparam T Floating-point or signed integer scalar types
  100. /// @tparam Q Value from qualifier enum
  101. ///
  102. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
  103. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
  104. template<length_t C, length_t R, typename T, qualifier Q>
  105. GLM_FUNC_DECL typename detail::outerProduct_trait<C, R, T, Q>::type outerProduct(vec<C, T, Q> const& c, vec<R, T, Q> const& r);
  106. /// Returns the transposed matrix of x
  107. ///
  108. /// @tparam C Integer between 1 and 4 included that qualify the number a column
  109. /// @tparam R Integer between 1 and 4 included that qualify the number a row
  110. /// @tparam T Floating-point or signed integer scalar types
  111. /// @tparam Q Value from qualifier enum
  112. ///
  113. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/transpose.xml">GLSL transpose man page</a>
  114. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
  115. template<length_t C, length_t R, typename T, qualifier Q>
  116. GLM_FUNC_DECL typename mat<C, R, T, Q>::transpose_type transpose(mat<C, R, T, Q> const& x);
  117. /// Return the determinant of a squared matrix.
  118. ///
  119. /// @tparam C Integer between 1 and 4 included that qualify the number a column
  120. /// @tparam R Integer between 1 and 4 included that qualify the number a row
  121. /// @tparam T Floating-point or signed integer scalar types
  122. /// @tparam Q Value from qualifier enum
  123. ///
  124. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
  125. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
  126. template<length_t C, length_t R, typename T, qualifier Q>
  127. GLM_FUNC_DECL T determinant(mat<C, R, T, Q> const& m);
  128. /// Return the inverse of a squared matrix.
  129. ///
  130. /// @tparam C Integer between 1 and 4 included that qualify the number a column
  131. /// @tparam R Integer between 1 and 4 included that qualify the number a row
  132. /// @tparam T Floating-point or signed integer scalar types
  133. /// @tparam Q Value from qualifier enum
  134. ///
  135. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
  136. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.6 Matrix Functions</a>
  137. template<length_t C, length_t R, typename T, qualifier Q>
  138. GLM_FUNC_DECL mat<C, R, T, Q> inverse(mat<C, R, T, Q> const& m);
  139. /// @}
  140. }//namespace glm
  141. #include "detail/func_matrix.inl"