/glm/core/type_mat4x4.hpp

https://bitbucket.org/vtlmks/include · C++ Header · 320 lines · 199 code · 49 blank · 72 comment · 0 complexity · 59f3138714cbb56baff0e4c829216604 MD5 · raw file

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref core
  24. /// @file glm/core/type_mat4x4.hpp
  25. /// @date 2005-01-27 / 2011-06-15
  26. /// @author Christophe Riccio
  27. ///////////////////////////////////////////////////////////////////////////////////
  28. #ifndef glm_core_type_mat4x4
  29. #define glm_core_type_mat4x4
  30. #include "type_mat.hpp"
  31. namespace glm{
  32. namespace detail
  33. {
  34. template <typename T> struct tvec1;
  35. template <typename T> struct tvec2;
  36. template <typename T> struct tvec3;
  37. template <typename T> struct tvec4;
  38. template <typename T> struct tmat2x2;
  39. template <typename T> struct tmat2x3;
  40. template <typename T> struct tmat2x4;
  41. template <typename T> struct tmat3x2;
  42. template <typename T> struct tmat3x3;
  43. template <typename T> struct tmat3x4;
  44. template <typename T> struct tmat4x2;
  45. template <typename T> struct tmat4x3;
  46. template <typename T> struct tmat4x4;
  47. template <typename T>
  48. struct tmat4x4
  49. {
  50. enum ctor{null};
  51. typedef T value_type;
  52. typedef std::size_t size_type;
  53. typedef tvec4<T> col_type;
  54. typedef tvec4<T> row_type;
  55. typedef tmat4x4<T> type;
  56. typedef tmat4x4<T> transpose_type;
  57. static GLM_FUNC_DECL size_type col_size();
  58. static GLM_FUNC_DECL size_type row_size();
  59. GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
  60. public:
  61. /// Implementation detail
  62. /// @cond DETAIL
  63. GLM_FUNC_DECL tmat4x4<T> _inverse() const;
  64. /// @endcond
  65. private:
  66. // Data
  67. col_type value[4];
  68. public:
  69. // Constructors
  70. GLM_FUNC_DECL tmat4x4();
  71. GLM_FUNC_DECL tmat4x4(tmat4x4 const & m);
  72. GLM_FUNC_DECL explicit tmat4x4(
  73. ctor Null);
  74. GLM_FUNC_DECL explicit tmat4x4(
  75. value_type const & x);
  76. GLM_FUNC_DECL explicit tmat4x4(
  77. value_type const & x0, value_type const & y0, value_type const & z0, value_type const & w0,
  78. value_type const & x1, value_type const & y1, value_type const & z1, value_type const & w1,
  79. value_type const & x2, value_type const & y2, value_type const & z2, value_type const & w2,
  80. value_type const & x3, value_type const & y3, value_type const & z3, value_type const & w3);
  81. GLM_FUNC_DECL explicit tmat4x4(
  82. col_type const & v0,
  83. col_type const & v1,
  84. col_type const & v2,
  85. col_type const & v3);
  86. //////////////////////////////////////
  87. // Conversions
  88. template <typename U>
  89. GLM_FUNC_DECL explicit tmat4x4(
  90. U const & x);
  91. template <
  92. typename X1, typename Y1, typename Z1, typename W1,
  93. typename X2, typename Y2, typename Z2, typename W2,
  94. typename X3, typename Y3, typename Z3, typename W3,
  95. typename X4, typename Y4, typename Z4, typename W4>
  96. GLM_FUNC_DECL explicit tmat4x4(
  97. X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1,
  98. X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2,
  99. X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3,
  100. X4 const & x4, Y4 const & y4, Z4 const & z4, W4 const & w4);
  101. template <typename V1, typename V2, typename V3, typename V4>
  102. GLM_FUNC_DECL explicit tmat4x4(
  103. tvec4<V1> const & v1,
  104. tvec4<V2> const & v2,
  105. tvec4<V3> const & v3,
  106. tvec4<V4> const & v4);
  107. // Matrix conversions
  108. template <typename U>
  109. GLM_FUNC_DECL explicit tmat4x4(tmat4x4<U> const & m);
  110. GLM_FUNC_DECL explicit tmat4x4(tmat2x2<T> const & x);
  111. GLM_FUNC_DECL explicit tmat4x4(tmat3x3<T> const & x);
  112. GLM_FUNC_DECL explicit tmat4x4(tmat2x3<T> const & x);
  113. GLM_FUNC_DECL explicit tmat4x4(tmat3x2<T> const & x);
  114. GLM_FUNC_DECL explicit tmat4x4(tmat2x4<T> const & x);
  115. GLM_FUNC_DECL explicit tmat4x4(tmat4x2<T> const & x);
  116. GLM_FUNC_DECL explicit tmat4x4(tmat3x4<T> const & x);
  117. GLM_FUNC_DECL explicit tmat4x4(tmat4x3<T> const & x);
  118. // Accesses
  119. GLM_FUNC_DECL col_type & operator[](size_type i);
  120. GLM_FUNC_DECL col_type const & operator[](size_type i) const;
  121. // Unary updatable operators
  122. GLM_FUNC_DECL tmat4x4<T> & operator= (tmat4x4<T> const & m);
  123. template <typename U>
  124. GLM_FUNC_DECL tmat4x4<T> & operator= (tmat4x4<U> const & m);
  125. template <typename U>
  126. GLM_FUNC_DECL tmat4x4<T> & operator+= (U const & s);
  127. template <typename U>
  128. GLM_FUNC_DECL tmat4x4<T> & operator+= (tmat4x4<U> const & m);
  129. template <typename U>
  130. GLM_FUNC_DECL tmat4x4<T> & operator-= (U const & s);
  131. template <typename U>
  132. GLM_FUNC_DECL tmat4x4<T> & operator-= (tmat4x4<U> const & m);
  133. template <typename U>
  134. GLM_FUNC_DECL tmat4x4<T> & operator*= (U const & s);
  135. template <typename U>
  136. GLM_FUNC_DECL tmat4x4<T> & operator*= (tmat4x4<U> const & m);
  137. template <typename U>
  138. GLM_FUNC_DECL tmat4x4<T> & operator/= (U const & s);
  139. template <typename U>
  140. GLM_FUNC_DECL tmat4x4<T> & operator/= (tmat4x4<U> const & m);
  141. GLM_FUNC_DECL tmat4x4<T> & operator++ ();
  142. GLM_FUNC_DECL tmat4x4<T> & operator-- ();
  143. };
  144. // Binary operators
  145. template <typename T>
  146. GLM_FUNC_DECL tmat4x4<T> operator+ (
  147. tmat4x4<T> const & m,
  148. typename tmat4x4<T>::value_type const & s);
  149. template <typename T>
  150. GLM_FUNC_DECL tmat4x4<T> operator+ (
  151. typename tmat4x4<T>::value_type const & s,
  152. tmat4x4<T> const & m);
  153. template <typename T>
  154. GLM_FUNC_DECL tmat4x4<T> operator+ (
  155. tmat4x4<T> const & m1,
  156. tmat4x4<T> const & m2);
  157. template <typename T>
  158. GLM_FUNC_DECL tmat4x4<T> operator- (
  159. tmat4x4<T> const & m,
  160. typename tmat4x4<T>::value_type const & s);
  161. template <typename T>
  162. GLM_FUNC_DECL tmat4x4<T> operator- (
  163. typename tmat4x4<T>::value_type const & s,
  164. tmat4x4<T> const & m);
  165. template <typename T>
  166. GLM_FUNC_DECL tmat4x4<T> operator- (
  167. tmat4x4<T> const & m1,
  168. tmat4x4<T> const & m2);
  169. template <typename T>
  170. GLM_FUNC_DECL tmat4x4<T> operator* (
  171. tmat4x4<T> const & m,
  172. typename tmat4x4<T>::value_type const & s);
  173. template <typename T>
  174. GLM_FUNC_DECL tmat4x4<T> operator* (
  175. typename tmat4x4<T>::value_type const & s,
  176. tmat4x4<T> const & m);
  177. template <typename T>
  178. GLM_FUNC_DECL typename tmat4x4<T>::col_type operator* (
  179. tmat4x4<T> const & m,
  180. typename tmat4x4<T>::row_type const & v);
  181. template <typename T>
  182. GLM_FUNC_DECL typename tmat4x4<T>::row_type operator* (
  183. typename tmat4x4<T>::col_type const & v,
  184. tmat4x4<T> const & m);
  185. template <typename T>
  186. GLM_FUNC_DECL tmat2x4<T> operator* (
  187. tmat4x4<T> const & m1,
  188. tmat2x4<T> const & m2);
  189. template <typename T>
  190. GLM_FUNC_DECL tmat3x4<T> operator* (
  191. tmat4x4<T> const & m1,
  192. tmat3x4<T> const & m2);
  193. template <typename T>
  194. GLM_FUNC_DECL tmat4x4<T> operator* (
  195. tmat4x4<T> const & m1,
  196. tmat4x4<T> const & m2);
  197. template <typename T>
  198. GLM_FUNC_DECL tmat4x4<T> operator/ (
  199. tmat4x4<T> const & m,
  200. typename tmat4x4<T>::value_type const & s);
  201. template <typename T>
  202. GLM_FUNC_DECL tmat4x4<T> operator/ (
  203. typename tmat4x4<T>::value_type const & s,
  204. tmat4x4<T> const & m);
  205. template <typename T>
  206. GLM_FUNC_DECL typename tmat4x4<T>::col_type operator/ (
  207. tmat4x4<T> const & m,
  208. typename tmat4x4<T>::row_type const & v);
  209. template <typename T>
  210. GLM_FUNC_DECL typename tmat4x4<T>::row_type operator/ (
  211. typename tmat4x4<T>::col_type & v,
  212. tmat4x4<T> const & m);
  213. template <typename T>
  214. GLM_FUNC_DECL tmat4x4<T> operator/ (
  215. tmat4x4<T> const & m1,
  216. tmat4x4<T> const & m2);
  217. // Unary constant operators
  218. template <typename T>
  219. GLM_FUNC_DECL tmat4x4<T> const operator- (
  220. tmat4x4<T> const & m);
  221. template <typename T>
  222. GLM_FUNC_DECL tmat4x4<T> const operator-- (
  223. tmat4x4<T> const & m, int);
  224. template <typename T>
  225. GLM_FUNC_DECL tmat4x4<T> const operator++ (
  226. tmat4x4<T> const & m, int);
  227. } //namespace detail
  228. /// @addtogroup core_precision
  229. /// @{
  230. /// 4 columns of 4 components matrix of low precision floating-point numbers.
  231. /// There is no guarantee on the actual precision.
  232. ///
  233. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
  234. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
  235. typedef detail::tmat4x4<lowp_float> lowp_mat4;
  236. /// 4 columns of 4 components matrix of medium precision floating-point numbers.
  237. /// There is no guarantee on the actual precision.
  238. ///
  239. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
  240. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
  241. typedef detail::tmat4x4<mediump_float> mediump_mat4;
  242. /// 4 columns of 4 components matrix of high precision floating-point numbers.
  243. /// There is no guarantee on the actual precision.
  244. ///
  245. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
  246. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
  247. typedef detail::tmat4x4<highp_float> highp_mat4;
  248. /// 4 columns of 4 components matrix of low precision floating-point numbers.
  249. /// There is no guarantee on the actual precision.
  250. ///
  251. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
  252. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
  253. typedef detail::tmat4x4<lowp_float> lowp_mat4x4;
  254. /// 4 columns of 4 components matrix of medium precision floating-point numbers.
  255. /// There is no guarantee on the actual precision.
  256. ///
  257. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
  258. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
  259. typedef detail::tmat4x4<mediump_float> mediump_mat4x4;
  260. /// 4 columns of 4 components matrix of high precision floating-point numbers.
  261. /// There is no guarantee on the actual precision.
  262. ///
  263. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.1.6 Matrices</a>
  264. /// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 4.7.2 Precision Qualifier</a>
  265. typedef detail::tmat4x4<highp_float> highp_mat4x4;
  266. /// @}
  267. }//namespace glm
  268. #ifndef GLM_EXTERNAL_TEMPLATE
  269. #include "type_mat4x4.inl"
  270. #endif//GLM_EXTERNAL_TEMPLATE
  271. #endif//glm_core_type_mat4x4