type_mat2x2.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /// @ref core
  2. /// @file glm/detail/type_mat2x2.hpp
  3. #pragma once
  4. #include "type_vec2.hpp"
  5. #include <limits>
  6. #include <cstddef>
  7. namespace glm
  8. {
  9. template<typename T, qualifier Q>
  10. struct mat<2, 2, T, Q>
  11. {
  12. typedef vec<2, T, Q> col_type;
  13. typedef vec<2, T, Q> row_type;
  14. typedef mat<2, 2, T, Q> type;
  15. typedef mat<2, 2, T, Q> transpose_type;
  16. typedef T value_type;
  17. private:
  18. col_type value[2];
  19. public:
  20. // -- Accesses --
  21. typedef length_t length_type;
  22. GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 2; }
  23. GLM_FUNC_DECL col_type & operator[](length_type i);
  24. GLM_FUNC_DECL GLM_CONSTEXPR col_type const& operator[](length_type i) const;
  25. // -- Constructors --
  26. GLM_FUNC_DECL GLM_CONSTEXPR mat() GLM_DEFAULT;
  27. template<qualifier P>
  28. GLM_FUNC_DECL GLM_CONSTEXPR mat(mat<2, 2, T, P> const& m);
  29. GLM_FUNC_DECL explicit GLM_CONSTEXPR mat(T scalar);
  30. GLM_FUNC_DECL GLM_CONSTEXPR mat(
  31. T const& x1, T const& y1,
  32. T const& x2, T const& y2);
  33. GLM_FUNC_DECL GLM_CONSTEXPR mat(
  34. col_type const& v1,
  35. col_type const& v2);
  36. // -- Conversions --
  37. template<typename U, typename V, typename M, typename N>
  38. GLM_FUNC_DECL GLM_CONSTEXPR mat(
  39. U const& x1, V const& y1,
  40. M const& x2, N const& y2);
  41. template<typename U, typename V>
  42. GLM_FUNC_DECL GLM_CONSTEXPR mat(
  43. vec<2, U, Q> const& v1,
  44. vec<2, V, Q> const& v2);
  45. // -- Matrix conversions --
  46. template<typename U, qualifier P>
  47. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 2, U, P> const& m);
  48. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 3, T, Q> const& x);
  49. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 4, T, Q> const& x);
  50. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 3, T, Q> const& x);
  51. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 2, T, Q> const& x);
  52. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<2, 4, T, Q> const& x);
  53. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 2, T, Q> const& x);
  54. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<3, 4, T, Q> const& x);
  55. GLM_FUNC_DECL GLM_EXPLICIT GLM_CONSTEXPR mat(mat<4, 3, T, Q> const& x);
  56. // -- Unary arithmetic operators --
  57. template<typename U>
  58. GLM_FUNC_DECL mat<2, 2, T, Q> & operator=(mat<2, 2, U, Q> const& m);
  59. template<typename U>
  60. GLM_FUNC_DECL mat<2, 2, T, Q> & operator+=(U s);
  61. template<typename U>
  62. GLM_FUNC_DECL mat<2, 2, T, Q> & operator+=(mat<2, 2, U, Q> const& m);
  63. template<typename U>
  64. GLM_FUNC_DECL mat<2, 2, T, Q> & operator-=(U s);
  65. template<typename U>
  66. GLM_FUNC_DECL mat<2, 2, T, Q> & operator-=(mat<2, 2, U, Q> const& m);
  67. template<typename U>
  68. GLM_FUNC_DECL mat<2, 2, T, Q> & operator*=(U s);
  69. template<typename U>
  70. GLM_FUNC_DECL mat<2, 2, T, Q> & operator*=(mat<2, 2, U, Q> const& m);
  71. template<typename U>
  72. GLM_FUNC_DECL mat<2, 2, T, Q> & operator/=(U s);
  73. template<typename U>
  74. GLM_FUNC_DECL mat<2, 2, T, Q> & operator/=(mat<2, 2, U, Q> const& m);
  75. // -- Increment and decrement operators --
  76. GLM_FUNC_DECL mat<2, 2, T, Q> & operator++ ();
  77. GLM_FUNC_DECL mat<2, 2, T, Q> & operator-- ();
  78. GLM_FUNC_DECL mat<2, 2, T, Q> operator++(int);
  79. GLM_FUNC_DECL mat<2, 2, T, Q> operator--(int);
  80. };
  81. // -- Unary operators --
  82. template<typename T, qualifier Q>
  83. GLM_FUNC_DECL mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m);
  84. template<typename T, qualifier Q>
  85. GLM_FUNC_DECL mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m);
  86. // -- Binary operators --
  87. template<typename T, qualifier Q>
  88. GLM_FUNC_DECL mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m, T scalar);
  89. template<typename T, qualifier Q>
  90. GLM_FUNC_DECL mat<2, 2, T, Q> operator+(T scalar, mat<2, 2, T, Q> const& m);
  91. template<typename T, qualifier Q>
  92. GLM_FUNC_DECL mat<2, 2, T, Q> operator+(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2);
  93. template<typename T, qualifier Q>
  94. GLM_FUNC_DECL mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m, T scalar);
  95. template<typename T, qualifier Q>
  96. GLM_FUNC_DECL mat<2, 2, T, Q> operator-(T scalar, mat<2, 2, T, Q> const& m);
  97. template<typename T, qualifier Q>
  98. GLM_FUNC_DECL mat<2, 2, T, Q> operator-(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2);
  99. template<typename T, qualifier Q>
  100. GLM_FUNC_DECL mat<2, 2, T, Q> operator*(mat<2, 2, T, Q> const& m, T scalar);
  101. template<typename T, qualifier Q>
  102. GLM_FUNC_DECL mat<2, 2, T, Q> operator*(T scalar, mat<2, 2, T, Q> const& m);
  103. template<typename T, qualifier Q>
  104. GLM_FUNC_DECL typename mat<2, 2, T, Q>::col_type operator*(mat<2, 2, T, Q> const& m, typename mat<2, 2, T, Q>::row_type const& v);
  105. template<typename T, qualifier Q>
  106. GLM_FUNC_DECL typename mat<2, 2, T, Q>::row_type operator*(typename mat<2, 2, T, Q>::col_type const& v, mat<2, 2, T, Q> const& m);
  107. template<typename T, qualifier Q>
  108. GLM_FUNC_DECL mat<2, 2, T, Q> operator*(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2);
  109. template<typename T, qualifier Q>
  110. GLM_FUNC_DECL mat<3, 2, T, Q> operator*(mat<2, 2, T, Q> const& m1, mat<3, 2, T, Q> const& m2);
  111. template<typename T, qualifier Q>
  112. GLM_FUNC_DECL mat<4, 2, T, Q> operator*(mat<2, 2, T, Q> const& m1, mat<4, 2, T, Q> const& m2);
  113. template<typename T, qualifier Q>
  114. GLM_FUNC_DECL mat<2, 2, T, Q> operator/(mat<2, 2, T, Q> const& m, T scalar);
  115. template<typename T, qualifier Q>
  116. GLM_FUNC_DECL mat<2, 2, T, Q> operator/(T scalar, mat<2, 2, T, Q> const& m);
  117. template<typename T, qualifier Q>
  118. GLM_FUNC_DECL typename mat<2, 2, T, Q>::col_type operator/(mat<2, 2, T, Q> const& m, typename mat<2, 2, T, Q>::row_type const& v);
  119. template<typename T, qualifier Q>
  120. GLM_FUNC_DECL typename mat<2, 2, T, Q>::row_type operator/(typename mat<2, 2, T, Q>::col_type const& v, mat<2, 2, T, Q> const& m);
  121. template<typename T, qualifier Q>
  122. GLM_FUNC_DECL mat<2, 2, T, Q> operator/(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2);
  123. // -- Boolean operators --
  124. template<typename T, qualifier Q>
  125. GLM_FUNC_DECL bool operator==(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2);
  126. template<typename T, qualifier Q>
  127. GLM_FUNC_DECL bool operator!=(mat<2, 2, T, Q> const& m1, mat<2, 2, T, Q> const& m2);
  128. } //namespace glm
  129. #ifndef GLM_EXTERNAL_TEMPLATE
  130. #include "type_mat2x2.inl"
  131. #endif