/glm/core/type_vec4.inl
C++ Header | 1378 lines | 1208 code | 113 blank | 57 comment | 14 complexity | bff185042ceb37d20962d3492610244d MD5 | raw file
1///////////////////////////////////////////////////////////////////////////////////
2/// OpenGL Mathematics (glm.g-truc.net)
3///
4/// Copyright (c) 2005 - 2012 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/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21/// THE SOFTWARE.
22///
23/// @ref core
24/// @file glm/core/type_tvec4.inl
25/// @date 2008-08-23 / 2011-06-15
26/// @author Christophe Riccio
27///////////////////////////////////////////////////////////////////////////////////
28
29namespace glm{
30namespace detail
31{
32 template <typename T>
33 GLM_FUNC_QUALIFIER typename tvec4<T>::size_type tvec4<T>::length() const
34 {
35 return 4;
36 }
37
38 //////////////////////////////////////
39 // Accesses
40
41 template <typename T>
42 GLM_FUNC_QUALIFIER typename tvec4<T>::value_type &
43 tvec4<T>::operator[]
44 (
45 size_type i
46 )
47 {
48 assert(i < this->length());
49 return (&x)[i];
50 }
51
52 template <typename T>
53 GLM_FUNC_QUALIFIER typename tvec4<T>::value_type const &
54 tvec4<T>::operator[]
55 (
56 size_type i
57 ) const
58 {
59 assert(i < this->length());
60 return (&x)[i];
61 }
62
63 //////////////////////////////////////
64 // Implicit basic constructors
65
66 template <typename T>
67 GLM_FUNC_QUALIFIER tvec4<T>::tvec4() :
68 x(value_type(0)),
69 y(value_type(0)),
70 z(value_type(0)),
71 w(value_type(0))
72 {}
73
74 template <typename T>
75 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
76 (
77 ctor
78 )
79 {}
80
81 template <typename T>
82 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
83 (
84 type const & v
85 ) :
86 x(v.x),
87 y(v.y),
88 z(v.z),
89 w(v.w)
90 {}
91
92 //////////////////////////////////////
93 // Explicit basic constructors
94
95 template <typename T>
96 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
97 (
98 value_type const & s
99 ) :
100 x(s),
101 y(s),
102 z(s),
103 w(s)
104 {}
105
106 template <typename T>
107 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
108 (
109 value_type const & s1,
110 value_type const & s2,
111 value_type const & s3,
112 value_type const & s4
113 ) :
114 x(s1),
115 y(s2),
116 z(s3),
117 w(s4)
118 {}
119
120 //////////////////////////////////////
121 // Swizzle constructors
122
123 template <typename T>
124 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
125 (
126 tref4<T> const & r
127 ) :
128 x(r.x),
129 y(r.y),
130 z(r.z),
131 w(r.w)
132 {}
133
134 template <typename T>
135 template <typename A, typename B, typename C>
136 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
137 (
138 tref2<A> const & v,
139 B const & s1,
140 C const & s2
141 ) :
142 x(value_type(v.x)),
143 y(value_type(v.y)),
144 z(value_type(s1)),
145 w(value_type(s2))
146 {}
147
148 template <typename T>
149 template <typename A, typename B, typename C>
150 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
151 (
152 A const & s1,
153 tref2<B> const & v,
154 C const & s2
155 ) :
156 x(value_type(s1)),
157 y(value_type(v.x)),
158 z(value_type(v.y)),
159 w(value_type(s2))
160 {}
161
162 template <typename T>
163 template <typename A, typename B, typename C>
164 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
165 (
166 A const & s1,
167 B const & s2,
168 tref2<C> const & v
169 ) :
170 x(value_type(s1)),
171 y(value_type(s2)),
172 z(value_type(v.x)),
173 w(value_type(v.y))
174 {}
175
176 template <typename T>
177 template <typename A, typename B>
178 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
179 (
180 tref3<A> const & v,
181 B const & s
182 ) :
183 x(value_type(v.x)),
184 y(value_type(v.y)),
185 z(value_type(v.z)),
186 w(value_type(s))
187 {}
188
189 template <typename T>
190 template <typename A, typename B>
191 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
192 (
193 A const & s,
194 tref3<B> const & v
195 ) :
196 x(value_type(s)),
197 y(value_type(v.x)),
198 z(value_type(v.y)),
199 w(value_type(v.z))
200 {}
201
202 template <typename T>
203 template <typename A, typename B>
204 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
205 (
206 tref2<A> const & v1,
207 tref2<B> const & v2
208 ) :
209 x(value_type(v1.x)),
210 y(value_type(v1.y)),
211 z(value_type(v2.x)),
212 w(value_type(v2.y))
213 {}
214
215 template <typename T>
216 template <typename A, typename B>
217 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
218 (
219 tvec2<A> const & v1,
220 tref2<B> const & v2
221 ) :
222 x(value_type(v1.x)),
223 y(value_type(v1.y)),
224 z(value_type(v2.x)),
225 w(value_type(v2.y))
226 {}
227
228 template <typename T>
229 template <typename A, typename B>
230 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
231 (
232 tref2<A> const & v1,
233 tvec2<B> const & v2
234 ) :
235 x(value_type(v1.x)),
236 y(value_type(v1.y)),
237 z(value_type(v2.x)),
238 w(value_type(v2.y))
239 {}
240
241 //////////////////////////////////////
242 // Convertion scalar constructors
243
244 template <typename T>
245 template <typename U>
246 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
247 (
248 U const & x
249 ) :
250 x(value_type(x)),
251 y(value_type(x)),
252 z(value_type(x)),
253 w(value_type(x))
254 {}
255
256 template <typename T>
257 template <typename A, typename B, typename C, typename D>
258 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
259 (
260 A const & x,
261 B const & y,
262 C const & z,
263 D const & w
264 ) :
265 x(value_type(x)),
266 y(value_type(y)),
267 z(value_type(z)),
268 w(value_type(w))
269 {}
270
271 //////////////////////////////////////
272 // Convertion vector constructors
273
274 template <typename T>
275 template <typename A, typename B, typename C>
276 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
277 (
278 tvec2<A> const & v,
279 B const & s1,
280 C const & s2
281 ) :
282 x(value_type(v.x)),
283 y(value_type(v.y)),
284 z(value_type(s1)),
285 w(value_type(s2))
286 {}
287
288 template <typename T>
289 template <typename A, typename B, typename C>
290 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
291 (
292 A const & s1,
293 tvec2<B> const & v,
294 C const & s2
295 ) :
296 x(value_type(s1)),
297 y(value_type(v.x)),
298 z(value_type(v.y)),
299 w(value_type(s2))
300 {}
301
302 template <typename T>
303 template <typename A, typename B, typename C>
304 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
305 (
306 A const & s1,
307 B const & s2,
308 tvec2<C> const & v
309 ) :
310 x(value_type(s1)),
311 y(value_type(s2)),
312 z(value_type(v.x)),
313 w(value_type(v.y))
314 {}
315
316 template <typename T>
317 template <typename A, typename B>
318 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
319 (
320 tvec3<A> const & v,
321 B const & s
322 ) :
323 x(value_type(v.x)),
324 y(value_type(v.y)),
325 z(value_type(v.z)),
326 w(value_type(s))
327 {}
328
329 template <typename T>
330 template <typename A, typename B>
331 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
332 (
333 A const & s,
334 tvec3<B> const & v
335 ) :
336 x(value_type(s)),
337 y(value_type(v.x)),
338 z(value_type(v.y)),
339 w(value_type(v.z))
340 {}
341
342 template <typename T>
343 template <typename A, typename B>
344 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
345 (
346 tvec2<A> const & v1,
347 tvec2<B> const & v2
348 ) :
349 x(value_type(v1.x)),
350 y(value_type(v1.y)),
351 z(value_type(v2.x)),
352 w(value_type(v2.y))
353 {}
354
355 template <typename T>
356 template <typename U>
357 GLM_FUNC_QUALIFIER tvec4<T>::tvec4
358 (
359 tvec4<U> const & v
360 ) :
361 x(value_type(v.x)),
362 y(value_type(v.y)),
363 z(value_type(v.z)),
364 w(value_type(v.w))
365 {}
366
367 //////////////////////////////////////
368 // Unary arithmetic operators
369
370 template <typename T>
371 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator=
372 (
373 tvec4<T> const & v
374 )
375 {
376 this->x = v.x;
377 this->y = v.y;
378 this->z = v.z;
379 this->w = v.w;
380 return *this;
381 }
382
383 template <typename T>
384 template <typename U>
385 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator=
386 (
387 tvec4<U> const & v
388 )
389 {
390 this->x = T(v.x);
391 this->y = T(v.y);
392 this->z = T(v.z);
393 this->w = T(v.w);
394 return *this;
395 }
396
397 template <typename T>
398 template <typename U>
399 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator+=
400 (
401 U const & s
402 )
403 {
404 this->x += T(s);
405 this->y += T(s);
406 this->z += T(s);
407 this->w += T(s);
408 return *this;
409 }
410
411 template <typename T>
412 template <typename U>
413 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator+=
414 (
415 tvec4<U> const & v
416 )
417 {
418 this->x += T(v.x);
419 this->y += T(v.y);
420 this->z += T(v.z);
421 this->w += T(v.w);
422 return *this;
423 }
424
425 template <typename T>
426 template <typename U>
427 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator-=
428 (
429 U const & s
430 )
431 {
432 this->x -= T(s);
433 this->y -= T(s);
434 this->z -= T(s);
435 this->w -= T(s);
436 return *this;
437 }
438
439 template <typename T>
440 template <typename U>
441 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator-=
442 (
443 tvec4<U> const & v
444 )
445 {
446 this->x -= T(v.x);
447 this->y -= T(v.y);
448 this->z -= T(v.z);
449 this->w -= T(v.w);
450 return *this;
451 }
452
453 template <typename T>
454 template <typename U>
455 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator*=
456 (
457 U const & s
458 )
459 {
460 this->x *= T(s);
461 this->y *= T(s);
462 this->z *= T(s);
463 this->w *= T(s);
464 return *this;
465 }
466
467 template <typename T>
468 template <typename U>
469 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator*=
470 (
471 tvec4<U> const & v
472 )
473 {
474 this->x *= T(v.x);
475 this->y *= T(v.y);
476 this->z *= T(v.z);
477 this->w *= T(v.w);
478 return *this;
479 }
480
481 template <typename T>
482 template <typename U>
483 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator/=
484 (
485 U const & s
486 )
487 {
488 this->x /= T(s);
489 this->y /= T(s);
490 this->z /= T(s);
491 this->w /= T(s);
492 return *this;
493 }
494
495 template <typename T>
496 template <typename U>
497 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator/=
498 (
499 tvec4<U> const & v
500 )
501 {
502 this->x /= T(v.x);
503 this->y /= T(v.y);
504 this->z /= T(v.z);
505 this->w /= T(v.w);
506 return *this;
507 }
508
509 template <typename T>
510 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator++()
511 {
512 ++this->x;
513 ++this->y;
514 ++this->z;
515 ++this->w;
516 return *this;
517 }
518
519 template <typename T>
520 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator--()
521 {
522 --this->x;
523 --this->y;
524 --this->z;
525 --this->w;
526 return *this;
527 }
528
529 //////////////////////////////////////
530 // Unary bit operators
531
532 template <typename T>
533 template <typename U>
534 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator%=
535 (
536 U const & s
537 )
538 {
539 this->x %= T(s);
540 this->y %= T(s);
541 this->z %= T(s);
542 this->w %= T(s);
543 return *this;
544 }
545
546 template <typename T>
547 template <typename U>
548 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator%=
549 (
550 tvec4<U> const & v
551 )
552 {
553 this->x %= T(v.x);
554 this->y %= T(v.y);
555 this->z %= T(v.z);
556 this->w %= T(v.w);
557 return *this;
558 }
559
560 template <typename T>
561 template <typename U>
562 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator&=
563 (
564 U const & s
565 )
566 {
567 this->x &= T(s);
568 this->y &= T(s);
569 this->z &= T(s);
570 this->w &= T(s);
571 return *this;
572 }
573
574 template <typename T>
575 template <typename U>
576 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator&=
577 (
578 tvec4<U> const & v
579 )
580 {
581 this->x &= T(v.x);
582 this->y &= T(v.y);
583 this->z &= T(v.z);
584 this->w &= T(v.w);
585 return *this;
586 }
587
588 template <typename T>
589 template <typename U>
590 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator|=
591 (
592 U const & s
593 )
594 {
595 this->x |= T(s);
596 this->y |= T(s);
597 this->z |= T(s);
598 this->w |= T(s);
599 return *this;
600 }
601
602 template <typename T>
603 template <typename U>
604 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator|=
605 (
606 tvec4<U> const & v
607 )
608 {
609 this->x |= T(v.x);
610 this->y |= T(v.y);
611 this->z |= T(v.z);
612 this->w |= T(v.w);
613 return *this;
614 }
615
616 template <typename T>
617 template <typename U>
618 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator^=
619 (
620 U const & s
621 )
622 {
623 this->x ^= T(s);
624 this->y ^= T(s);
625 this->z ^= T(s);
626 this->w ^= T(s);
627 return *this;
628 }
629
630 template <typename T>
631 template <typename U>
632 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator^=
633 (
634 tvec4<U> const & v
635 )
636 {
637 this->x ^= T(v.x);
638 this->y ^= T(v.y);
639 this->z ^= T(v.z);
640 this->w ^= T(v.w);
641 return *this;
642 }
643
644 template <typename T>
645 template <typename U>
646 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator<<=
647 (
648 U const & s
649 )
650 {
651 this->x <<= T(s);
652 this->y <<= T(s);
653 this->z <<= T(s);
654 this->w <<= T(s);
655 return *this;
656 }
657
658 template <typename T>
659 template <typename U>
660 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator<<=
661 (
662 tvec4<U> const & v
663 )
664 {
665 this->x <<= T(v.x);
666 this->y <<= T(v.y);
667 this->z <<= T(v.z);
668 this->w <<= T(v.w);
669 return *this;
670 }
671
672 template <typename T>
673 template <typename U>
674 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator>>=
675 (
676 U const & s
677 )
678 {
679 this->x >>= T(s);
680 this->y >>= T(s);
681 this->z >>= T(s);
682 this->w >>= T(s);
683 return *this;
684 }
685
686 template <typename T>
687 template <typename U>
688 GLM_FUNC_QUALIFIER tvec4<T> & tvec4<T>::operator>>=
689 (
690 tvec4<U> const & v
691 )
692 {
693 this->x >>= T(v.x);
694 this->y >>= T(v.y);
695 this->z >>= T(v.z);
696 this->w >>= T(v.w);
697 return *this;
698 }
699
700 //////////////////////////////////////
701 // Swizzle operators
702
703 template <typename T>
704 GLM_FUNC_QUALIFIER typename tvec4<T>::value_type
705 tvec4<T>::swizzle
706 (
707 comp x
708 ) const
709 {
710 return (*this)[x];
711 }
712
713 template <typename T>
714 GLM_FUNC_QUALIFIER tvec2<T> tvec4<T>::swizzle
715 (
716 comp x,
717 comp y
718 ) const
719 {
720 return tvec2<T>(
721 (*this)[x],
722 (*this)[y]);
723 }
724
725 template <typename T>
726 GLM_FUNC_QUALIFIER tvec3<T> tvec4<T>::swizzle
727 (
728 comp x,
729 comp y,
730 comp z
731 ) const
732 {
733 return tvec3<T>(
734 (*this)[x],
735 (*this)[y],
736 (*this)[z]);
737 }
738
739 template <typename T>
740 GLM_FUNC_QUALIFIER tvec4<T> tvec4<T>::swizzle
741 (
742 comp x,
743 comp y,
744 comp z,
745 comp w
746 ) const
747 {
748 return tvec4<T>(
749 (*this)[x],
750 (*this)[y],
751 (*this)[z],
752 (*this)[w]);
753 }
754
755 template <typename T>
756 GLM_FUNC_QUALIFIER tref2<T> tvec4<T>::swizzle
757 (
758 comp x,
759 comp y
760 )
761 {
762 return tref2<T>(
763 (*this)[x],
764 (*this)[y]);
765 }
766
767 template <typename T>
768 GLM_FUNC_QUALIFIER tref3<T> tvec4<T>::swizzle
769 (
770 comp x,
771 comp y,
772 comp z
773 )
774 {
775 return tref3<T>(
776 (*this)[x],
777 (*this)[y],
778 (*this)[z]);
779 }
780
781 template <typename T>
782 GLM_FUNC_QUALIFIER tref4<T> tvec4<T>::swizzle
783 (
784 comp x,
785 comp y,
786 comp z,
787 comp w
788 )
789 {
790 return tref4<T>(
791 (*this)[x],
792 (*this)[y],
793 (*this)[z],
794 (*this)[w]);
795 }
796
797 //////////////////////////////////////
798 // Binary arithmetic operators
799
800 template <typename T>
801 GLM_FUNC_QUALIFIER tvec4<T> operator+
802 (
803 tvec4<T> const & v,
804 typename tvec4<T>::value_type const & s
805 )
806 {
807 return tvec4<T>(
808 v.x + s,
809 v.y + s,
810 v.z + s,
811 v.w + s);
812 }
813
814 template <typename T>
815 GLM_FUNC_QUALIFIER tvec4<T> operator+
816 (
817 typename tvec4<T>::value_type const & s,
818 tvec4<T> const & v
819 )
820 {
821 return tvec4<T>(
822 s + v.x,
823 s + v.y,
824 s + v.z,
825 s + v.w);
826 }
827
828 template <typename T>
829 GLM_FUNC_QUALIFIER tvec4<T> operator+
830 (
831 tvec4<T> const & v1,
832 tvec4<T> const & v2
833 )
834 {
835 return tvec4<T>(
836 v1.x + v2.x,
837 v1.y + v2.y,
838 v1.z + v2.z,
839 v1.w + v2.w);
840 }
841
842 //operator-
843 template <typename T>
844 GLM_FUNC_QUALIFIER tvec4<T> operator-
845 (
846 tvec4<T> const & v,
847 typename tvec4<T>::value_type const & s
848 )
849 {
850 return tvec4<T>(
851 v.x - s,
852 v.y - s,
853 v.z - s,
854 v.w - s);
855 }
856
857 template <typename T>
858 GLM_FUNC_QUALIFIER tvec4<T> operator-
859 (
860 typename tvec4<T>::value_type const & s,
861 tvec4<T> const & v
862 )
863 {
864 return tvec4<T>(
865 s - v.x,
866 s - v.y,
867 s - v.z,
868 s - v.w);
869 }
870
871 template <typename T>
872 GLM_FUNC_QUALIFIER tvec4<T> operator-
873 (
874 tvec4<T> const & v1,
875 tvec4<T> const & v2
876 )
877 {
878 return tvec4<T>(
879 v1.x - v2.x,
880 v1.y - v2.y,
881 v1.z - v2.z,
882 v1.w - v2.w);
883 }
884
885 //operator*
886 template <typename T>
887 GLM_FUNC_QUALIFIER tvec4<T> operator*
888 (
889 tvec4<T> const & v,
890 typename tvec4<T>::value_type const & s
891 )
892 {
893 return tvec4<T>(
894 v.x * s,
895 v.y * s,
896 v.z * s,
897 v.w * s);
898 }
899
900 template <typename T>
901 GLM_FUNC_QUALIFIER tvec4<T> operator*
902 (
903 typename tvec4<T>::value_type const & s,
904 tvec4<T> const & v
905 )
906 {
907 return tvec4<T>(
908 s * v.x,
909 s * v.y,
910 s * v.z,
911 s * v.w);
912 }
913
914 template <typename T>
915 GLM_FUNC_QUALIFIER tvec4<T> operator*
916 (
917 tvec4<T> const & v1,
918 tvec4<T> const & v2
919 )
920 {
921 return tvec4<T>(
922 v1.x * v2.x,
923 v1.y * v2.y,
924 v1.z * v2.z,
925 v1.w * v2.w);
926 }
927
928 //operator/
929 template <typename T>
930 GLM_FUNC_QUALIFIER tvec4<T> operator/
931 (
932 tvec4<T> const & v,
933 typename tvec4<T>::value_type const & s
934 )
935 {
936 return tvec4<T>(
937 v.x / s,
938 v.y / s,
939 v.z / s,
940 v.w / s);
941 }
942
943 template <typename T>
944 GLM_FUNC_QUALIFIER tvec4<T> operator/
945 (
946 typename tvec4<T>::value_type const & s,
947 tvec4<T> const & v
948 )
949 {
950 return tvec4<T>(
951 s / v.x,
952 s / v.y,
953 s / v.z,
954 s / v.w);
955 }
956
957 template <typename T>
958 GLM_FUNC_QUALIFIER tvec4<T> operator/
959 (
960 tvec4<T> const & v1,
961 tvec4<T> const & v2
962 )
963 {
964 return tvec4<T>(
965 v1.x / v2.x,
966 v1.y / v2.y,
967 v1.z / v2.z,
968 v1.w / v2.w);
969 }
970
971 // Unary constant operators
972 template <typename T>
973 GLM_FUNC_QUALIFIER tvec4<T> operator-
974 (
975 tvec4<T> const & v
976 )
977 {
978 return tvec4<T>(
979 -v.x,
980 -v.y,
981 -v.z,
982 -v.w);
983 }
984
985 template <typename T>
986 GLM_FUNC_QUALIFIER tvec4<T> operator++
987 (
988 tvec4<T> const & v,
989 int
990 )
991 {
992 typename tvec4<T>::value_type One(1);
993 return tvec4<T>(
994 v.x + One,
995 v.y + One,
996 v.z + One,
997 v.w + One);
998 }
999
1000 template <typename T>
1001 GLM_FUNC_QUALIFIER tvec4<T> operator--
1002 (
1003 tvec4<T> const & v,
1004 int
1005 )
1006 {
1007 typename tvec4<T>::value_type One(1);
1008 return tvec4<T>(
1009 v.x - One,
1010 v.y - One,
1011 v.z - One,
1012 v.w - One);
1013 }
1014
1015 //////////////////////////////////////
1016 // Boolean operators
1017
1018 template <typename T>
1019 GLM_FUNC_QUALIFIER bool operator==
1020 (
1021 tvec4<T> const & v1,
1022 tvec4<T> const & v2
1023 )
1024 {
1025 return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);
1026 }
1027
1028 template <typename T>
1029 GLM_FUNC_QUALIFIER bool operator!=
1030 (
1031 tvec4<T> const & v1,
1032 tvec4<T> const & v2
1033 )
1034 {
1035 return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w);
1036 }
1037
1038 //////////////////////////////////////
1039 // Binary bit operators
1040
1041 template <typename T>
1042 GLM_FUNC_QUALIFIER tvec4<T> operator%
1043 (
1044 tvec4<T> const & v,
1045 typename tvec4<T>::value_type const & s
1046 )
1047 {
1048 return tvec4<T>(
1049 v.x % s,
1050 v.y % s,
1051 v.z % s,
1052 v.w % s);
1053 }
1054
1055 template <typename T>
1056 GLM_FUNC_QUALIFIER tvec4<T> operator%
1057 (
1058 typename tvec4<T>::value_type const & s,
1059 tvec4<T> const & v
1060 )
1061 {
1062 return tvec4<T>(
1063 s % v.x,
1064 s % v.y,
1065 s % v.z,
1066 s % v.w);
1067 }
1068
1069 template <typename T>
1070 GLM_FUNC_QUALIFIER tvec4<T> operator%
1071 (
1072 tvec4<T> const & v1,
1073 tvec4<T> const & v2
1074 )
1075 {
1076 return tvec4<T>(
1077 v1.x % v2.x,
1078 v1.y % v2.y,
1079 v1.z % v2.z,
1080 v1.w % v2.w);
1081 }
1082
1083 template <typename T>
1084 GLM_FUNC_QUALIFIER tvec4<T> operator&
1085 (
1086 tvec4<T> const & v,
1087 typename tvec4<T>::value_type const & s
1088 )
1089 {
1090 return tvec4<T>(
1091 v.x & s,
1092 v.y & s,
1093 v.z & s,
1094 v.w & s);
1095 }
1096
1097 template <typename T>
1098 GLM_FUNC_QUALIFIER tvec4<T> operator&
1099 (
1100 typename tvec4<T>::value_type const & s,
1101 tvec4<T> const & v
1102 )
1103 {
1104 return tvec4<T>(
1105 s & v.x,
1106 s & v.y,
1107 s & v.z,
1108 s & v.w);
1109 }
1110
1111 template <typename T>
1112 GLM_FUNC_QUALIFIER tvec4<T> operator&
1113 (
1114 tvec4<T> const & v1,
1115 tvec4<T> const & v2
1116 )
1117 {
1118 return tvec4<T>(
1119 v1.x & v2.x,
1120 v1.y & v2.y,
1121 v1.z & v2.z,
1122 v1.w & v2.w);
1123 }
1124
1125 template <typename T>
1126 GLM_FUNC_QUALIFIER tvec4<T> operator|
1127 (
1128 tvec4<T> const & v,
1129 typename tvec4<T>::value_type const & s
1130 )
1131 {
1132 return tvec4<T>(
1133 v.x | s,
1134 v.y | s,
1135 v.z | s,
1136 v.w | s);
1137 }
1138
1139 template <typename T>
1140 GLM_FUNC_QUALIFIER tvec4<T> operator|
1141 (
1142 typename tvec4<T>::value_type const & s,
1143 tvec4<T> const & v
1144 )
1145 {
1146 return tvec4<T>(
1147 s | v.x,
1148 s | v.y,
1149 s | v.z,
1150 s | v.w);
1151 }
1152
1153 template <typename T>
1154 GLM_FUNC_QUALIFIER tvec4<T> operator|
1155 (
1156 tvec4<T> const & v1,
1157 tvec4<T> const & v2
1158 )
1159 {
1160 return tvec4<T>(
1161 v1.x | v2.x,
1162 v1.y | v2.y,
1163 v1.z | v2.z,
1164 v1.w | v2.w);
1165 }
1166
1167 template <typename T>
1168 GLM_FUNC_QUALIFIER tvec4<T> operator^
1169 (
1170 tvec4<T> const & v,
1171 typename tvec4<T>::value_type const & s
1172 )
1173 {
1174 return tvec4<T>(
1175 v.x ^ s,
1176 v.y ^ s,
1177 v.z ^ s,
1178 v.w ^ s);
1179 }
1180
1181 template <typename T>
1182 GLM_FUNC_QUALIFIER tvec4<T> operator^
1183 (
1184 typename tvec4<T>::value_type const & s,
1185 tvec4<T> const & v
1186 )
1187 {
1188 return tvec4<T>(
1189 s ^ v.x,
1190 s ^ v.y,
1191 s ^ v.z,
1192 s ^ v.w);
1193 }
1194
1195 template <typename T>
1196 GLM_FUNC_QUALIFIER tvec4<T> operator^
1197 (
1198 tvec4<T> const & v1,
1199 tvec4<T> const & v2
1200 )
1201 {
1202 return tvec4<T>(
1203 v1.x ^ v2.x,
1204 v1.y ^ v2.y,
1205 v1.z ^ v2.z,
1206 v1.w ^ v2.w);
1207 }
1208
1209 template <typename T>
1210 GLM_FUNC_QUALIFIER tvec4<T> operator<<
1211 (
1212 tvec4<T> const & v,
1213 typename tvec4<T>::value_type const & s
1214 )
1215 {
1216 return tvec4<T>(
1217 v.x << s,
1218 v.y << s,
1219 v.z << s,
1220 v.w << s);
1221 }
1222
1223 template <typename T>
1224 GLM_FUNC_QUALIFIER tvec4<T> operator<<
1225 (
1226 typename tvec4<T>::value_type const & s,
1227 tvec4<T> const & v
1228 )
1229 {
1230 return tvec4<T>(
1231 s << v.x,
1232 s << v.y,
1233 s << v.z,
1234 s << v.w);
1235 }
1236
1237 template <typename T>
1238 GLM_FUNC_QUALIFIER tvec4<T> operator<<
1239 (
1240 tvec4<T> const & v1,
1241 tvec4<T> const & v2
1242 )
1243 {
1244 return tvec4<T>(
1245 v1.x << v2.x,
1246 v1.y << v2.y,
1247 v1.z << v2.z,
1248 v1.w << v2.w);
1249 }
1250
1251 template <typename T>
1252 GLM_FUNC_QUALIFIER tvec4<T> operator>>
1253 (
1254 tvec4<T> const & v,
1255 typename tvec4<T>::value_type const & s
1256 )
1257 {
1258 return tvec4<T>(
1259 v.x >> s,
1260 v.y >> s,
1261 v.z >> s,
1262 v.w >> s);
1263 }
1264
1265 template <typename T>
1266 GLM_FUNC_QUALIFIER tvec4<T> operator>>
1267 (
1268 typename tvec4<T>::value_type const & s,
1269 tvec4<T> const & v
1270 )
1271 {
1272 return tvec4<T>(
1273 s >> v.x,
1274 s >> v.y,
1275 s >> v.z,
1276 s >> v.w);
1277 }
1278
1279 template <typename T>
1280 GLM_FUNC_QUALIFIER tvec4<T> operator>>
1281 (
1282 tvec4<T> const & v1,
1283 tvec4<T> const & v2
1284 )
1285 {
1286 return tvec4<T>(
1287 v1.x >> v2.x,
1288 v1.y >> v2.y,
1289 v1.z >> v2.z,
1290 v1.w >> v2.w);
1291 }
1292
1293 template <typename T>
1294 GLM_FUNC_QUALIFIER tvec4<T> operator~
1295 (
1296 tvec4<T> const & v
1297 )
1298 {
1299 return tvec4<T>(
1300 ~v.x,
1301 ~v.y,
1302 ~v.z,
1303 ~v.w);
1304 }
1305
1306 //////////////////////////////////////
1307 // tref definition
1308
1309 template <typename T>
1310 tref4<T>::tref4
1311 (
1312 T & x,
1313 T & y,
1314 T & z,
1315 T & w
1316 ) :
1317 x(x),
1318 y(y),
1319 z(z),
1320 w(w)
1321 {}
1322
1323 template <typename T>
1324 tref4<T>::tref4
1325 (
1326 tref4<T> const & r
1327 ) :
1328 x(r.x),
1329 y(r.y),
1330 z(r.z),
1331 w(r.w)
1332 {}
1333
1334 template <typename T>
1335 tref4<T>::tref4
1336 (
1337 tvec4<T> const & v
1338 ) :
1339 x(v.x),
1340 y(v.y),
1341 z(v.z),
1342 w(v.w)
1343 {}
1344
1345 template <typename T>
1346 tref4<T>& tref4<T>::operator=
1347 (
1348 tref4<T> const & r
1349 )
1350 {
1351 x = r.x;
1352 y = r.y;
1353 z = r.z;
1354 w = r.w;
1355 return *this;
1356 }
1357
1358 template <typename T>
1359 tref4<T>& tref4<T>::operator=
1360 (
1361 tvec4<T> const & v
1362 )
1363 {
1364 x = v.x;
1365 y = v.y;
1366 z = v.z;
1367 w = v.w;
1368 return *this;
1369 }
1370
1371 template <typename T>
1372 GLM_FUNC_QUALIFIER tvec4<T> tref4<T>::operator() ()
1373 {
1374 return tvec4<T>(this->x, this->y, this->z, this->w);
1375 }
1376
1377}//namespace detail
1378}//namespace glm