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"
40 #include <boost/functional/hash.hpp>
46 PXR_NAMESPACE_OPEN_SCOPE
66 static const size_t dimension = 2;
73 : _data{ value, value }
121 return Set(a[0], a[1]);
125 int const *
data()
const {
return _data; }
126 int *
data() {
return _data; }
127 int const *GetArray()
const {
return data(); }
131 int &
operator[](
size_t i) {
return _data[i]; }
136 boost::hash_combine(h, vec[0]);
137 boost::hash_combine(h, vec[1]);
143 return _data[0] == other[0] &&
144 _data[1] == other[1];
146 bool operator!=(
GfVec2i const &other)
const {
147 return !(*
this == other);
163 return GfVec2i(-_data[0], -_data[1]);
168 _data[0] += other[0];
169 _data[1] += other[1];
178 _data[0] -= other[0];
179 _data[1] -= other[1];
192 GfVec2i operator*(
double s)
const {
205 GfVec2i operator/(
int s)
const {
211 return _data[0] * v[0] + _data[1] * v[1];
219 return v * (*
this * v);
233 return *
this * *
this;
271 PXR_NAMESPACE_CLOSE_SCOPE
273 #endif // PXR_BASE_GF_VEC2I_H
int operator*(GfVec2i const &v) const
See GfDot().
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.
decltype(std::declval< Left >()*std::declval< Right >()) GfCompMult(Left left, Right right)
Returns component-wise multiplication of vectors.
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, like GfVec2i, GfVec4d, etc and false for all other types.
constexpr GfVec2i(Scl const *p)
Construct with pointer to values.
bool operator==(GfVec2i const &other) const
Equality comparison.
Basic type for a vector of 2 double components.
constexpr GfVec2i(int s0, int s1)
Initialize all elements with explicit arguments.
GfVec2i GetProjection(GfVec2i const &v) const
Returns the projection of this onto v.
Basic type for a vector of 2 GfHalf components.
static GfVec2i XAxis()
Create a unit vector along the X-axis.
decltype(std::declval< Left >()/std::declval< Right >()) GfCompDiv(Left left, Right right)
Returns component-wise quotient of vectors.
decltype(std::declval< Left >()*std::declval< Right >()) GfDot(Left left, Right right)
Returns the dot (inner) product of two vectors.
GfVec2i & operator-=(GfVec2i const &other)
Subtraction.
int const * data() const
Direct data access.
friend size_t hash_value(GfVec2i const &vec)
Hash.
GfVec2i GetComplement(GfVec2i const &b) const
Returns the orthogonal complement of this->GetProjection(b).
static GfVec2i YAxis()
Create a unit vector along the Y-axis.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
constexpr GfVec2i(int value)
Initialize all elements to a single value.
GfVec2i & operator*=(double s)
Multiplication by scalar.
int ScalarType
Scalar element type and dimension.
Basic type for a vector of 2 float components.
GfVec2i & Set(int const *a)
Set all elements with a pointer to data.
int GetLengthSq() const
Squared length.
Defines useful mathematical limits.
int const & operator[](size_t i) const
Indexing.
GfVec2i operator-() const
Create a vec with negated elements.
GfVec2i()=default
Default constructor does no initialization.
GfVec2i & operator/=(int s)
Division by scalar.