Loading...
Searching...
No Matches
vec4i.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
8// This file is generated by a script. Do not edit directly. Edit the
9// vec.template.h file to make changes.
10
11#ifndef PXR_BASE_GF_VEC4I_H
12#define PXR_BASE_GF_VEC4I_H
13
16
17#include "pxr/pxr.h"
18#include "pxr/base/gf/api.h"
19#include "pxr/base/gf/limits.h"
20#include "pxr/base/gf/traits.h"
22#include "pxr/base/tf/hash.h"
23
24#include <cstddef>
25#include <type_traits>
26
27#include <iosfwd>
28
29PXR_NAMESPACE_OPEN_SCOPE
30
31class GfVec2i;
32class GfVec3i;
33
34template <>
35struct GfIsGfVec<class GfVec4i> { static const bool value = true; };
36
46{
47public:
49 typedef int ScalarType;
50 static const size_t dimension = 4;
51
63 int x, y, z, w;
65
68 GfVec4i() = default;
69
71 constexpr explicit GfVec4i(int value)
72 : x(value), y(value), z(value), w(value)
73 {
74 }
75
77 constexpr GfVec4i(int s0, int s1, int s2, int s3)
78 : x(s0), y(s1), z(s2), w(s3)
79 {
80 }
81
83 template <class Scl>
84 constexpr explicit GfVec4i(Scl const *p)
85 : x(p[0]), y(p[1]), z(p[2]), w(p[3])
86 {
87 }
89 static GfVec4i XAxis() {
90 GfVec4i result(0);
91 result[0] = 1;
92 return result;
93 }
94
96 static GfVec4i YAxis() {
97 GfVec4i result(0);
98 result[1] = 1;
99 return result;
100 }
101
103 static GfVec4i ZAxis() {
104 GfVec4i result(0);
105 result[2] = 1;
106 return result;
107 }
108
110 static GfVec4i WAxis() {
111 GfVec4i result(0);
112 result[3] = 1;
113 return result;
114 }
115
118 static GfVec4i Axis(size_t i) {
119 GfVec4i result(0);
120 if (i < 4)
121 result[i] = 1;
122 return result;
123 }
124
126 GfVec4i &Set(int s0, int s1, int s2, int s3) {
127 x = s0;
128 y = s1;
129 z = s2;
130 w = s3;
131 return *this;
132 }
133
135 GfVec4i &Set(int const *a) {
136 return Set(a[0], a[1], a[2], a[3]);
137 }
138
144 int const *data() const { return &x; }
145 int *data() { return &x; }
146 int const *GetArray() const { return data(); }
147
149 int const &operator[](size_t i) const { return data()[i]; }
150 int &operator[](size_t i) { return data()[i]; }
151
153 friend inline size_t hash_value(GfVec4i const &vec) {
154 return TfHash::Combine(vec.x, vec.y, vec.z, vec.w);
155 }
156
158 bool operator==(GfVec4i const &other) const {
159 return x == other.x &&
160 y == other.y &&
161 z == other.z &&
162 w == other.w;
163 }
164 bool operator!=(GfVec4i const &other) const {
165 return !(*this == other);
166 }
167
168 // TODO Add inequality for other vec types...
170 GF_API
171 bool operator==(class GfVec4d const &other) const;
173 GF_API
174 bool operator==(class GfVec4f const &other) const;
176 GF_API
177 bool operator==(class GfVec4h const &other) const;
178
181 return GfVec4i(-x, -y, -z, -w);
182 }
183
185 GfVec4i &operator+=(GfVec4i const &other) {
186 x += other.x;
187 y += other.y;
188 z += other.z;
189 w += other.w;
190 return *this;
191 }
192 friend GfVec4i operator+(GfVec4i const &l, GfVec4i const &r) {
193 return GfVec4i(l) += r;
194 }
195
197 GfVec4i &operator-=(GfVec4i const &other) {
198 x -= other.x;
199 y -= other.y;
200 z -= other.z;
201 w -= other.w;
202 return *this;
203 }
204 friend GfVec4i operator-(GfVec4i const &l, GfVec4i const &r) {
205 return GfVec4i(l) -= r;
206 }
207
209 GfVec4i &operator*=(double s) {
210 x *= s;
211 y *= s;
212 z *= s;
213 w *= s;
214 return *this;
215 }
216 GfVec4i operator*(double s) const {
217 return GfVec4i(*this) *= s;
218 }
219 friend GfVec4i operator*(double s, GfVec4i const &v) {
220 return v * s;
221 }
222
225 x /= s;
226 y /= s;
227 z /= s;
228 w /= s;
229 return *this;
230 }
231 GfVec4i operator/(int s) const {
232 return GfVec4i(*this) /= s;
233 }
234
236 int operator*(GfVec4i const &v) const {
237 return x * v.x + y * v.y + z * v.z + w * v.w;
238 }
239
244 GfVec4i GetProjection(GfVec4i const &v) const {
245 return v * (*this * v);
246 }
247
253 GfVec4i GetComplement(GfVec4i const &b) const {
254 return *this - this->GetProjection(b);
255 }
256
258 int GetLengthSq() const {
259 return *this * *this;
260 }
261
262
278#if defined (doxygen)
279 constexpr GfVec2i xy() const;
280 constexpr GfVec2i xz() const;
281 constexpr GfVec2i xw() const;
282 constexpr GfVec2i yx() const;
283 constexpr GfVec2i yz() const;
284 constexpr GfVec2i yw() const;
285 constexpr GfVec2i zx() const;
286 constexpr GfVec2i zy() const;
287 constexpr GfVec2i zw() const;
288 constexpr GfVec2i wx() const;
289 constexpr GfVec2i wy() const;
290 constexpr GfVec2i wz() const;
291 constexpr GfVec3i xyz() const;
292 constexpr GfVec3i xyw() const;
293 constexpr GfVec3i xzy() const;
294 constexpr GfVec3i xzw() const;
295 constexpr GfVec3i xwy() const;
296 constexpr GfVec3i xwz() const;
297 constexpr GfVec3i yxz() const;
298 constexpr GfVec3i yxw() const;
299 constexpr GfVec3i yzx() const;
300 constexpr GfVec3i yzw() const;
301 constexpr GfVec3i ywx() const;
302 constexpr GfVec3i ywz() const;
303 constexpr GfVec3i zxy() const;
304 constexpr GfVec3i zxw() const;
305 constexpr GfVec3i zyx() const;
306 constexpr GfVec3i zyw() const;
307 constexpr GfVec3i zwx() const;
308 constexpr GfVec3i zwy() const;
309 constexpr GfVec3i wxy() const;
310 constexpr GfVec3i wxz() const;
311 constexpr GfVec3i wyx() const;
312 constexpr GfVec3i wyz() const;
313 constexpr GfVec3i wzx() const;
314 constexpr GfVec3i wzy() const;
315 constexpr GfVec4i xyzw() const;
316 constexpr GfVec4i xywz() const;
317 constexpr GfVec4i xzyw() const;
318 constexpr GfVec4i xzwy() const;
319 constexpr GfVec4i xwyz() const;
320 constexpr GfVec4i xwzy() const;
321 constexpr GfVec4i yxzw() const;
322 constexpr GfVec4i yxwz() const;
323 constexpr GfVec4i yzxw() const;
324 constexpr GfVec4i yzwx() const;
325 constexpr GfVec4i ywxz() const;
326 constexpr GfVec4i ywzx() const;
327 constexpr GfVec4i zxyw() const;
328 constexpr GfVec4i zxwy() const;
329 constexpr GfVec4i zyxw() const;
330 constexpr GfVec4i zywx() const;
331 constexpr GfVec4i zwxy() const;
332 constexpr GfVec4i zwyx() const;
333 constexpr GfVec4i wxyz() const;
334 constexpr GfVec4i wxzy() const;
335 constexpr GfVec4i wyxz() const;
336 constexpr GfVec4i wyzx() const;
337 constexpr GfVec4i wzxy() const;
338 constexpr GfVec4i wzyx() const;
340#else // !doxygen
341 // Note that these are templated on their own return type so that the
342 // declarations cost nothing in compile time & debug info unless they are
343 // actually called in a TU. Naming a different type is an error and
344 // static_assert()ed against.
345 template <class Vec = GfVec2i> constexpr Vec xy() const;
346 template <class Vec = GfVec2i> constexpr Vec xz() const;
347 template <class Vec = GfVec2i> constexpr Vec xw() const;
348 template <class Vec = GfVec2i> constexpr Vec yx() const;
349 template <class Vec = GfVec2i> constexpr Vec yz() const;
350 template <class Vec = GfVec2i> constexpr Vec yw() const;
351 template <class Vec = GfVec2i> constexpr Vec zx() const;
352 template <class Vec = GfVec2i> constexpr Vec zy() const;
353 template <class Vec = GfVec2i> constexpr Vec zw() const;
354 template <class Vec = GfVec2i> constexpr Vec wx() const;
355 template <class Vec = GfVec2i> constexpr Vec wy() const;
356 template <class Vec = GfVec2i> constexpr Vec wz() const;
357 template <class Vec = GfVec3i> constexpr Vec xyz() const;
358 template <class Vec = GfVec3i> constexpr Vec xyw() const;
359 template <class Vec = GfVec3i> constexpr Vec xzy() const;
360 template <class Vec = GfVec3i> constexpr Vec xzw() const;
361 template <class Vec = GfVec3i> constexpr Vec xwy() const;
362 template <class Vec = GfVec3i> constexpr Vec xwz() const;
363 template <class Vec = GfVec3i> constexpr Vec yxz() const;
364 template <class Vec = GfVec3i> constexpr Vec yxw() const;
365 template <class Vec = GfVec3i> constexpr Vec yzx() const;
366 template <class Vec = GfVec3i> constexpr Vec yzw() const;
367 template <class Vec = GfVec3i> constexpr Vec ywx() const;
368 template <class Vec = GfVec3i> constexpr Vec ywz() const;
369 template <class Vec = GfVec3i> constexpr Vec zxy() const;
370 template <class Vec = GfVec3i> constexpr Vec zxw() const;
371 template <class Vec = GfVec3i> constexpr Vec zyx() const;
372 template <class Vec = GfVec3i> constexpr Vec zyw() const;
373 template <class Vec = GfVec3i> constexpr Vec zwx() const;
374 template <class Vec = GfVec3i> constexpr Vec zwy() const;
375 template <class Vec = GfVec3i> constexpr Vec wxy() const;
376 template <class Vec = GfVec3i> constexpr Vec wxz() const;
377 template <class Vec = GfVec3i> constexpr Vec wyx() const;
378 template <class Vec = GfVec3i> constexpr Vec wyz() const;
379 template <class Vec = GfVec3i> constexpr Vec wzx() const;
380 template <class Vec = GfVec3i> constexpr Vec wzy() const;
381 template <class Vec = GfVec4i> constexpr Vec xyzw() const;
382 template <class Vec = GfVec4i> constexpr Vec xywz() const;
383 template <class Vec = GfVec4i> constexpr Vec xzyw() const;
384 template <class Vec = GfVec4i> constexpr Vec xzwy() const;
385 template <class Vec = GfVec4i> constexpr Vec xwyz() const;
386 template <class Vec = GfVec4i> constexpr Vec xwzy() const;
387 template <class Vec = GfVec4i> constexpr Vec yxzw() const;
388 template <class Vec = GfVec4i> constexpr Vec yxwz() const;
389 template <class Vec = GfVec4i> constexpr Vec yzxw() const;
390 template <class Vec = GfVec4i> constexpr Vec yzwx() const;
391 template <class Vec = GfVec4i> constexpr Vec ywxz() const;
392 template <class Vec = GfVec4i> constexpr Vec ywzx() const;
393 template <class Vec = GfVec4i> constexpr Vec zxyw() const;
394 template <class Vec = GfVec4i> constexpr Vec zxwy() const;
395 template <class Vec = GfVec4i> constexpr Vec zyxw() const;
396 template <class Vec = GfVec4i> constexpr Vec zywx() const;
397 template <class Vec = GfVec4i> constexpr Vec zwxy() const;
398 template <class Vec = GfVec4i> constexpr Vec zwyx() const;
399 template <class Vec = GfVec4i> constexpr Vec wxyz() const;
400 template <class Vec = GfVec4i> constexpr Vec wxzy() const;
401 template <class Vec = GfVec4i> constexpr Vec wyxz() const;
402 template <class Vec = GfVec4i> constexpr Vec wyzx() const;
403 template <class Vec = GfVec4i> constexpr Vec wzxy() const;
404 template <class Vec = GfVec4i> constexpr Vec wzyx() const;
405#endif // doxygen
406 };
407
410GF_API std::ostream& operator<<(std::ostream &, GfVec4i const &);
411
412PXR_NAMESPACE_CLOSE_SCOPE
413
414// Lower dimensions of the same scalar type, for the swizzles above. Note that
415// lower dimensions never include higher ones, so this introduces no cycle.
416#include "pxr/base/gf/vec2i.h"
417#include "pxr/base/gf/vec3i.h"
418
419PXR_NAMESPACE_OPEN_SCOPE
420
421
422template <class Vec>
423constexpr Vec
424GfVec4i::xy() const
425{
426 static_assert(std::is_same<Vec, GfVec2i>::value);
427 return Vec(x, y);
428}
429
430template <class Vec>
431constexpr Vec
432GfVec4i::xz() const
433{
434 static_assert(std::is_same<Vec, GfVec2i>::value);
435 return Vec(x, z);
436}
437
438template <class Vec>
439constexpr Vec
440GfVec4i::xw() const
441{
442 static_assert(std::is_same<Vec, GfVec2i>::value);
443 return Vec(x, w);
444}
445
446template <class Vec>
447constexpr Vec
448GfVec4i::yx() const
449{
450 static_assert(std::is_same<Vec, GfVec2i>::value);
451 return Vec(y, x);
452}
453
454template <class Vec>
455constexpr Vec
456GfVec4i::yz() const
457{
458 static_assert(std::is_same<Vec, GfVec2i>::value);
459 return Vec(y, z);
460}
461
462template <class Vec>
463constexpr Vec
464GfVec4i::yw() const
465{
466 static_assert(std::is_same<Vec, GfVec2i>::value);
467 return Vec(y, w);
468}
469
470template <class Vec>
471constexpr Vec
472GfVec4i::zx() const
473{
474 static_assert(std::is_same<Vec, GfVec2i>::value);
475 return Vec(z, x);
476}
477
478template <class Vec>
479constexpr Vec
480GfVec4i::zy() const
481{
482 static_assert(std::is_same<Vec, GfVec2i>::value);
483 return Vec(z, y);
484}
485
486template <class Vec>
487constexpr Vec
488GfVec4i::zw() const
489{
490 static_assert(std::is_same<Vec, GfVec2i>::value);
491 return Vec(z, w);
492}
493
494template <class Vec>
495constexpr Vec
496GfVec4i::wx() const
497{
498 static_assert(std::is_same<Vec, GfVec2i>::value);
499 return Vec(w, x);
500}
501
502template <class Vec>
503constexpr Vec
504GfVec4i::wy() const
505{
506 static_assert(std::is_same<Vec, GfVec2i>::value);
507 return Vec(w, y);
508}
509
510template <class Vec>
511constexpr Vec
512GfVec4i::wz() const
513{
514 static_assert(std::is_same<Vec, GfVec2i>::value);
515 return Vec(w, z);
516}
517
518template <class Vec>
519constexpr Vec
520GfVec4i::xyz() const
521{
522 static_assert(std::is_same<Vec, GfVec3i>::value);
523 return Vec(x, y, z);
524}
525
526template <class Vec>
527constexpr Vec
528GfVec4i::xyw() const
529{
530 static_assert(std::is_same<Vec, GfVec3i>::value);
531 return Vec(x, y, w);
532}
533
534template <class Vec>
535constexpr Vec
536GfVec4i::xzy() const
537{
538 static_assert(std::is_same<Vec, GfVec3i>::value);
539 return Vec(x, z, y);
540}
541
542template <class Vec>
543constexpr Vec
544GfVec4i::xzw() const
545{
546 static_assert(std::is_same<Vec, GfVec3i>::value);
547 return Vec(x, z, w);
548}
549
550template <class Vec>
551constexpr Vec
552GfVec4i::xwy() const
553{
554 static_assert(std::is_same<Vec, GfVec3i>::value);
555 return Vec(x, w, y);
556}
557
558template <class Vec>
559constexpr Vec
560GfVec4i::xwz() const
561{
562 static_assert(std::is_same<Vec, GfVec3i>::value);
563 return Vec(x, w, z);
564}
565
566template <class Vec>
567constexpr Vec
568GfVec4i::yxz() const
569{
570 static_assert(std::is_same<Vec, GfVec3i>::value);
571 return Vec(y, x, z);
572}
573
574template <class Vec>
575constexpr Vec
576GfVec4i::yxw() const
577{
578 static_assert(std::is_same<Vec, GfVec3i>::value);
579 return Vec(y, x, w);
580}
581
582template <class Vec>
583constexpr Vec
584GfVec4i::yzx() const
585{
586 static_assert(std::is_same<Vec, GfVec3i>::value);
587 return Vec(y, z, x);
588}
589
590template <class Vec>
591constexpr Vec
592GfVec4i::yzw() const
593{
594 static_assert(std::is_same<Vec, GfVec3i>::value);
595 return Vec(y, z, w);
596}
597
598template <class Vec>
599constexpr Vec
600GfVec4i::ywx() const
601{
602 static_assert(std::is_same<Vec, GfVec3i>::value);
603 return Vec(y, w, x);
604}
605
606template <class Vec>
607constexpr Vec
608GfVec4i::ywz() const
609{
610 static_assert(std::is_same<Vec, GfVec3i>::value);
611 return Vec(y, w, z);
612}
613
614template <class Vec>
615constexpr Vec
616GfVec4i::zxy() const
617{
618 static_assert(std::is_same<Vec, GfVec3i>::value);
619 return Vec(z, x, y);
620}
621
622template <class Vec>
623constexpr Vec
624GfVec4i::zxw() const
625{
626 static_assert(std::is_same<Vec, GfVec3i>::value);
627 return Vec(z, x, w);
628}
629
630template <class Vec>
631constexpr Vec
632GfVec4i::zyx() const
633{
634 static_assert(std::is_same<Vec, GfVec3i>::value);
635 return Vec(z, y, x);
636}
637
638template <class Vec>
639constexpr Vec
640GfVec4i::zyw() const
641{
642 static_assert(std::is_same<Vec, GfVec3i>::value);
643 return Vec(z, y, w);
644}
645
646template <class Vec>
647constexpr Vec
648GfVec4i::zwx() const
649{
650 static_assert(std::is_same<Vec, GfVec3i>::value);
651 return Vec(z, w, x);
652}
653
654template <class Vec>
655constexpr Vec
656GfVec4i::zwy() const
657{
658 static_assert(std::is_same<Vec, GfVec3i>::value);
659 return Vec(z, w, y);
660}
661
662template <class Vec>
663constexpr Vec
664GfVec4i::wxy() const
665{
666 static_assert(std::is_same<Vec, GfVec3i>::value);
667 return Vec(w, x, y);
668}
669
670template <class Vec>
671constexpr Vec
672GfVec4i::wxz() const
673{
674 static_assert(std::is_same<Vec, GfVec3i>::value);
675 return Vec(w, x, z);
676}
677
678template <class Vec>
679constexpr Vec
680GfVec4i::wyx() const
681{
682 static_assert(std::is_same<Vec, GfVec3i>::value);
683 return Vec(w, y, x);
684}
685
686template <class Vec>
687constexpr Vec
688GfVec4i::wyz() const
689{
690 static_assert(std::is_same<Vec, GfVec3i>::value);
691 return Vec(w, y, z);
692}
693
694template <class Vec>
695constexpr Vec
696GfVec4i::wzx() const
697{
698 static_assert(std::is_same<Vec, GfVec3i>::value);
699 return Vec(w, z, x);
700}
701
702template <class Vec>
703constexpr Vec
704GfVec4i::wzy() const
705{
706 static_assert(std::is_same<Vec, GfVec3i>::value);
707 return Vec(w, z, y);
708}
709
710template <class Vec>
711constexpr Vec
712GfVec4i::xyzw() const
713{
714 static_assert(std::is_same<Vec, GfVec4i>::value);
715 return Vec(x, y, z, w);
716}
717
718template <class Vec>
719constexpr Vec
720GfVec4i::xywz() const
721{
722 static_assert(std::is_same<Vec, GfVec4i>::value);
723 return Vec(x, y, w, z);
724}
725
726template <class Vec>
727constexpr Vec
728GfVec4i::xzyw() const
729{
730 static_assert(std::is_same<Vec, GfVec4i>::value);
731 return Vec(x, z, y, w);
732}
733
734template <class Vec>
735constexpr Vec
736GfVec4i::xzwy() const
737{
738 static_assert(std::is_same<Vec, GfVec4i>::value);
739 return Vec(x, z, w, y);
740}
741
742template <class Vec>
743constexpr Vec
744GfVec4i::xwyz() const
745{
746 static_assert(std::is_same<Vec, GfVec4i>::value);
747 return Vec(x, w, y, z);
748}
749
750template <class Vec>
751constexpr Vec
752GfVec4i::xwzy() const
753{
754 static_assert(std::is_same<Vec, GfVec4i>::value);
755 return Vec(x, w, z, y);
756}
757
758template <class Vec>
759constexpr Vec
760GfVec4i::yxzw() const
761{
762 static_assert(std::is_same<Vec, GfVec4i>::value);
763 return Vec(y, x, z, w);
764}
765
766template <class Vec>
767constexpr Vec
768GfVec4i::yxwz() const
769{
770 static_assert(std::is_same<Vec, GfVec4i>::value);
771 return Vec(y, x, w, z);
772}
773
774template <class Vec>
775constexpr Vec
776GfVec4i::yzxw() const
777{
778 static_assert(std::is_same<Vec, GfVec4i>::value);
779 return Vec(y, z, x, w);
780}
781
782template <class Vec>
783constexpr Vec
784GfVec4i::yzwx() const
785{
786 static_assert(std::is_same<Vec, GfVec4i>::value);
787 return Vec(y, z, w, x);
788}
789
790template <class Vec>
791constexpr Vec
792GfVec4i::ywxz() const
793{
794 static_assert(std::is_same<Vec, GfVec4i>::value);
795 return Vec(y, w, x, z);
796}
797
798template <class Vec>
799constexpr Vec
800GfVec4i::ywzx() const
801{
802 static_assert(std::is_same<Vec, GfVec4i>::value);
803 return Vec(y, w, z, x);
804}
805
806template <class Vec>
807constexpr Vec
808GfVec4i::zxyw() const
809{
810 static_assert(std::is_same<Vec, GfVec4i>::value);
811 return Vec(z, x, y, w);
812}
813
814template <class Vec>
815constexpr Vec
816GfVec4i::zxwy() const
817{
818 static_assert(std::is_same<Vec, GfVec4i>::value);
819 return Vec(z, x, w, y);
820}
821
822template <class Vec>
823constexpr Vec
824GfVec4i::zyxw() const
825{
826 static_assert(std::is_same<Vec, GfVec4i>::value);
827 return Vec(z, y, x, w);
828}
829
830template <class Vec>
831constexpr Vec
832GfVec4i::zywx() const
833{
834 static_assert(std::is_same<Vec, GfVec4i>::value);
835 return Vec(z, y, w, x);
836}
837
838template <class Vec>
839constexpr Vec
840GfVec4i::zwxy() const
841{
842 static_assert(std::is_same<Vec, GfVec4i>::value);
843 return Vec(z, w, x, y);
844}
845
846template <class Vec>
847constexpr Vec
848GfVec4i::zwyx() const
849{
850 static_assert(std::is_same<Vec, GfVec4i>::value);
851 return Vec(z, w, y, x);
852}
853
854template <class Vec>
855constexpr Vec
856GfVec4i::wxyz() const
857{
858 static_assert(std::is_same<Vec, GfVec4i>::value);
859 return Vec(w, x, y, z);
860}
861
862template <class Vec>
863constexpr Vec
864GfVec4i::wxzy() const
865{
866 static_assert(std::is_same<Vec, GfVec4i>::value);
867 return Vec(w, x, z, y);
868}
869
870template <class Vec>
871constexpr Vec
872GfVec4i::wyxz() const
873{
874 static_assert(std::is_same<Vec, GfVec4i>::value);
875 return Vec(w, y, x, z);
876}
877
878template <class Vec>
879constexpr Vec
880GfVec4i::wyzx() const
881{
882 static_assert(std::is_same<Vec, GfVec4i>::value);
883 return Vec(w, y, z, x);
884}
885
886template <class Vec>
887constexpr Vec
888GfVec4i::wzxy() const
889{
890 static_assert(std::is_same<Vec, GfVec4i>::value);
891 return Vec(w, z, x, y);
892}
893
894template <class Vec>
895constexpr Vec
896GfVec4i::wzyx() const
897{
898 static_assert(std::is_same<Vec, GfVec4i>::value);
899 return Vec(w, z, y, x);
900}
901
902
904inline GfVec4i
905GfCompMult(GfVec4i const &v1, GfVec4i const &v2) {
906 return GfVec4i(
907 v1.x * v2.x,
908 v1.y * v2.y,
909 v1.z * v2.z,
910 v1.w * v2.w
911 );
912}
913
915inline GfVec4i
916GfCompDiv(GfVec4i const &v1, GfVec4i const &v2) {
917 return GfVec4i(
918 v1.x / v2.x,
919 v1.y / v2.y,
920 v1.z / v2.z,
921 v1.w / v2.w
922 );
923}
924
926inline int
927GfDot(GfVec4i const &v1, GfVec4i const &v2) {
928 return v1 * v2;
929}
930
931
932PXR_NAMESPACE_CLOSE_SCOPE
933
934#endif // PXR_BASE_GF_VEC4I_H
Low-level utilities for informing users of various internal and external diagnostic conditions.
Basic type for a vector of 2 int components.
Definition vec2i.h:44
Basic type for a vector of 3 int components.
Definition vec3i.h:45
Basic type for a vector of 4 double components.
Definition vec4d.h:48
Basic type for a vector of 4 float components.
Definition vec4f.h:48
Basic type for a vector of 4 GfHalf components.
Definition vec4h.h:49
Basic type for a vector of 4 int components.
Definition vec4i.h:46
int ScalarType
Scalar element type and dimension.
Definition vec4i.h:49
static GfVec4i ZAxis()
Create a unit vector along the Z-axis.
Definition vec4i.h:103
constexpr GfVec4i(int s0, int s1, int s2, int s3)
Initialize all elements with explicit arguments.
Definition vec4i.h:77
constexpr GfVec4i(Scl const *p)
Construct with pointer to values.
Definition vec4i.h:84
static GfVec4i Axis(size_t i)
Create a unit vector along the i-th axis, zero-based.
Definition vec4i.h:118
GfVec4i & operator-=(GfVec4i const &other)
Subtraction.
Definition vec4i.h:197
friend size_t hash_value(GfVec4i const &vec)
Hash.
Definition vec4i.h:153
static GfVec4i XAxis()
Create a unit vector along the X-axis.
Definition vec4i.h:89
GfVec4i operator-() const
Create a vec with negated elements.
Definition vec4i.h:180
GfVec4i()=default
GfVec4i value-initializes to zero and performs no default initialization, like float or double.
static GfVec4i YAxis()
Create a unit vector along the Y-axis.
Definition vec4i.h:96
GfVec4i & operator+=(GfVec4i const &other)
Addition.
Definition vec4i.h:185
bool operator==(GfVec4i const &other) const
Equality comparison.
Definition vec4i.h:158
int operator*(GfVec4i const &v) const
See GfDot().
Definition vec4i.h:236
GfVec4i GetProjection(GfVec4i const &v) const
Returns the projection of this onto v.
Definition vec4i.h:244
int const * data() const
Direct data access.
Definition vec4i.h:144
GF_API bool operator==(class GfVec4f const &other) const
Equality comparison.
int const & operator[](size_t i) const
Indexing.
Definition vec4i.h:149
GF_API bool operator==(class GfVec4h const &other) const
Equality comparison.
GfVec4i & operator*=(double s)
Multiplication by scalar.
Definition vec4i.h:209
static GfVec4i WAxis()
Create a unit vector along the W-axis.
Definition vec4i.h:110
GfVec4i GetComplement(GfVec4i const &b) const
Returns the orthogonal complement of this->GetProjection(b).
Definition vec4i.h:253
GfVec4i & Set(int s0, int s1, int s2, int s3)
Set all elements with passed arguments.
Definition vec4i.h:126
GF_API bool operator==(class GfVec4d const &other) const
Equality comparison.
GfVec4i & Set(int const *a)
Set all elements with a pointer to data.
Definition vec4i.h:135
int GetLengthSq() const
Squared length.
Definition vec4i.h:258
constexpr GfVec4i(int value)
Initialize all elements to a single value.
Definition vec4i.h:71
GfVec4i & operator/=(int s)
Division by scalar.
Definition vec4i.h:224
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition hash.h:487
GF_API std::ostream & operator<<(std::ostream &, GfVec4i const &)
Output a GfVec4i.
Defines useful mathematical limits.
A metafunction with a static const bool member 'value' that is true for GfVec types,...
Definition traits.h:23
GfVec4i GfCompMult(GfVec4i const &v1, GfVec4i const &v2)
Returns component-wise multiplication of vectors v1 and v2.
Definition vec4i.h:905
int GfDot(GfVec4i const &v1, GfVec4i const &v2)
Returns the dot (inner) product of two vectors.
Definition vec4i.h:927
GfVec4i GfCompDiv(GfVec4i const &v1, GfVec4i const &v2)
Returns component-wise quotient of vectors v1 and v2.
Definition vec4i.h:916