func_matrix.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /// @ref core
  2. /// @file glm/detail/func_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. /// For each of the following built-in matrix functions, there is both a
  10. /// single-precision floating point version, where all arguments and return values
  11. /// are single precision, and a double-precision floating version, where all
  12. /// arguments and return values are double precision. Only the single-precision
  13. /// floating point version is shown.
  14. #pragma once
  15. // Dependencies
  16. #include "../detail/precision.hpp"
  17. #include "../detail/setup.hpp"
  18. #include "../detail/type_mat.hpp"
  19. #include "../vec2.hpp"
  20. #include "../vec3.hpp"
  21. #include "../vec4.hpp"
  22. #include "../mat2x2.hpp"
  23. #include "../mat2x3.hpp"
  24. #include "../mat2x4.hpp"
  25. #include "../mat3x2.hpp"
  26. #include "../mat3x3.hpp"
  27. #include "../mat3x4.hpp"
  28. #include "../mat4x2.hpp"
  29. #include "../mat4x3.hpp"
  30. #include "../mat4x4.hpp"
  31. namespace glm{
  32. namespace detail
  33. {
  34. template<typename T, precision P>
  35. struct outerProduct_trait<2, 2, T, P, vec, vec>
  36. {
  37. typedef mat<2, 2, T, P> type;
  38. };
  39. template<typename T, precision P>
  40. struct outerProduct_trait<2, 3, T, P, vec, vec>
  41. {
  42. typedef mat<3, 2, T, P> type;
  43. };
  44. template<typename T, precision P>
  45. struct outerProduct_trait<2, 4, T, P, vec, vec>
  46. {
  47. typedef mat<4, 2, T, P> type;
  48. };
  49. template<typename T, precision P>
  50. struct outerProduct_trait<3, 2, T, P, vec, vec>
  51. {
  52. typedef mat<2, 3, T, P> type;
  53. };
  54. template<typename T, precision P>
  55. struct outerProduct_trait<3, 3, T, P, vec, vec>
  56. {
  57. typedef mat<3, 3, T, P> type;
  58. };
  59. template<typename T, precision P>
  60. struct outerProduct_trait<3, 4, T, P, vec, vec>
  61. {
  62. typedef mat<4, 3, T, P> type;
  63. };
  64. template<typename T, precision P>
  65. struct outerProduct_trait<4, 2, T, P, vec, vec>
  66. {
  67. typedef mat<2, 4, T, P> type;
  68. };
  69. template<typename T, precision P>
  70. struct outerProduct_trait<4, 3, T, P, vec, vec>
  71. {
  72. typedef mat<3, 4, T, P> type;
  73. };
  74. template<typename T, precision P>
  75. struct outerProduct_trait<4, 4, T, P, vec, vec>
  76. {
  77. typedef mat<4, 4, T, P> type;
  78. };
  79. }//namespace detail
  80. /// @addtogroup core_func_matrix
  81. /// @{
  82. /// Multiply matrix x by matrix y component-wise, i.e.,
  83. /// result[i][j] is the scalar product of x[i][j] and y[i][j].
  84. ///
  85. /// @tparam matType Floating-point matrix types.
  86. ///
  87. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/matrixCompMult.xml">GLSL matrixCompMult man page</a>
  88. /// @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>
  89. template<typename T, precision P, template<typename, precision> class matType>
  90. GLM_FUNC_DECL matType<T, P> matrixCompMult(matType<T, P> const & x, matType<T, P> const & y);
  91. /// Treats the first parameter c as a column vector
  92. /// and the second parameter r as a row vector
  93. /// and does a linear algebraic matrix multiply c * r.
  94. ///
  95. /// @tparam matType Floating-point matrix types.
  96. ///
  97. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/outerProduct.xml">GLSL outerProduct man page</a>
  98. /// @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>
  99. template<int DA, int DB, typename T, precision P, template<length_t, typename, precision> class vecTypeA, template<length_t, typename, precision> class vecTypeB>
  100. GLM_FUNC_DECL typename detail::outerProduct_trait<DA, DB, T, P, vecTypeA, vecTypeB>::type outerProduct(vecTypeA<DA, T, P> const & c, vecTypeB<DB, T, P> const & r);
  101. /// Returns the transposed matrix of x
  102. ///
  103. /// @tparam matType Floating-point matrix types.
  104. ///
  105. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/transpose.xml">GLSL transpose man page</a>
  106. /// @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>
  107. # if((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC11))
  108. template<typename T, precision P, template<typename, precision> class matType>
  109. GLM_FUNC_DECL typename matType<T, P>::transpose_type transpose(matType<T, P> const & x);
  110. # endif
  111. /// Return the determinant of a squared matrix.
  112. ///
  113. /// @tparam valType Floating-point scalar types.
  114. ///
  115. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/determinant.xml">GLSL determinant man page</a>
  116. /// @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>
  117. template<typename T, precision P, template<typename, precision> class matType>
  118. GLM_FUNC_DECL T determinant(matType<T, P> const & m);
  119. /// Return the inverse of a squared matrix.
  120. ///
  121. /// @tparam valType Floating-point scalar types.
  122. ///
  123. /// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/inverse.xml">GLSL inverse man page</a>
  124. /// @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>
  125. template<typename T, precision P, template<typename, precision> class matType>
  126. GLM_FUNC_DECL matType<T, P> inverse(matType<T, P> const & m);
  127. /// @}
  128. }//namespace glm
  129. #include "func_matrix.inl"