1 /// @ref core 2 /// @file glm/detail/type_mat2x2.hpp 3 4 #pragma once 5 6 #include "../fwd.hpp" 7 #include "type_vec2.hpp" 8 #include "type_mat.hpp" 9 #include <limits> 10 #include <cstddef> 11 12 namespace glm 13 { 14 template <typename T, precision P = defaultp> 15 struct tmat2x2 16 { 17 typedef tvec2<T, P> col_type; 18 typedef tvec2<T, P> row_type; 19 typedef tmat2x2<T, P> type; 20 typedef tmat2x2<T, P> transpose_type; 21 typedef T value_type; 22 23 private: 24 col_type value[2]; 25 26 public: 27 // -- Constructors -- 28 29 GLM_FUNC_DECL tmat2x2() GLM_DEFAULT_CTOR; 30 GLM_FUNC_DECL tmat2x2(tmat2x2<T, P> const & m) GLM_DEFAULT; 31 template <precision Q> 32 GLM_FUNC_DECL tmat2x2(tmat2x2<T, Q> const & m); 33 34 GLM_FUNC_DECL GLM_CONSTEXPR_CTOR explicit tmat2x2(ctor); 35 GLM_FUNC_DECL explicit tmat2x2(T scalar); 36 GLM_FUNC_DECL tmat2x2( 37 T const & x1, T const & y1, 38 T const & x2, T const & y2); 39 GLM_FUNC_DECL tmat2x2( 40 col_type const & v1, 41 col_type const & v2); 42 43 // -- Conversions -- 44 45 template <typename U, typename V, typename M, typename N> 46 GLM_FUNC_DECL tmat2x2( 47 U const & x1, V const & y1, 48 M const & x2, N const & y2); 49 50 template <typename U, typename V> 51 GLM_FUNC_DECL tmat2x2( 52 tvec2<U, P> const & v1, 53 tvec2<V, P> const & v2); 54 55 // -- Matrix conversions -- 56 57 template <typename U, precision Q> 58 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat2x2<U, Q> const & m); 59 60 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat3x3<T, P> const & x); 61 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat4x4<T, P> const & x); 62 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat2x3<T, P> const & x); 63 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat3x2<T, P> const & x); 64 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat2x4<T, P> const & x); 65 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat4x2<T, P> const & x); 66 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat3x4<T, P> const & x); 67 GLM_FUNC_DECL GLM_EXPLICIT tmat2x2(tmat4x3<T, P> const & x); 68 69 // -- Accesses -- 70 71 typedef length_t length_type; lengthglm::tmat2x272 GLM_FUNC_DECL static length_type length(){return 2;} 73 74 GLM_FUNC_DECL col_type & operator[](length_type i); 75 GLM_FUNC_DECL col_type const & operator[](length_type i) const; 76 77 // -- Unary arithmetic operators -- 78 79 GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<T, P> const & v) GLM_DEFAULT; 80 81 template <typename U> 82 GLM_FUNC_DECL tmat2x2<T, P> & operator=(tmat2x2<U, P> const & m); 83 template <typename U> 84 GLM_FUNC_DECL tmat2x2<T, P> & operator+=(U s); 85 template <typename U> 86 GLM_FUNC_DECL tmat2x2<T, P> & operator+=(tmat2x2<U, P> const & m); 87 template <typename U> 88 GLM_FUNC_DECL tmat2x2<T, P> & operator-=(U s); 89 template <typename U> 90 GLM_FUNC_DECL tmat2x2<T, P> & operator-=(tmat2x2<U, P> const & m); 91 template <typename U> 92 GLM_FUNC_DECL tmat2x2<T, P> & operator*=(U s); 93 template <typename U> 94 GLM_FUNC_DECL tmat2x2<T, P> & operator*=(tmat2x2<U, P> const & m); 95 template <typename U> 96 GLM_FUNC_DECL tmat2x2<T, P> & operator/=(U s); 97 template <typename U> 98 GLM_FUNC_DECL tmat2x2<T, P> & operator/=(tmat2x2<U, P> const & m); 99 100 // -- Increment and decrement operators -- 101 102 GLM_FUNC_DECL tmat2x2<T, P> & operator++ (); 103 GLM_FUNC_DECL tmat2x2<T, P> & operator-- (); 104 GLM_FUNC_DECL tmat2x2<T, P> operator++(int); 105 GLM_FUNC_DECL tmat2x2<T, P> operator--(int); 106 }; 107 108 // -- Unary operators -- 109 110 template <typename T, precision P> 111 GLM_FUNC_DECL tmat2x2<T, P> operator+(tmat2x2<T, P> const & m); 112 113 template <typename T, precision P> 114 GLM_FUNC_DECL tmat2x2<T, P> operator-(tmat2x2<T, P> const & m); 115 116 // -- Binary operators -- 117 118 template <typename T, precision P> 119 GLM_FUNC_DECL tmat2x2<T, P> operator+(tmat2x2<T, P> const & m, T scalar); 120 121 template <typename T, precision P> 122 GLM_FUNC_DECL tmat2x2<T, P> operator+(T scalar, tmat2x2<T, P> const & m); 123 124 template <typename T, precision P> 125 GLM_FUNC_DECL tmat2x2<T, P> operator+(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2); 126 127 template <typename T, precision P> 128 GLM_FUNC_DECL tmat2x2<T, P> operator-(tmat2x2<T, P> const & m, T scalar); 129 130 template <typename T, precision P> 131 GLM_FUNC_DECL tmat2x2<T, P> operator-(T scalar, tmat2x2<T, P> const & m); 132 133 template <typename T, precision P> 134 GLM_FUNC_DECL tmat2x2<T, P> operator-(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2); 135 136 template <typename T, precision P> 137 GLM_FUNC_DECL tmat2x2<T, P> operator*(tmat2x2<T, P> const & m, T scalar); 138 139 template <typename T, precision P> 140 GLM_FUNC_DECL tmat2x2<T, P> operator*(T scalar, tmat2x2<T, P> const & m); 141 142 template <typename T, precision P> 143 GLM_FUNC_DECL typename tmat2x2<T, P>::col_type operator*(tmat2x2<T, P> const & m, typename tmat2x2<T, P>::row_type const & v); 144 145 template <typename T, precision P> 146 GLM_FUNC_DECL typename tmat2x2<T, P>::row_type operator*(typename tmat2x2<T, P>::col_type const & v, tmat2x2<T, P> const & m); 147 148 template <typename T, precision P> 149 GLM_FUNC_DECL tmat2x2<T, P> operator*(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2); 150 151 template <typename T, precision P> 152 GLM_FUNC_DECL tmat3x2<T, P> operator*(tmat2x2<T, P> const & m1, tmat3x2<T, P> const & m2); 153 154 template <typename T, precision P> 155 GLM_FUNC_DECL tmat4x2<T, P> operator*(tmat2x2<T, P> const & m1, tmat4x2<T, P> const & m2); 156 157 template <typename T, precision P> 158 GLM_FUNC_DECL tmat2x2<T, P> operator/(tmat2x2<T, P> const & m, T scalar); 159 160 template <typename T, precision P> 161 GLM_FUNC_DECL tmat2x2<T, P> operator/(T scalar, tmat2x2<T, P> const & m); 162 163 template <typename T, precision P> 164 GLM_FUNC_DECL typename tmat2x2<T, P>::col_type operator/(tmat2x2<T, P> const & m, typename tmat2x2<T, P>::row_type const & v); 165 166 template <typename T, precision P> 167 GLM_FUNC_DECL typename tmat2x2<T, P>::row_type operator/(typename tmat2x2<T, P>::col_type const & v, tmat2x2<T, P> const & m); 168 169 template <typename T, precision P> 170 GLM_FUNC_DECL tmat2x2<T, P> operator/(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2); 171 172 // -- Boolean operators -- 173 174 template <typename T, precision P> 175 GLM_FUNC_DECL bool operator==(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2); 176 177 template <typename T, precision P> 178 GLM_FUNC_DECL bool operator!=(tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2); 179 } //namespace glm 180 181 #ifndef GLM_EXTERNAL_TEMPLATE 182 #include "type_mat2x2.inl" 183 #endif 184