28 #ifndef PXR_BASE_GF_VEC2I_H 29 #define PXR_BASE_GF_VEC2I_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 = 2;
72 : _data{ value, value }
120 return Set(a[0], a[1]);
124 int const *
data()
const {
return _data; }
125 int *
data() {
return _data; }
126 int const *GetArray()
const {
return data(); }
130 int &
operator[](
size_t i) {
return _data[i]; }
139 return _data[0] == other[0] &&
140 _data[1] == other[1];
142 bool operator!=(
GfVec2i const &other)
const {
143 return !(*
this == other);
159 return GfVec2i(-_data[0], -_data[1]);
164 _data[0] += other[0];
165 _data[1] += other[1];
174 _data[0] -= other[0];
175 _data[1] -= other[1];
188 GfVec2i operator*(
double s)
const {
201 GfVec2i operator/(
int s)
const {
207 return _data[0] * v[0] + _data[1] * v[1];
215 return v * (*
this * v);
229 return *
this * *
this;
267 PXR_NAMESPACE_CLOSE_SCOPE
269 #endif // PXR_BASE_GF_VEC2I_H GfVec2i & operator *=(double s)
Multiplication by scalar.
Basic type for a vector of 2 int components.
GfVec2i & operator+=(GfVec2i const &other)
Addition.
static GfVec2i Axis(size_t i)
Create a unit vector along the i-th axis, zero-based.
GfVec2i & Set(int s0, int s1)
Set all elements with passed arguments.
bool operator==(GfVec2i const &other) const
Equality comparison.
Low-level utilities for informing users of various internal and external diagnostic conditions.
A metafunction with a static const bool member 'value' that is true for GfVec types,...
int GetLengthSq() const
Squared length.
constexpr GfVec2i(Scl const *p)
Construct with pointer to values.
GfVec2i operator-() const
Create a vec with negated elements.
Basic type for a vector of 2 double components.
constexpr GfVec2i(int s0, int s1)
Initialize all elements with explicit arguments.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Basic type for a vector of 2 GfHalf components.
static GfVec2i XAxis()
Create a unit vector along the X-axis.
int GfDot(GfVec2i const &v1, GfVec2i const &v2)
Returns the dot (inner) product of two vectors.
GfVec2i GfCompMult(GfVec2i const &v1, GfVec2i const &v2)
Returns component-wise multiplication of vectors v1 and v2.
GfVec2i & operator-=(GfVec2i const &other)
Subtraction.
friend size_t hash_value(GfVec2i const &vec)
Hash.
int const * data() const
Direct data access.
static GfVec2i YAxis()
Create a unit vector along the Y-axis.
int const & operator[](size_t i) const
Indexing.
constexpr GfVec2i(int value)
Initialize all elements to a single value.
int ScalarType
Scalar element type and dimension.
GfVec2i GfCompDiv(GfVec2i const &v1, GfVec2i const &v2)
Returns component-wise quotient of vectors v1 and v2.
Basic type for a vector of 2 float components.
GfVec2i & Set(int const *a)
Set all elements with a pointer to data.
Defines useful mathematical limits.
GfVec2i GetComplement(GfVec2i const &b) const
Returns the orthogonal complement of this->GetProjection(b).
GfVec2i()=default
Default constructor does no initialization.
GfVec2i GetProjection(GfVec2i const &v) const
Returns the projection of this onto v.
GF_API std::ostream & operator<<(std::ostream &, GfVec2i const &)
Output a GfVec2i.
GfVec2i & operator/=(int s)
Division by scalar.