28 #ifndef PXR_BASE_GF_VEC2F_H
29 #define PXR_BASE_GF_VEC2F_H
74 : _data{
value, value }
131 return Set(a[0], a[1]);
135 float const *
data()
const {
return _data; }
136 float *
data() {
return _data; }
150 return _data[0] == other[0] &&
151 _data[1] == other[1];
154 return !(*
this == other);
170 return GfVec2f(-_data[0], -_data[1]);
175 _data[0] += other[0];
176 _data[1] += other[1];
185 _data[0] -= other[0];
186 _data[1] -= other[1];
212 return *
this *= (1.0 /
s);
215 return *
this * (1.0 /
s);
220 return _data[0] * v[0] + _data[1] * v[1];
228 return v * (*
this *
v);
242 return *
this * *
this;
262 *
this /= (length > eps) ? length : eps;
385 return delta.
GetLengthSq() <= tolerance * tolerance;
392 #endif // PXR_BASE_GF_VEC2F_H
bool operator==(GfVec2f const &other) const
Equality comparison.
float GetLength() const
Length.
float const & operator[](size_t i) const
Indexing.
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
static GfVec2f YAxis()
Create a unit vector along the Y-axis.
GLsizei const GLfloat * value
GfVec2f & operator-=(GfVec2f const &other)
Subtraction.
float operator*(GfVec2f const &v) const
See GfDot().
GfVec2f GfGetComplement(GfVec2f const &a, GfVec2f const &b)
float const * GetArray() const
GLboolean GLboolean GLboolean GLboolean a
GLuint GLsizei GLsizei * length
float & operator[](size_t i)
GfVec2f GetComplement(GfVec2f const &b) const
bool GfIsClose(GfVec2f const &v1, GfVec2f const &v2, double tolerance)
float GfGetLength(GfVec2f const &v)
Returns the geometric length of v.
**But if you need a result
GLfloat GLfloat GLfloat v2
GfVec2f & Set(float const *a)
Set all elements with a pointer to data.
static const size_t dimension
GfVec2f GfCompDiv(GfVec2f const &v1, GfVec2f const &v2)
Returns component-wise quotient of vectors v1 and v2.
GfVec2f & operator*=(double s)
Multiplication by scalar.
float Normalize(float eps=GF_MIN_VECTOR_LENGTH)
GfVec2f GetProjection(GfVec2f const &v) const
GfVec2f operator-() const
Create a vec with negated elements.
float GetLengthSq() const
Squared length.
constexpr GfVec2f(Scl const *p)
Construct with pointer to values.
bool operator!=(GfVec2f const &other) const
friend size_t hash_value(GfVec2f const &vec)
Hash.
float const * data() const
Direct data access.
GfVec2f operator/(double s) const
constexpr GfVec2f(float value)
Initialize all elements to a single value.
GLint GLenum GLboolean normalized
float ScalarType
Scalar element type and dimension.
GLboolean GLboolean GLboolean b
GfVec2f GfGetProjection(GfVec2f const &a, GfVec2f const &b)
GfVec2f GfCompMult(GfVec2f const &v1, GfVec2f const &v2)
Returns component-wise multiplication of vectors v1 and v2.
GF_API std::ostream & operator<<(std::ostream &, GfVec2f const &)
constexpr GfVec2f(float s0, float 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.
static GfVec2f Axis(size_t i)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
GfVec2f()=default
Default constructor does no initialization.
GfVec2f & operator/=(double s)
Division by scalar.
friend GfVec2f operator+(GfVec2f const &l, GfVec2f const &r)
GfVec2f operator*(double s) const
friend GfVec2f operator-(GfVec2f const &l, GfVec2f const &r)
#define PXR_NAMESPACE_CLOSE_SCOPE
GfVec2f GetNormalized(float eps=GF_MIN_VECTOR_LENGTH) const
GfVec2f & Set(float s0, float s1)
Set all elements with passed arguments.
friend GfVec2f operator*(double s, GfVec2f const &v)
#define GF_MIN_VECTOR_LENGTH
float GfNormalize(GfVec2f *v, float eps=GF_MIN_VECTOR_LENGTH)
GfVec2f & operator+=(GfVec2f const &other)
Addition.
float GfDot(GfVec2f const &v1, GfVec2f const &v2)
Returns the dot (inner) product of two vectors.
static GfVec2f XAxis()
Create a unit vector along the X-axis.
GfVec2f GfGetNormalized(GfVec2f const &v, float eps=GF_MIN_VECTOR_LENGTH)