11#ifndef PXR_BASE_GF_VEC2I_H
12#define PXR_BASE_GF_VEC2I_H
19#include "pxr/base/gf/api.h"
21#include "pxr/base/gf/traits.h"
28PXR_NAMESPACE_OPEN_SCOPE
48 static const size_t dimension = 2;
55 : _data{ value, value }
103 return Set(a[0], a[1]);
107 int const *
data()
const {
return _data; }
108 int *
data() {
return _data; }
109 int const *GetArray()
const {
return data(); }
113 int &
operator[](
size_t i) {
return _data[i]; }
122 return _data[0] == other[0] &&
123 _data[1] == other[1];
125 bool operator!=(
GfVec2i const &other)
const {
126 return !(*
this == other);
142 return GfVec2i(-_data[0], -_data[1]);
147 _data[0] += other[0];
148 _data[1] += other[1];
157 _data[0] -= other[0];
158 _data[1] -= other[1];
171 GfVec2i operator*(
double s)
const {
184 GfVec2i operator/(
int s)
const {
190 return _data[0] * v[0] + _data[1] * v[1];
198 return v * (*
this * v);
212 return *
this * *
this;
250PXR_NAMESPACE_CLOSE_SCOPE
Low-level utilities for informing users of various internal and external diagnostic conditions.
Basic type for a vector of 2 double components.
Basic type for a vector of 2 float components.
Basic type for a vector of 2 GfHalf components.
Basic type for a vector of 2 int components.
static GfVec2i XAxis()
Create a unit vector along the X-axis.
bool operator==(GfVec2i const &other) const
Equality comparison.
GfVec2i GetComplement(GfVec2i const &b) const
Returns the orthogonal complement of this->GetProjection(b).
GfVec2i & operator-=(GfVec2i const &other)
Subtraction.
int operator*(GfVec2i const &v) const
See GfDot().
GF_API bool operator==(class GfVec2h const &other) const
Equality comparison.
GfVec2i operator-() const
Create a vec with negated elements.
GfVec2i & Set(int s0, int s1)
Set all elements with passed arguments.
GfVec2i & operator*=(double s)
Multiplication by scalar.
static GfVec2i YAxis()
Create a unit vector along the Y-axis.
static GfVec2i Axis(size_t i)
Create a unit vector along the i-th axis, zero-based.
friend size_t hash_value(GfVec2i const &vec)
Hash.
constexpr GfVec2i(int value)
Initialize all elements to a single value.
GfVec2i & operator/=(int s)
Division by scalar.
constexpr GfVec2i(int s0, int s1)
Initialize all elements with explicit arguments.
int const * data() const
Direct data access.
constexpr GfVec2i(Scl const *p)
Construct with pointer to values.
GF_API bool operator==(class GfVec2f const &other) const
Equality comparison.
int const & operator[](size_t i) const
Indexing.
GfVec2i & operator+=(GfVec2i const &other)
Addition.
GF_API bool operator==(class GfVec2d const &other) const
Equality comparison.
GfVec2i()=default
Default constructor does no initialization.
GfVec2i GetProjection(GfVec2i const &v) const
Returns the projection of this onto v.
GfVec2i & Set(int const *a)
Set all elements with a pointer to data.
int ScalarType
Scalar element type and dimension.
int GetLengthSq() const
Squared length.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Defines useful mathematical limits.
A metafunction with a static const bool member 'value' that is true for GfVec types,...
GfVec2i GfCompMult(GfVec2i const &v1, GfVec2i const &v2)
Returns component-wise multiplication of vectors v1 and v2.
GfVec2i GfCompDiv(GfVec2i const &v1, GfVec2i const &v2)
Returns component-wise quotient of vectors v1 and v2.
int GfDot(GfVec2i const &v1, GfVec2i const &v2)
Returns the dot (inner) product of two vectors.