1/// @ref core 2/// @file glm/detail/type_tvec3.inl 3 4namespace glm 5{ 6 7# ifdef GLM_STATIC_CONST_MEMBERS 8 template <typename T, precision P> 9 const tvec3<T, P> tvec3<T, P>::ZERO(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)); 10 11 template <typename T, precision P> 12 const tvec3<T, P> tvec3<T, P>::X(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0)); 13 14 template <typename T, precision P> 15 const tvec3<T, P> tvec3<T, P>::Y(static_cast<T>(0), static_cast<T>(1), static_cast<T>(0)); 16 17 template <typename T, precision P> 18 const tvec3<T, P> tvec3<T, P>::Z(static_cast<T>(0), static_cast<T>(0), static_cast<T>(1)); 19 20 template <typename T, precision P> 21 const tvec3<T, P> tvec3<T, P>::XY(static_cast<T>(1), static_cast<T>(1), static_cast<T>(0)); 22 23 template <typename T, precision P> 24 const tvec3<T, P> tvec3<T, P>::XZ(static_cast<T>(1), static_cast<T>(0), static_cast<T>(1)); 25 26 template <typename T, precision P> 27 const tvec3<T, P> tvec3<T, P>::YZ(static_cast<T>(0), static_cast<T>(1), static_cast<T>(1)); 28 29 template <typename T, precision P> 30 const tvec3<T, P> tvec3<T, P>::XYZ(static_cast<T>(1), static_cast<T>(1), static_cast<T>(1)); 31# endif 32 // -- Implicit basic constructors -- 33 34# if !GLM_HAS_DEFAULTED_FUNCTIONS || !defined(GLM_FORCE_NO_CTOR_INIT) 35 template <typename T, precision P> 36 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3() 37# ifndef GLM_FORCE_NO_CTOR_INIT 38 : x(0), y(0), z(0) 39# endif 40 {} 41# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 42 43# if !GLM_HAS_DEFAULTED_FUNCTIONS 44 template <typename T, precision P> 45 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec3<T, P> const & v) 46 : x(v.x), y(v.y), z(v.z) 47 {} 48# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 49 50 template <typename T, precision P> 51 template <precision Q> 52 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec3<T, Q> const & v) 53 : x(v.x), y(v.y), z(v.z) 54 {} 55 56 // -- Explicit basic constructors -- 57 58 template <typename T, precision P> 59 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(ctor) 60 {} 61 62 template <typename T, precision P> 63 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(T scalar) 64 : x(scalar), y(scalar), z(scalar) 65 {} 66 67 template <typename T, precision P> 68 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(T a, T b, T c) 69 : x(a), y(b), z(c) 70 {} 71 72 // -- Conversion scalar constructors -- 73 74 template <typename T, precision P> 75 template <typename A, typename B, typename C> 76 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(A a, B b, C c) : 77 x(static_cast<T>(a)), 78 y(static_cast<T>(b)), 79 z(static_cast<T>(c)) 80 {} 81 82 template <typename T, precision P> 83 template <typename A, typename B, typename C> 84 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec1<A, P> const & a, tvec1<B, P> const & b, tvec1<C, P> const & c) : 85 x(static_cast<T>(a)), 86 y(static_cast<T>(b)), 87 z(static_cast<T>(c)) 88 {} 89 90 // -- Conversion vector constructors -- 91 92 template <typename T, precision P> 93 template <typename A, typename B, precision Q> 94 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec2<A, Q> const & a, B b) : 95 x(static_cast<T>(a.x)), 96 y(static_cast<T>(a.y)), 97 z(static_cast<T>(b)) 98 {} 99 100 template <typename T, precision P> 101 template <typename A, typename B, precision Q> 102 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec2<A, Q> const & a, tvec1<B, Q> const & b) : 103 x(static_cast<T>(a.x)), 104 y(static_cast<T>(a.y)), 105 z(static_cast<T>(b.x)) 106 {} 107 108 template <typename T, precision P> 109 template <typename A, typename B, precision Q> 110 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(A a, tvec2<B, Q> const & b) : 111 x(static_cast<T>(a)), 112 y(static_cast<T>(b.x)), 113 z(static_cast<T>(b.y)) 114 {} 115 116 template <typename T, precision P> 117 template <typename A, typename B, precision Q> 118 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec1<A, Q> const & a, tvec2<B, Q> const & b) : 119 x(static_cast<T>(a.x)), 120 y(static_cast<T>(b.x)), 121 z(static_cast<T>(b.y)) 122 {} 123 124 template <typename T, precision P> 125 template <typename U, precision Q> 126 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec3<U, Q> const & v) : 127 x(static_cast<T>(v.x)), 128 y(static_cast<T>(v.y)), 129 z(static_cast<T>(v.z)) 130 {} 131 132 template <typename T, precision P> 133 template <typename U, precision Q> 134 GLM_FUNC_QUALIFIER GLM_CONSTEXPR_CTOR tvec3<T, P>::tvec3(tvec4<U, Q> const & v) : 135 x(static_cast<T>(v.x)), 136 y(static_cast<T>(v.y)), 137 z(static_cast<T>(v.z)) 138 {} 139 140 // -- Component accesses -- 141 142 template <typename T, precision P> 143 GLM_FUNC_QUALIFIER T & tvec3<T, P>::operator[](typename tvec3<T, P>::length_type i) 144 { 145 assert(i >= 0 && i < this->length()); 146 return (&x)[i]; 147 } 148 149 template <typename T, precision P> 150 GLM_FUNC_QUALIFIER T const & tvec3<T, P>::operator[](typename tvec3<T, P>::length_type i) const 151 { 152 assert(i >= 0 && i < this->length()); 153 return (&x)[i]; 154 } 155 156 // -- Unary arithmetic operators -- 157 158# if !GLM_HAS_DEFAULTED_FUNCTIONS 159 template <typename T, precision P> 160 GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<T, P> const & v) 161 { 162 this->x = v.x; 163 this->y = v.y; 164 this->z = v.z; 165 return *this; 166 } 167# endif//!GLM_HAS_DEFAULTED_FUNCTIONS 168 169 template <typename T, precision P> 170 template <typename U> 171 GLM_FUNC_QUALIFIER tvec3<T, P>& tvec3<T, P>::operator=(tvec3<U, P> const & v) 172 { 173 this->x = static_cast<T>(v.x); 174 this->y = static_cast<T>(v.y); 175 this->z = static_cast<T>(v.z); 176 return *this; 177 } 178 179 template <typename T, precision P> 180 template <typename U> 181 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator+=(U scalar) 182 { 183 this->x += static_cast<T>(scalar); 184 this->y += static_cast<T>(scalar); 185 this->z += static_cast<T>(scalar); 186 return *this; 187 } 188 189 template <typename T, precision P> 190 template <typename U> 191 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator+=(tvec1<U, P> const & v) 192 { 193 this->x += static_cast<T>(v.x); 194 this->y += static_cast<T>(v.x); 195 this->z += static_cast<T>(v.x); 196 return *this; 197 } 198 199 template <typename T, precision P> 200 template <typename U> 201 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator+=(tvec3<U, P> const & v) 202 { 203 this->x += static_cast<T>(v.x); 204 this->y += static_cast<T>(v.y); 205 this->z += static_cast<T>(v.z); 206 return *this; 207 } 208 209 template <typename T, precision P> 210 template <typename U> 211 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator-=(U scalar) 212 { 213 this->x -= static_cast<T>(scalar); 214 this->y -= static_cast<T>(scalar); 215 this->z -= static_cast<T>(scalar); 216 return *this; 217 } 218 219 template <typename T, precision P> 220 template <typename U> 221 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator-=(tvec1<U, P> const & v) 222 { 223 this->x -= static_cast<T>(v.x); 224 this->y -= static_cast<T>(v.x); 225 this->z -= static_cast<T>(v.x); 226 return *this; 227 } 228 229 template <typename T, precision P> 230 template <typename U> 231 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator-=(tvec3<U, P> const & v) 232 { 233 this->x -= static_cast<T>(v.x); 234 this->y -= static_cast<T>(v.y); 235 this->z -= static_cast<T>(v.z); 236 return *this; 237 } 238 239 template <typename T, precision P> 240 template <typename U> 241 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator*=(U scalar) 242 { 243 this->x *= static_cast<T>(scalar); 244 this->y *= static_cast<T>(scalar); 245 this->z *= static_cast<T>(scalar); 246 return *this; 247 } 248 249 template <typename T, precision P> 250 template <typename U> 251 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator*=(tvec1<U, P> const & v) 252 { 253 this->x *= static_cast<T>(v.x); 254 this->y *= static_cast<T>(v.x); 255 this->z *= static_cast<T>(v.x); 256 return *this; 257 } 258 259 template <typename T, precision P> 260 template <typename U> 261 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator*=(tvec3<U, P> const & v) 262 { 263 this->x *= static_cast<T>(v.x); 264 this->y *= static_cast<T>(v.y); 265 this->z *= static_cast<T>(v.z); 266 return *this; 267 } 268 269 template <typename T, precision P> 270 template <typename U> 271 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator/=(U v) 272 { 273 this->x /= static_cast<T>(v); 274 this->y /= static_cast<T>(v); 275 this->z /= static_cast<T>(v); 276 return *this; 277 } 278 279 template <typename T, precision P> 280 template <typename U> 281 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator/=(tvec1<U, P> const & v) 282 { 283 this->x /= static_cast<T>(v.x); 284 this->y /= static_cast<T>(v.x); 285 this->z /= static_cast<T>(v.x); 286 return *this; 287 } 288 289 template <typename T, precision P> 290 template <typename U> 291 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator/=(tvec3<U, P> const & v) 292 { 293 this->x /= static_cast<T>(v.x); 294 this->y /= static_cast<T>(v.y); 295 this->z /= static_cast<T>(v.z); 296 return *this; 297 } 298 299 // -- Increment and decrement operators -- 300 301 template <typename T, precision P> 302 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator++() 303 { 304 ++this->x; 305 ++this->y; 306 ++this->z; 307 return *this; 308 } 309 310 template <typename T, precision P> 311 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator--() 312 { 313 --this->x; 314 --this->y; 315 --this->z; 316 return *this; 317 } 318 319 template <typename T, precision P> 320 GLM_FUNC_QUALIFIER tvec3<T, P> tvec3<T, P>::operator++(int) 321 { 322 tvec3<T, P> Result(*this); 323 ++*this; 324 return Result; 325 } 326 327 template <typename T, precision P> 328 GLM_FUNC_QUALIFIER tvec3<T, P> tvec3<T, P>::operator--(int) 329 { 330 tvec3<T, P> Result(*this); 331 --*this; 332 return Result; 333 } 334 335 // -- Unary bit operators -- 336 337 template <typename T, precision P> 338 template <typename U> 339 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator%=(U scalar) 340 { 341 this->x %= scalar; 342 this->y %= scalar; 343 this->z %= scalar; 344 return *this; 345 } 346 347 template <typename T, precision P> 348 template <typename U> 349 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator%=(tvec1<U, P> const & v) 350 { 351 this->x %= v.x; 352 this->y %= v.x; 353 this->z %= v.x; 354 return *this; 355 } 356 357 template <typename T, precision P> 358 template <typename U> 359 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator%=(tvec3<U, P> const & v) 360 { 361 this->x %= v.x; 362 this->y %= v.y; 363 this->z %= v.z; 364 return *this; 365 } 366 367 template <typename T, precision P> 368 template <typename U> 369 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator&=(U scalar) 370 { 371 this->x &= scalar; 372 this->y &= scalar; 373 this->z &= scalar; 374 return *this; 375 } 376 377 template <typename T, precision P> 378 template <typename U> 379 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator&=(tvec1<U, P> const & v) 380 { 381 this->x &= v.x; 382 this->y &= v.x; 383 this->z &= v.x; 384 return *this; 385 } 386 387 template <typename T, precision P> 388 template <typename U> 389 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator&=(tvec3<U, P> const & v) 390 { 391 this->x &= v.x; 392 this->y &= v.y; 393 this->z &= v.z; 394 return *this; 395 } 396 397 template <typename T, precision P> 398 template <typename U> 399 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator|=(U scalar) 400 { 401 this->x |= scalar; 402 this->y |= scalar; 403 this->z |= scalar; 404 return *this; 405 } 406 407 template <typename T, precision P> 408 template <typename U> 409 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator|=(tvec1<U, P> const & v) 410 { 411 this->x |= v.x; 412 this->y |= v.x; 413 this->z |= v.x; 414 return *this; 415 } 416 417 template <typename T, precision P> 418 template <typename U> 419 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator|=(tvec3<U, P> const & v) 420 { 421 this->x |= v.x; 422 this->y |= v.y; 423 this->z |= v.z; 424 return *this; 425 } 426 427 template <typename T, precision P> 428 template <typename U> 429 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator^=(U scalar) 430 { 431 this->x ^= scalar; 432 this->y ^= scalar; 433 this->z ^= scalar; 434 return *this; 435 } 436 437 template <typename T, precision P> 438 template <typename U> 439 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator^=(tvec1<U, P> const & v) 440 { 441 this->x ^= v.x; 442 this->y ^= v.x; 443 this->z ^= v.x; 444 return *this; 445 } 446 447 template <typename T, precision P> 448 template <typename U> 449 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator^=(tvec3<U, P> const & v) 450 { 451 this->x ^= v.x; 452 this->y ^= v.y; 453 this->z ^= v.z; 454 return *this; 455 } 456 457 template <typename T, precision P> 458 template <typename U> 459 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator<<=(U scalar) 460 { 461 this->x <<= scalar; 462 this->y <<= scalar; 463 this->z <<= scalar; 464 return *this; 465 } 466 467 template <typename T, precision P> 468 template <typename U> 469 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator<<=(tvec1<U, P> const & v) 470 { 471 this->x <<= static_cast<T>(v.x); 472 this->y <<= static_cast<T>(v.x); 473 this->z <<= static_cast<T>(v.x); 474 return *this; 475 } 476 477 template <typename T, precision P> 478 template <typename U> 479 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator<<=(tvec3<U, P> const & v) 480 { 481 this->x <<= static_cast<T>(v.x); 482 this->y <<= static_cast<T>(v.y); 483 this->z <<= static_cast<T>(v.z); 484 return *this; 485 } 486 487 template <typename T, precision P> 488 template <typename U> 489 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator>>=(U scalar) 490 { 491 this->x >>= static_cast<T>(scalar); 492 this->y >>= static_cast<T>(scalar); 493 this->z >>= static_cast<T>(scalar); 494 return *this; 495 } 496 497 template <typename T, precision P> 498 template <typename U> 499 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator>>=(tvec1<U, P> const & v) 500 { 501 this->x >>= static_cast<T>(v.x); 502 this->y >>= static_cast<T>(v.x); 503 this->z >>= static_cast<T>(v.x); 504 return *this; 505 } 506 507 template <typename T, precision P> 508 template <typename U> 509 GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator>>=(tvec3<U, P> const & v) 510 { 511 this->x >>= static_cast<T>(v.x); 512 this->y >>= static_cast<T>(v.y); 513 this->z >>= static_cast<T>(v.z); 514 return *this; 515 } 516 517 // -- Unary arithmetic operators -- 518 519 template <typename T, precision P> 520 GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v) 521 { 522 return v; 523 } 524 525 template <typename T, precision P> 526 GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v) 527 { 528 return tvec3<T, P>( 529 -v.x, 530 -v.y, 531 -v.z); 532 } 533 534 // -- Binary arithmetic operators -- 535 536 template <typename T, precision P> 537 GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v, T scalar) 538 { 539 return tvec3<T, P>( 540 v.x + scalar, 541 v.y + scalar, 542 v.z + scalar); 543 } 544 545 template <typename T, precision P> 546 GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 547 { 548 return tvec3<T, P>( 549 v.x + scalar.x, 550 v.y + scalar.x, 551 v.z + scalar.x); 552 } 553 554 template <typename T, precision P> 555 GLM_FUNC_QUALIFIER tvec3<T, P> operator+(T scalar, tvec3<T, P> const & v) 556 { 557 return tvec3<T, P>( 558 scalar + v.x, 559 scalar + v.y, 560 scalar + v.z); 561 } 562 563 template <typename T, precision P> 564 GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 565 { 566 return tvec3<T, P>( 567 scalar.x + v.x, 568 scalar.x + v.y, 569 scalar.x + v.z); 570 } 571 572 template <typename T, precision P> 573 GLM_FUNC_QUALIFIER tvec3<T, P> operator+(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 574 { 575 return tvec3<T, P>( 576 v1.x + v2.x, 577 v1.y + v2.y, 578 v1.z + v2.z); 579 } 580 581 template <typename T, precision P> 582 GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v, T scalar) 583 { 584 return tvec3<T, P>( 585 v.x - scalar, 586 v.y - scalar, 587 v.z - scalar); 588 } 589 590 template <typename T, precision P> 591 GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 592 { 593 return tvec3<T, P>( 594 v.x - scalar.x, 595 v.y - scalar.x, 596 v.z - scalar.x); 597 } 598 599 template <typename T, precision P> 600 GLM_FUNC_QUALIFIER tvec3<T, P> operator-(T scalar, tvec3<T, P> const & v) 601 { 602 return tvec3<T, P>( 603 scalar - v.x, 604 scalar - v.y, 605 scalar - v.z); 606 } 607 608 template <typename T, precision P> 609 GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 610 { 611 return tvec3<T, P>( 612 scalar.x - v.x, 613 scalar.x - v.y, 614 scalar.x - v.z); 615 } 616 617 template <typename T, precision P> 618 GLM_FUNC_QUALIFIER tvec3<T, P> operator-(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 619 { 620 return tvec3<T, P>( 621 v1.x - v2.x, 622 v1.y - v2.y, 623 v1.z - v2.z); 624 } 625 626 template <typename T, precision P> 627 GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, T scalar) 628 { 629 return tvec3<T, P>( 630 v.x * scalar, 631 v.y * scalar, 632 v.z * scalar); 633 } 634 635 template <typename T, precision P> 636 GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 637 { 638 return tvec3<T, P>( 639 v.x * scalar.x, 640 v.y * scalar.x, 641 v.z * scalar.x); 642 } 643 644 template <typename T, precision P> 645 GLM_FUNC_QUALIFIER tvec3<T, P> operator*(T scalar, tvec3<T, P> const & v) 646 { 647 return tvec3<T, P>( 648 scalar * v.x, 649 scalar * v.y, 650 scalar * v.z); 651 } 652 653 template <typename T, precision P> 654 GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 655 { 656 return tvec3<T, P>( 657 scalar.x * v.x, 658 scalar.x * v.y, 659 scalar.x * v.z); 660 } 661 662 template <typename T, precision P> 663 GLM_FUNC_QUALIFIER tvec3<T, P> operator*(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 664 { 665 return tvec3<T, P>( 666 v1.x * v2.x, 667 v1.y * v2.y, 668 v1.z * v2.z); 669 } 670 671 template <typename T, precision P> 672 GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v, T scalar) 673 { 674 return tvec3<T, P>( 675 v.x / scalar, 676 v.y / scalar, 677 v.z / scalar); 678 } 679 680 template <typename T, precision P> 681 GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 682 { 683 return tvec3<T, P>( 684 v.x / scalar.x, 685 v.y / scalar.x, 686 v.z / scalar.x); 687 } 688 689 template <typename T, precision P> 690 GLM_FUNC_QUALIFIER tvec3<T, P> operator/(T scalar, tvec3<T, P> const & v) 691 { 692 return tvec3<T, P>( 693 scalar / v.x, 694 scalar / v.y, 695 scalar / v.z); 696 } 697 698 template <typename T, precision P> 699 GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 700 { 701 return tvec3<T, P>( 702 scalar.x / v.x, 703 scalar.x / v.y, 704 scalar.x / v.z); 705 } 706 707 template <typename T, precision P> 708 GLM_FUNC_QUALIFIER tvec3<T, P> operator/(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 709 { 710 return tvec3<T, P>( 711 v1.x / v2.x, 712 v1.y / v2.y, 713 v1.z / v2.z); 714 } 715 716 // -- Binary bit operators -- 717 718 template <typename T, precision P> 719 GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v, T scalar) 720 { 721 return tvec3<T, P>( 722 v.x % scalar, 723 v.y % scalar, 724 v.z % scalar); 725 } 726 727 template <typename T, precision P> 728 GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 729 { 730 return tvec3<T, P>( 731 v.x % scalar.x, 732 v.y % scalar.x, 733 v.z % scalar.x); 734 } 735 736 template <typename T, precision P> 737 GLM_FUNC_QUALIFIER tvec3<T, P> operator%(T scalar, tvec3<T, P> const & v) 738 { 739 return tvec3<T, P>( 740 scalar % v.x, 741 scalar % v.y, 742 scalar % v.z); 743 } 744 745 template <typename T, precision P> 746 GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 747 { 748 return tvec3<T, P>( 749 scalar.x % v.x, 750 scalar.x % v.y, 751 scalar.x % v.z); 752 } 753 754 template <typename T, precision P> 755 GLM_FUNC_QUALIFIER tvec3<T, P> operator%(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 756 { 757 return tvec3<T, P>( 758 v1.x % v2.x, 759 v1.y % v2.y, 760 v1.z % v2.z); 761 } 762 763 template <typename T, precision P> 764 GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v, T scalar) 765 { 766 return tvec3<T, P>( 767 v.x & scalar, 768 v.y & scalar, 769 v.z & scalar); 770 } 771 772 template <typename T, precision P> 773 GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 774 { 775 return tvec3<T, P>( 776 v.x & scalar.x, 777 v.y & scalar.x, 778 v.z & scalar.x); 779 } 780 781 template <typename T, precision P> 782 GLM_FUNC_QUALIFIER tvec3<T, P> operator&(T scalar, tvec3<T, P> const & v) 783 { 784 return tvec3<T, P>( 785 scalar & v.x, 786 scalar & v.y, 787 scalar & v.z); 788 } 789 790 template <typename T, precision P> 791 GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 792 { 793 return tvec3<T, P>( 794 scalar.x & v.x, 795 scalar.x & v.y, 796 scalar.x & v.z); 797 } 798 799 template <typename T, precision P> 800 GLM_FUNC_QUALIFIER tvec3<T, P> operator&(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 801 { 802 return tvec3<T, P>( 803 v1.x & v2.x, 804 v1.y & v2.y, 805 v1.z & v2.z); 806 } 807 808 template <typename T, precision P> 809 GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v, T scalar) 810 { 811 return tvec3<T, P>( 812 v.x | scalar, 813 v.y | scalar, 814 v.z | scalar); 815 } 816 817 template <typename T, precision P> 818 GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 819 { 820 return tvec3<T, P>( 821 v.x | scalar.x, 822 v.y | scalar.x, 823 v.z | scalar.x); 824 } 825 826 template <typename T, precision P> 827 GLM_FUNC_QUALIFIER tvec3<T, P> operator|(T scalar, tvec3<T, P> const & v) 828 { 829 return tvec3<T, P>( 830 scalar | v.x, 831 scalar | v.y, 832 scalar | v.z); 833 } 834 835 template <typename T, precision P> 836 GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 837 { 838 return tvec3<T, P>( 839 scalar.x | v.x, 840 scalar.x | v.y, 841 scalar.x | v.z); 842 } 843 844 template <typename T, precision P> 845 GLM_FUNC_QUALIFIER tvec3<T, P> operator|(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 846 { 847 return tvec3<T, P>( 848 v1.x | v2.x, 849 v1.y | v2.y, 850 v1.z | v2.z); 851 } 852 853 template <typename T, precision P> 854 GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v, T scalar) 855 { 856 return tvec3<T, P>( 857 v.x ^ scalar, 858 v.y ^ scalar, 859 v.z ^ scalar); 860 } 861 862 template <typename T, precision P> 863 GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 864 { 865 return tvec3<T, P>( 866 v.x ^ scalar.x, 867 v.y ^ scalar.x, 868 v.z ^ scalar.x); 869 } 870 871 template <typename T, precision P> 872 GLM_FUNC_QUALIFIER tvec3<T, P> operator^(T scalar, tvec3<T, P> const & v) 873 { 874 return tvec3<T, P>( 875 scalar ^ v.x, 876 scalar ^ v.y, 877 scalar ^ v.z); 878 } 879 880 template <typename T, precision P> 881 GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 882 { 883 return tvec3<T, P>( 884 scalar.x ^ v.x, 885 scalar.x ^ v.y, 886 scalar.x ^ v.z); 887 } 888 889 template <typename T, precision P> 890 GLM_FUNC_QUALIFIER tvec3<T, P> operator^(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 891 { 892 return tvec3<T, P>( 893 v1.x ^ v2.x, 894 v1.y ^ v2.y, 895 v1.z ^ v2.z); 896 } 897 898 template <typename T, precision P> 899 GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v, T scalar) 900 { 901 return tvec3<T, P>( 902 v.x << scalar, 903 v.y << scalar, 904 v.z << scalar); 905 } 906 907 template <typename T, precision P> 908 GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 909 { 910 return tvec3<T, P>( 911 v.x << scalar.x, 912 v.y << scalar.x, 913 v.z << scalar.x); 914 } 915 916 template <typename T, precision P> 917 GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(T scalar, tvec3<T, P> const & v) 918 { 919 return tvec3<T, P>( 920 scalar << v.x, 921 scalar << v.y, 922 scalar << v.z); 923 } 924 925 template <typename T, precision P> 926 GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 927 { 928 return tvec3<T, P>( 929 scalar.x << v.x, 930 scalar.x << v.y, 931 scalar.x << v.z); 932 } 933 934 template <typename T, precision P> 935 GLM_FUNC_QUALIFIER tvec3<T, P> operator<<(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 936 { 937 return tvec3<T, P>( 938 v1.x << v2.x, 939 v1.y << v2.y, 940 v1.z << v2.z); 941 } 942 943 template <typename T, precision P> 944 GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v, T scalar) 945 { 946 return tvec3<T, P>( 947 v.x >> scalar, 948 v.y >> scalar, 949 v.z >> scalar); 950 } 951 952 template <typename T, precision P> 953 GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v, tvec1<T, P> const & scalar) 954 { 955 return tvec3<T, P>( 956 v.x >> scalar.x, 957 v.y >> scalar.x, 958 v.z >> scalar.x); 959 } 960 961 template <typename T, precision P> 962 GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(T scalar, tvec3<T, P> const & v) 963 { 964 return tvec3<T, P>( 965 scalar >> v.x, 966 scalar >> v.y, 967 scalar >> v.z); 968 } 969 970 template <typename T, precision P> 971 GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec1<T, P> const & scalar, tvec3<T, P> const & v) 972 { 973 return tvec3<T, P>( 974 scalar.x >> v.x, 975 scalar.x >> v.y, 976 scalar.x >> v.z); 977 } 978 979 template <typename T, precision P> 980 GLM_FUNC_QUALIFIER tvec3<T, P> operator>>(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 981 { 982 return tvec3<T, P>( 983 v1.x >> v2.x, 984 v1.y >> v2.y, 985 v1.z >> v2.z); 986 } 987 988 template <typename T, precision P> 989 GLM_FUNC_QUALIFIER tvec3<T, P> operator~(tvec3<T, P> const & v) 990 { 991 return tvec3<T, P>( 992 ~v.x, 993 ~v.y, 994 ~v.z); 995 } 996 997 // -- Boolean operators -- 998 999 template <typename T, precision P> 1000 GLM_FUNC_QUALIFIER bool operator==(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 1001 { 1002 return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); 1003 } 1004 1005 template <typename T, precision P> 1006 GLM_FUNC_QUALIFIER bool operator!=(tvec3<T, P> const & v1, tvec3<T, P> const & v2) 1007 { 1008 return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z); 1009 } 1010 1011 template <precision P> 1012 GLM_FUNC_QUALIFIER tvec3<bool, P> operator&&(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2) 1013 { 1014 return tvec3<bool, P>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z); 1015 } 1016 1017 template <precision P> 1018 GLM_FUNC_QUALIFIER tvec3<bool, P> operator||(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2) 1019 { 1020 return tvec3<bool, P>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z); 1021 } 1022}//namespace glm 1023