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" 40 #include <boost/functional/hash.hpp> 46 PXR_NAMESPACE_OPEN_SCOPE
66 static const size_t dimension = 4;
73 : _data{ value, value, value, value }
78 constexpr
GfVec4i(
int s0,
int s1,
int s2,
int s3)
79 : _data{ s0, s1, s2, s3 }
86 : _data{ p[0], p[1], p[2], p[3] }
135 return Set(a[0], a[1], a[2], a[3]);
139 int const *
data()
const {
return _data; }
140 int *
data() {
return _data; }
141 int const *GetArray()
const {
return data(); }
145 int &
operator[](
size_t i) {
return _data[i]; }
150 boost::hash_combine(h, vec[0]);
151 boost::hash_combine(h, vec[1]);
152 boost::hash_combine(h, vec[2]);
153 boost::hash_combine(h, vec[3]);
159 return _data[0] == other[0] &&
160 _data[1] == other[1] &&
161 _data[2] == other[2] &&
162 _data[3] == other[3];
164 bool operator!=(
GfVec4i const &other)
const {
165 return !(*
this == other);
181 return GfVec4i(-_data[0], -_data[1], -_data[2], -_data[3]);
186 _data[0] += other[0];
187 _data[1] += other[1];
188 _data[2] += other[2];
189 _data[3] += other[3];
198 _data[0] -= other[0];
199 _data[1] -= other[1];
200 _data[2] -= other[2];
201 _data[3] -= other[3];
216 GfVec4i operator*(
double s)
const {
231 GfVec4i operator/(
int s)
const {
237 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2] + _data[3] * v[3];
245 return v * (*
this * v);
259 return *
this * *
this;
301 PXR_NAMESPACE_CLOSE_SCOPE
303 #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 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.