28 #ifndef PXR_BASE_GF_VEC4I_H 29 #define PXR_BASE_GF_VEC4I_H 36 #include "pxr/base/gf/api.h" 38 #include "pxr/base/gf/traits.h" 45 PXR_NAMESPACE_OPEN_SCOPE
65 static const size_t dimension = 4;
72 : _data{ value, value, value, value }
77 constexpr
GfVec4i(
int s0,
int s1,
int s2,
int s3)
78 : _data{ s0, s1, s2, s3 }
85 : _data{ p[0], p[1], p[2], p[3] }
134 return Set(a[0], a[1], a[2], a[3]);
138 int const *
data()
const {
return _data; }
139 int *
data() {
return _data; }
140 int const *GetArray()
const {
return data(); }
144 int &
operator[](
size_t i) {
return _data[i]; }
153 return _data[0] == other[0] &&
154 _data[1] == other[1] &&
155 _data[2] == other[2] &&
156 _data[3] == other[3];
158 bool operator!=(
GfVec4i const &other)
const {
159 return !(*
this == other);
175 return GfVec4i(-_data[0], -_data[1], -_data[2], -_data[3]);
180 _data[0] += other[0];
181 _data[1] += other[1];
182 _data[2] += other[2];
183 _data[3] += other[3];
192 _data[0] -= other[0];
193 _data[1] -= other[1];
194 _data[2] -= other[2];
195 _data[3] -= other[3];
210 GfVec4i operator*(
double s)
const {
225 GfVec4i operator/(
int s)
const {
231 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2] + _data[3] * v[3];
239 return v * (*
this * v);
253 return *
this * *
this;
295 PXR_NAMESPACE_CLOSE_SCOPE
297 #endif // PXR_BASE_GF_VEC4I_H static GfVec4i WAxis()
Create a unit vector along the W-axis.
Basic type for a vector of 4 int components.
GfVec4i GfCompMult(GfVec4i const &v1, GfVec4i const &v2)
Returns component-wise multiplication of vectors v1 and v2.
constexpr GfVec4i(int value)
Initialize all elements to a single value.
friend size_t hash_value(GfVec4i const &vec)
Hash.
constexpr GfVec4i(Scl const *p)
Construct with pointer to values.
GfVec4i & Set(int const *a)
Set all elements with a pointer to data.
int GetLengthSq() const
Squared length.
static GfVec4i YAxis()
Create a unit vector along the Y-axis.
GfVec4i & operator+=(GfVec4i const &other)
Addition.
GfVec4i operator-() const
Create a vec with negated elements.
GfVec4i GfCompDiv(GfVec4i const &v1, GfVec4i const &v2)
Returns component-wise quotient of vectors v1 and v2.
Basic type for a vector of 4 double components.
Low-level utilities for informing users of various internal and external diagnostic conditions.
constexpr GfVec4i(int s0, int s1, int s2, int s3)
Initialize all elements with explicit arguments.
A metafunction with a static const bool member 'value' that is true for GfVec types,...
Basic type for a vector of 4 GfHalf components.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
static GfVec4i ZAxis()
Create a unit vector along the Z-axis.
GfVec4i()=default
Default constructor does no initialization.
GfVec4i & operator-=(GfVec4i const &other)
Subtraction.
static GfVec4i XAxis()
Create a unit vector along the X-axis.
static GfVec4i Axis(size_t i)
Create a unit vector along the i-th axis, zero-based.
int ScalarType
Scalar element type and dimension.
Basic type for a vector of 4 float components.
int GfDot(GfVec4i const &v1, GfVec4i const &v2)
Returns the dot (inner) product of two vectors.
int const * data() const
Direct data access.
GfVec4i & operator/=(int s)
Division by scalar.
GfVec4i & operator *=(double s)
Multiplication by scalar.
bool operator==(GfVec4i const &other) const
Equality comparison.
GF_API std::ostream & operator<<(std::ostream &, GfVec4i const &)
Output a GfVec4i.
int const & operator[](size_t i) const
Indexing.
Defines useful mathematical limits.
GfVec4i GetComplement(GfVec4i const &b) const
Returns the orthogonal complement of this->GetProjection(b).
GfVec4i & Set(int s0, int s1, int s2, int s3)
Set all elements with passed arguments.
GfVec4i GetProjection(GfVec4i const &v) const
Returns the projection of this onto v.