type_mat4x2.hpp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2015 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. /// Restrictions:
  16. /// By making use of the Software for military purposes, you choose to make
  17. /// a Bunny unhappy.
  18. ///
  19. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. /// THE SOFTWARE.
  26. ///
  27. /// @ref core
  28. /// @file glm/detail/type_mat4x2.hpp
  29. /// @date 2006-10-01 / 2011-06-15
  30. /// @author Christophe Riccio
  31. ///////////////////////////////////////////////////////////////////////////////////
  32. #pragma once
  33. #include "../fwd.hpp"
  34. #include "type_vec2.hpp"
  35. #include "type_vec4.hpp"
  36. #include "type_mat.hpp"
  37. #include <limits>
  38. #include <cstddef>
  39. namespace glm
  40. {
  41. template <typename T, precision P = defaultp>
  42. struct tmat4x2
  43. {
  44. typedef tvec2<T, P> col_type;
  45. typedef tvec4<T, P> row_type;
  46. typedef tmat4x2<T, P> type;
  47. typedef tmat2x4<T, P> transpose_type;
  48. typedef T value_type;
  49. # if GLM_HAS_CONSTEXPR
  50. static GLM_CONSTEXPR length_t components = 4;
  51. static GLM_CONSTEXPR length_t cols = 2;
  52. static GLM_CONSTEXPR length_t rows = 4;
  53. static GLM_CONSTEXPR precision prec = P;
  54. # else
  55. static const length_t components = 4;
  56. static const length_t cols = 2;
  57. static const length_t rows = 4;
  58. static const precision prec = P;
  59. # endif
  60. private:
  61. /// @cond DETAIL
  62. col_type value[4];
  63. /// @endcond
  64. public:
  65. // Constructors
  66. GLM_FUNC_DECL tmat4x2();
  67. GLM_FUNC_DECL tmat4x2(tmat4x2<T, P> const & m);
  68. template <precision Q>
  69. GLM_FUNC_DECL tmat4x2(tmat4x2<T, Q> const & m);
  70. GLM_FUNC_DECL explicit tmat4x2(ctor);
  71. GLM_FUNC_DECL explicit tmat4x2(T const & x);
  72. GLM_FUNC_DECL tmat4x2(
  73. T const & x0, T const & y0,
  74. T const & x1, T const & y1,
  75. T const & x2, T const & y2,
  76. T const & x3, T const & y3);
  77. GLM_FUNC_DECL tmat4x2(
  78. col_type const & v0,
  79. col_type const & v1,
  80. col_type const & v2,
  81. col_type const & v3);
  82. //////////////////////////////////////
  83. // Conversions
  84. template <
  85. typename X1, typename Y1,
  86. typename X2, typename Y2,
  87. typename X3, typename Y3,
  88. typename X4, typename Y4>
  89. GLM_FUNC_DECL tmat4x2(
  90. X1 const & x1, Y1 const & y1,
  91. X2 const & x2, Y2 const & y2,
  92. X3 const & x3, Y3 const & y3,
  93. X4 const & x4, Y4 const & y4);
  94. template <typename V1, typename V2, typename V3, typename V4>
  95. GLM_FUNC_DECL tmat4x2(
  96. tvec2<V1, P> const & v1,
  97. tvec2<V2, P> const & v2,
  98. tvec2<V3, P> const & v3,
  99. tvec2<V4, P> const & v4);
  100. //////////////////////////////////////
  101. // Matrix conversions
  102. # ifdef GLM_FORCE_EXPLICIT_CTOR
  103. template <typename U, precision Q>
  104. GLM_FUNC_DECL explicit tmat4x2(tmat4x2<U, Q> const & m);
  105. # else
  106. template <typename U, precision Q>
  107. GLM_FUNC_DECL tmat4x2(tmat4x2<U, Q> const & m);
  108. # endif
  109. GLM_FUNC_DECL explicit tmat4x2(tmat2x2<T, P> const & x);
  110. GLM_FUNC_DECL explicit tmat4x2(tmat3x3<T, P> const & x);
  111. GLM_FUNC_DECL explicit tmat4x2(tmat4x4<T, P> const & x);
  112. GLM_FUNC_DECL explicit tmat4x2(tmat2x3<T, P> const & x);
  113. GLM_FUNC_DECL explicit tmat4x2(tmat3x2<T, P> const & x);
  114. GLM_FUNC_DECL explicit tmat4x2(tmat2x4<T, P> const & x);
  115. GLM_FUNC_DECL explicit tmat4x2(tmat4x3<T, P> const & x);
  116. GLM_FUNC_DECL explicit tmat4x2(tmat3x4<T, P> const & x);
  117. //////////////////////////////////////
  118. // Accesses
  119. # ifdef GLM_FORCE_SIZE_FUNC
  120. typedef size_t size_type;
  121. GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
  122. GLM_FUNC_DECL col_type & operator[](size_type i);
  123. GLM_FUNC_DECL col_type const & operator[](size_type i) const;
  124. # else
  125. typedef length_t length_type;
  126. GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
  127. GLM_FUNC_DECL col_type & operator[](length_type i);
  128. GLM_FUNC_DECL col_type const & operator[](length_type i) const;
  129. # endif//GLM_FORCE_SIZE_FUNC
  130. //////////////////////////////////////
  131. // Unary arithmetic operators
  132. GLM_FUNC_DECL tmat4x2<T, P> & operator=(tmat4x2<T, P> const & m);
  133. template <typename U>
  134. GLM_FUNC_DECL tmat4x2<T, P> & operator=(tmat4x2<U, P> const & m);
  135. template <typename U>
  136. GLM_FUNC_DECL tmat4x2<T, P> & operator+=(U s);
  137. template <typename U>
  138. GLM_FUNC_DECL tmat4x2<T, P> & operator+=(tmat4x2<U, P> const & m);
  139. template <typename U>
  140. GLM_FUNC_DECL tmat4x2<T, P> & operator-=(U s);
  141. template <typename U>
  142. GLM_FUNC_DECL tmat4x2<T, P> & operator-=(tmat4x2<U, P> const & m);
  143. template <typename U>
  144. GLM_FUNC_DECL tmat4x2<T, P> & operator*=(U s);
  145. template <typename U>
  146. GLM_FUNC_DECL tmat4x2<T, P> & operator/=(U s);
  147. //////////////////////////////////////
  148. // Increment and decrement operators
  149. GLM_FUNC_DECL tmat4x2<T, P> & operator++ ();
  150. GLM_FUNC_DECL tmat4x2<T, P> & operator-- ();
  151. GLM_FUNC_DECL tmat4x2<T, P> operator++(int);
  152. GLM_FUNC_DECL tmat4x2<T, P> operator--(int);
  153. };
  154. // Binary operators
  155. template <typename T, precision P>
  156. GLM_FUNC_DECL tmat4x2<T, P> operator+(tmat4x2<T, P> const & m, T const & s);
  157. template <typename T, precision P>
  158. GLM_FUNC_DECL tmat4x2<T, P> operator+(tmat4x2<T, P> const & m1, tmat4x2<T, P> const & m2);
  159. template <typename T, precision P>
  160. GLM_FUNC_DECL tmat4x2<T, P> operator-(tmat4x2<T, P> const & m, T const & s);
  161. template <typename T, precision P>
  162. GLM_FUNC_DECL tmat4x2<T, P> operator-(tmat4x2<T, P> const & m1, tmat4x2<T, P> const & m2);
  163. template <typename T, precision P>
  164. GLM_FUNC_DECL tmat4x2<T, P> operator*(tmat4x2<T, P> const & m, T const & s);
  165. template <typename T, precision P>
  166. GLM_FUNC_DECL tmat4x2<T, P> operator*(T const & s, tmat4x2<T, P> const & m);
  167. template <typename T, precision P>
  168. GLM_FUNC_DECL typename tmat4x2<T, P>::col_type operator*(tmat4x2<T, P> const & m, typename tmat4x2<T, P>::row_type const & v);
  169. template <typename T, precision P>
  170. GLM_FUNC_DECL typename tmat4x2<T, P>::row_type operator*(typename tmat4x2<T, P>::col_type const & v, tmat4x2<T, P> const & m);
  171. template <typename T, precision P>
  172. GLM_FUNC_DECL tmat3x2<T, P> operator*(tmat4x2<T, P> const & m1, tmat3x4<T, P> const & m2);
  173. template <typename T, precision P>
  174. GLM_FUNC_DECL tmat4x2<T, P> operator*(tmat4x2<T, P> const & m1, tmat4x4<T, P> const & m2);
  175. template <typename T, precision P>
  176. GLM_FUNC_DECL tmat2x3<T, P> operator*(tmat4x3<T, P> const & m1, tmat2x4<T, P> const & m2);
  177. template <typename T, precision P>
  178. GLM_FUNC_DECL tmat4x2<T, P> operator/(tmat4x2<T, P> const & m, T const & s);
  179. template <typename T, precision P>
  180. GLM_FUNC_DECL tmat4x2<T, P> operator/(T const & s, tmat4x2<T, P> const & m);
  181. // Unary constant operators
  182. template <typename T, precision P>
  183. GLM_FUNC_DECL tmat4x2<T, P> const operator-(tmat4x2<T, P> const & m);
  184. }//namespace glm
  185. #ifndef GLM_EXTERNAL_TEMPLATE
  186. #include "type_mat4x2.inl"
  187. #endif