1/// @ref core 2/// @file glm/detail/type_mat2x3.inl 3 4namespace glm 5{ 6 // -- Constructors -- 7 8# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) 9 template <typename T, precision P> 10 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3() 11 { 12# ifndef GLM_FORCE_NO_CTOR_INIT 13 this->value[0] = col_type(1, 0, 0); 14 this->value[1] = col_type(0, 1, 0); 15# endif 16 } 17# endif 18 19# if !GLM_HAS_DEFAULTED_FUNCTIONS 20 template <typename T, precision P> 21 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<T, P> const & m) 22 { 23 this->value[0] = m.value[0]; 24 this->value[1] = m.value[1]; 25 } 26# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 27 28 template <typename T, precision P> 29 template <precision Q> 30 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<T, Q> const & m) 31 { 32 this->value[0] = m.value[0]; 33 this->value[1] = m.value[1]; 34 } 35 36 template <typename T, precision P> 37 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tmat2x3<T, P>::tmat2x3(ctor) 38 {} 39 40 template <typename T, precision P> 41 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(T scalar) 42 { 43 this->value[0] = col_type(scalar, 0, 0); 44 this->value[1] = col_type(0, scalar, 0); 45 } 46 47 template <typename T, precision P> 48 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3 49 ( 50 T x0, T y0, T z0, 51 T x1, T y1, T z1 52 ) 53 { 54 this->value[0] = col_type(x0, y0, z0); 55 this->value[1] = col_type(x1, y1, z1); 56 } 57 58 template <typename T, precision P> 59 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(col_type const & v0, col_type const & v1) 60 { 61 this->value[0] = v0; 62 this->value[1] = v1; 63 } 64 65 // -- Conversion constructors -- 66 67 template <typename T, precision P> 68 template < 69 typename X1, typename Y1, typename Z1, 70 typename X2, typename Y2, typename Z2> 71 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3 72 ( 73 X1 x1, Y1 y1, Z1 z1, 74 X2 x2, Y2 y2, Z2 z2 75 ) 76 { 77 this->value[0] = col_type(static_cast<T>(x1), value_type(y1), value_type(z1)); 78 this->value[1] = col_type(static_cast<T>(x2), value_type(y2), value_type(z2)); 79 } 80 81 template <typename T, precision P> 82 template <typename V1, typename V2> 83 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tvec3<V1, P> const & v1, tvec3<V2, P> const & v2) 84 { 85 this->value[0] = col_type(v1); 86 this->value[1] = col_type(v2); 87 } 88 89 // -- Matrix conversions -- 90 91 template <typename T, precision P> 92 template <typename U, precision Q> 93 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x3<U, Q> const & m) 94 { 95 this->value[0] = col_type(m[0]); 96 this->value[1] = col_type(m[1]); 97 } 98 99 template <typename T, precision P> 100 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x2<T, P> const & m) 101 { 102 this->value[0] = col_type(m[0], 0); 103 this->value[1] = col_type(m[1], 0); 104 } 105 106 template <typename T, precision P> 107 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat3x3<T, P> const & m) 108 { 109 this->value[0] = col_type(m[0]); 110 this->value[1] = col_type(m[1]); 111 } 112 113 template <typename T, precision P> 114 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat4x4<T, P> const & m) 115 { 116 this->value[0] = col_type(m[0]); 117 this->value[1] = col_type(m[1]); 118 } 119 120 template <typename T, precision P> 121 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat2x4<T, P> const & m) 122 { 123 this->value[0] = col_type(m[0]); 124 this->value[1] = col_type(m[1]); 125 } 126 127 template <typename T, precision P> 128 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat3x2<T, P> const & m) 129 { 130 this->value[0] = col_type(m[0], 0); 131 this->value[1] = col_type(m[1], 0); 132 } 133 134 template <typename T, precision P> 135 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat3x4<T, P> const & m) 136 { 137 this->value[0] = col_type(m[0]); 138 this->value[1] = col_type(m[1]); 139 } 140 141 template <typename T, precision P> 142 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat4x2<T, P> const & m) 143 { 144 this->value[0] = col_type(m[0], 0); 145 this->value[1] = col_type(m[1], 0); 146 } 147 148 template <typename T, precision P> 149 GLM_FUNC_QUALIFIER tmat2x3<T, P>::tmat2x3(tmat4x3<T, P> const & m) 150 { 151 this->value[0] = m[0]; 152 this->value[1] = m[1]; 153 } 154 155 // -- Accesses -- 156 157 template <typename T, precision P> 158 GLM_FUNC_QUALIFIER typename tmat2x3<T, P>::col_type & tmat2x3<T, P>::operator[](typename tmat2x3<T, P>::length_type i) 159 { 160 assert(i < this->length()); 161 return this->value[i]; 162 } 163 164 template <typename T, precision P> 165 GLM_FUNC_QUALIFIER typename tmat2x3<T, P>::col_type const & tmat2x3<T, P>::operator[](typename tmat2x3<T, P>::length_type i) const 166 { 167 assert(i < this->length()); 168 return this->value[i]; 169 } 170 171 // -- Unary updatable operators -- 172 173# if !GLM_HAS_DEFAULTED_FUNCTIONS 174 template <typename T, precision P> 175 GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator=(tmat2x3<T, P> const & m) 176 { 177 this->value[0] = m[0]; 178 this->value[1] = m[1]; 179 return *this; 180 } 181# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 182 183 template <typename T, precision P> 184 template <typename U> 185 GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator=(tmat2x3<U, P> const & m) 186 { 187 this->value[0] = m[0]; 188 this->value[1] = m[1]; 189 return *this; 190 } 191 192 template <typename T, precision P> 193 template <typename U> 194 GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator+=(U s) 195 { 196 this->value[0] += s; 197 this->value[1] += s; 198 return *this; 199 } 200 201 template <typename T, precision P> 202 template <typename U> 203 GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator+=(tmat2x3<U, P> const & m) 204 { 205 this->value[0] += m[0]; 206 this->value[1] += m[1]; 207 return *this; 208 } 209 210 template <typename T, precision P> 211 template <typename U> 212 GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator-=(U s) 213 { 214 this->value[0] -= s; 215 this->value[1] -= s; 216 return *this; 217 } 218 219 template <typename T, precision P> 220 template <typename U> 221 GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator-=(tmat2x3<U, P> const & m) 222 { 223 this->value[0] -= m[0]; 224 this->value[1] -= m[1]; 225 return *this; 226 } 227 228 template <typename T, precision P> 229 template <typename U> 230 GLM_FUNC_QUALIFIER tmat2x3<T, P>& tmat2x3<T, P>::operator*=(U s) 231 { 232 this->value[0] *= s; 233 this->value[1] *= s; 234 return *this; 235 } 236 237 template <typename T, precision P> 238 template <typename U> 239 GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator/=(U s) 240 { 241 this->value[0] /= s; 242 this->value[1] /= s; 243 return *this; 244 } 245 246 // -- Increment and decrement operators -- 247 248 template <typename T, precision P> 249 GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator++() 250 { 251 ++this->value[0]; 252 ++this->value[1]; 253 return *this; 254 } 255 256 template <typename T, precision P> 257 GLM_FUNC_QUALIFIER tmat2x3<T, P> & tmat2x3<T, P>::operator--() 258 { 259 --this->value[0]; 260 --this->value[1]; 261 return *this; 262 } 263 264 template <typename T, precision P> 265 GLM_FUNC_QUALIFIER tmat2x3<T, P> tmat2x3<T, P>::operator++(int) 266 { 267 tmat2x3<T, P> Result(*this); 268 ++*this; 269 return Result; 270 } 271 272 template <typename T, precision P> 273 GLM_FUNC_QUALIFIER tmat2x3<T, P> tmat2x3<T, P>::operator--(int) 274 { 275 tmat2x3<T, P> Result(*this); 276 --*this; 277 return Result; 278 } 279 280 // -- Unary arithmetic operators -- 281 282 template <typename T, precision P> 283 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator+(tmat2x3<T, P> const & m) 284 { 285 return m; 286 } 287 288 template <typename T, precision P> 289 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator-(tmat2x3<T, P> const & m) 290 { 291 return tmat2x3<T, P>( 292 -m[0], 293 -m[1]); 294 } 295 296 // -- Binary arithmetic operators -- 297 298 template <typename T, precision P> 299 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator+(tmat2x3<T, P> const & m, T scalar) 300 { 301 return tmat2x3<T, P>( 302 m[0] + scalar, 303 m[1] + scalar); 304 } 305 306 template <typename T, precision P> 307 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator+(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2) 308 { 309 return tmat2x3<T, P>( 310 m1[0] + m2[0], 311 m1[1] + m2[1]); 312 } 313 314 template <typename T, precision P> 315 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator-(tmat2x3<T, P> const & m, T scalar) 316 { 317 return tmat2x3<T, P>( 318 m[0] - scalar, 319 m[1] - scalar); 320 } 321 322 template <typename T, precision P> 323 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator-(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2) 324 { 325 return tmat2x3<T, P>( 326 m1[0] - m2[0], 327 m1[1] - m2[1]); 328 } 329 330 template <typename T, precision P> 331 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator*(tmat2x3<T, P> const & m, T scalar) 332 { 333 return tmat2x3<T, P>( 334 m[0] * scalar, 335 m[1] * scalar); 336 } 337 338 template <typename T, precision P> 339 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator*(T scalar, tmat2x3<T, P> const & m) 340 { 341 return tmat2x3<T, P>( 342 m[0] * scalar, 343 m[1] * scalar); 344 } 345 346 template <typename T, precision P> 347 GLM_FUNC_QUALIFIER typename tmat2x3<T, P>::col_type operator* 348 ( 349 tmat2x3<T, P> const & m, 350 typename tmat2x3<T, P>::row_type const & v) 351 { 352 return typename tmat2x3<T, P>::col_type( 353 m[0][0] * v.x + m[1][0] * v.y, 354 m[0][1] * v.x + m[1][1] * v.y, 355 m[0][2] * v.x + m[1][2] * v.y); 356 } 357 358 template <typename T, precision P> 359 GLM_FUNC_QUALIFIER typename tmat2x3<T, P>::row_type operator* 360 ( 361 typename tmat2x3<T, P>::col_type const & v, 362 tmat2x3<T, P> const & m) 363 { 364 return typename tmat2x3<T, P>::row_type( 365 v.x * m[0][0] + v.y * m[0][1] + v.z * m[0][2], 366 v.x * m[1][0] + v.y * m[1][1] + v.z * m[1][2]); 367 } 368 369 template <typename T, precision P> 370 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat2x2<T, P> const & m2) 371 { 372 return tmat2x3<T, P>( 373 m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1], 374 m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1], 375 m1[0][2] * m2[0][0] + m1[1][2] * m2[0][1], 376 m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1], 377 m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1], 378 m1[0][2] * m2[1][0] + m1[1][2] * m2[1][1]); 379 } 380 381 template <typename T, precision P> 382 GLM_FUNC_QUALIFIER tmat3x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat3x2<T, P> const & m2) 383 { 384 T SrcA00 = m1[0][0]; 385 T SrcA01 = m1[0][1]; 386 T SrcA02 = m1[0][2]; 387 T SrcA10 = m1[1][0]; 388 T SrcA11 = m1[1][1]; 389 T SrcA12 = m1[1][2]; 390 391 T SrcB00 = m2[0][0]; 392 T SrcB01 = m2[0][1]; 393 T SrcB10 = m2[1][0]; 394 T SrcB11 = m2[1][1]; 395 T SrcB20 = m2[2][0]; 396 T SrcB21 = m2[2][1]; 397 398 tmat3x3<T, P> Result(uninitialize); 399 Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01; 400 Result[0][1] = SrcA01 * SrcB00 + SrcA11 * SrcB01; 401 Result[0][2] = SrcA02 * SrcB00 + SrcA12 * SrcB01; 402 Result[1][0] = SrcA00 * SrcB10 + SrcA10 * SrcB11; 403 Result[1][1] = SrcA01 * SrcB10 + SrcA11 * SrcB11; 404 Result[1][2] = SrcA02 * SrcB10 + SrcA12 * SrcB11; 405 Result[2][0] = SrcA00 * SrcB20 + SrcA10 * SrcB21; 406 Result[2][1] = SrcA01 * SrcB20 + SrcA11 * SrcB21; 407 Result[2][2] = SrcA02 * SrcB20 + SrcA12 * SrcB21; 408 return Result; 409 } 410 411 template <typename T, precision P> 412 GLM_FUNC_QUALIFIER tmat4x3<T, P> operator*(tmat2x3<T, P> const & m1, tmat4x2<T, P> const & m2) 413 { 414 return tmat4x3<T, P>( 415 m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1], 416 m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1], 417 m1[0][2] * m2[0][0] + m1[1][2] * m2[0][1], 418 m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1], 419 m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1], 420 m1[0][2] * m2[1][0] + m1[1][2] * m2[1][1], 421 m1[0][0] * m2[2][0] + m1[1][0] * m2[2][1], 422 m1[0][1] * m2[2][0] + m1[1][1] * m2[2][1], 423 m1[0][2] * m2[2][0] + m1[1][2] * m2[2][1], 424 m1[0][0] * m2[3][0] + m1[1][0] * m2[3][1], 425 m1[0][1] * m2[3][0] + m1[1][1] * m2[3][1], 426 m1[0][2] * m2[3][0] + m1[1][2] * m2[3][1]); 427 } 428 429 template <typename T, precision P> 430 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator/(tmat2x3<T, P> const & m, T scalar) 431 { 432 return tmat2x3<T, P>( 433 m[0] / scalar, 434 m[1] / scalar); 435 } 436 437 template <typename T, precision P> 438 GLM_FUNC_QUALIFIER tmat2x3<T, P> operator/(T scalar, tmat2x3<T, P> const & m) 439 { 440 return tmat2x3<T, P>( 441 scalar / m[0], 442 scalar / m[1]); 443 } 444 445 // -- Boolean operators -- 446 447 template <typename T, precision P> 448 GLM_FUNC_QUALIFIER bool operator==(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2) 449 { 450 return (m1[0] == m2[0]) && (m1[1] == m2[1]); 451 } 452 453 template <typename T, precision P> 454 GLM_FUNC_QUALIFIER bool operator!=(tmat2x3<T, P> const & m1, tmat2x3<T, P> const & m2) 455 { 456 return (m1[0] != m2[0]) || (m1[1] != m2[1]); 457 } 458} //namespace glm 459