11#ifndef PXR_BASE_GF_VEC2I_H
12#define PXR_BASE_GF_VEC2I_H
18#include "pxr/base/gf/api.h"
20#include "pxr/base/gf/traits.h"
29PXR_NAMESPACE_OPEN_SCOPE
48 static const size_t dimension = 2;
118 return Set(a[0], a[1]);
126 int const *
data()
const {
return &x; }
127 int *
data() {
return &x; }
128 int const *GetArray()
const {
return data(); }
141 return x == other.x &&
144 bool operator!=(
GfVec2i const &other)
const {
145 return !(*
this == other);
190 GfVec2i operator*(
double s)
const {
203 GfVec2i operator/(
int s)
const {
209 return x * v.x + y * v.y;
217 return v * (*
this * v);
231 return *
this * *
this;
259 template <
class Vec = GfVec2i>
constexpr Vec xy()
const;
260 template <
class Vec = GfVec2i>
constexpr Vec yx()
const;
268PXR_NAMESPACE_CLOSE_SCOPE
271PXR_NAMESPACE_OPEN_SCOPE
278 static_assert(std::is_same<Vec, GfVec2i>::value);
286 static_assert(std::is_same<Vec, GfVec2i>::value);
316PXR_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.
int ScalarType
Scalar element type and dimension.
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
GfVec2i value-initializes to zero and performs no default initialization, like float or double.
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 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 &, GfVec2i const &)
Output a GfVec2i.
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.