11#ifndef PXR_BASE_GF_VEC4I_H
12#define PXR_BASE_GF_VEC4I_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 = 4;
55 : _data{ value, value, value, value }
60 constexpr GfVec4i(
int s0,
int s1,
int s2,
int s3)
61 : _data{ s0, s1, s2, s3 }
68 : _data{ p[0], p[1], p[2], p[3] }
117 return Set(a[0], a[1], a[2], a[3]);
121 int const *
data()
const {
return _data; }
122 int *
data() {
return _data; }
123 int const *GetArray()
const {
return data(); }
127 int &
operator[](
size_t i) {
return _data[i]; }
136 return _data[0] == other[0] &&
137 _data[1] == other[1] &&
138 _data[2] == other[2] &&
139 _data[3] == other[3];
141 bool operator!=(
GfVec4i const &other)
const {
142 return !(*
this == other);
158 return GfVec4i(-_data[0], -_data[1], -_data[2], -_data[3]);
163 _data[0] += other[0];
164 _data[1] += other[1];
165 _data[2] += other[2];
166 _data[3] += other[3];
175 _data[0] -= other[0];
176 _data[1] -= other[1];
177 _data[2] -= other[2];
178 _data[3] -= other[3];
193 GfVec4i operator*(
double s)
const {
208 GfVec4i operator/(
int s)
const {
214 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2] + _data[3] * v[3];
222 return v * (*
this * v);
236 return *
this * *
this;
278PXR_NAMESPACE_CLOSE_SCOPE
Low-level utilities for informing users of various internal and external diagnostic conditions.
Basic type for a vector of 4 double components.
Basic type for a vector of 4 float components.
Basic type for a vector of 4 GfHalf components.
Basic type for a vector of 4 int components.
static GfVec4i ZAxis()
Create a unit vector along the Z-axis.
constexpr GfVec4i(int s0, int s1, int s2, int s3)
Initialize all elements with explicit arguments.
constexpr GfVec4i(Scl const *p)
Construct with pointer to values.
static GfVec4i Axis(size_t i)
Create a unit vector along the i-th axis, zero-based.
GfVec4i & operator-=(GfVec4i const &other)
Subtraction.
friend size_t hash_value(GfVec4i const &vec)
Hash.
static GfVec4i XAxis()
Create a unit vector along the X-axis.
GfVec4i operator-() const
Create a vec with negated elements.
GfVec4i()=default
Default constructor does no initialization.
static GfVec4i YAxis()
Create a unit vector along the Y-axis.
GfVec4i & operator+=(GfVec4i const &other)
Addition.
bool operator==(GfVec4i const &other) const
Equality comparison.
int operator*(GfVec4i const &v) const
See GfDot().
GfVec4i GetProjection(GfVec4i const &v) const
Returns the projection of this onto v.
int const * data() const
Direct data access.
GF_API bool operator==(class GfVec4f const &other) const
Equality comparison.
int const & operator[](size_t i) const
Indexing.
GF_API bool operator==(class GfVec4h const &other) const
Equality comparison.
GfVec4i & operator*=(double s)
Multiplication by scalar.
static GfVec4i WAxis()
Create a unit vector along the W-axis.
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.
GF_API bool operator==(class GfVec4d const &other) const
Equality comparison.
GfVec4i & Set(int const *a)
Set all elements with a pointer to data.
int ScalarType
Scalar element type and dimension.
int GetLengthSq() const
Squared length.
constexpr GfVec4i(int value)
Initialize all elements to a single value.
GfVec4i & operator/=(int s)
Division by scalar.
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,...
GfVec4i GfCompMult(GfVec4i const &v1, GfVec4i const &v2)
Returns component-wise multiplication of vectors v1 and v2.
int GfDot(GfVec4i const &v1, GfVec4i const &v2)
Returns the dot (inner) product of two vectors.
GfVec4i GfCompDiv(GfVec4i const &v1, GfVec4i const &v2)
Returns component-wise quotient of vectors v1 and v2.