28 #ifndef PXR_BASE_GF_VEC2D_H
29 #define PXR_BASE_GF_VEC2D_H
74 : _data{
value, value }
131 return Set(a[0], a[1]);
135 double const *
data()
const {
return _data; }
136 double *
data() {
return _data; }
140 double const &
operator[](
size_t i)
const {
return _data[i]; }
150 return _data[0] == other[0] &&
151 _data[1] == other[1];
154 return !(*
this == other);
170 return GfVec2d(-_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_VEC2D_H
GfVec2d operator-() const
Create a vec with negated elements.
double const * data() const
Direct data access.
friend GfVec2d operator*(double s, GfVec2d const &v)
double GfDot(GfVec2d const &v1, GfVec2d const &v2)
Returns the dot (inner) product of two vectors.
GfVec2d GfGetProjection(GfVec2d const &a, GfVec2d const &b)
*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
double Normalize(double eps=GF_MIN_VECTOR_LENGTH)
GLsizei const GLfloat * value
GfVec2d operator*(double s) const
friend GfVec2d operator-(GfVec2d const &l, GfVec2d const &r)
GLboolean GLboolean GLboolean GLboolean a
GF_API std::ostream & operator<<(std::ostream &, GfVec2d const &)
GLuint GLsizei GLsizei * length
bool operator!=(GfVec2d const &other) const
static GfVec2d XAxis()
Create a unit vector along the X-axis.
**But if you need a result
GLfloat GLfloat GLfloat v2
double GetLength() const
Length.
bool GfIsClose(GfVec2d const &v1, GfVec2d const &v2, double tolerance)
static const size_t dimension
GfVec2d operator/(double s) const
double & operator[](size_t i)
GfVec2d GfGetNormalized(GfVec2d const &v, double eps=GF_MIN_VECTOR_LENGTH)
constexpr GfVec2d(Scl const *p)
Construct with pointer to values.
double const * GetArray() const
constexpr GfVec2d(double s0, double s1)
Initialize all elements with explicit arguments.
friend GfVec2d operator+(GfVec2d const &l, GfVec2d const &r)
GfVec2d GfCompMult(GfVec2d const &v1, GfVec2d const &v2)
Returns component-wise multiplication of vectors v1 and v2.
GfVec2d & operator*=(double s)
Multiplication by scalar.
double ScalarType
Scalar element type and dimension.
constexpr GfVec2d(double value)
Initialize all elements to a single value.
double GfNormalize(GfVec2d *v, double eps=GF_MIN_VECTOR_LENGTH)
GLint GLenum GLboolean normalized
GLboolean GLboolean GLboolean b
GfVec2d & operator/=(double s)
Division by scalar.
GfVec2d & operator+=(GfVec2d const &other)
Addition.
double GetLengthSq() const
Squared length.
GfVec2d GetComplement(GfVec2d const &b) const
static GfVec2d YAxis()
Create a unit vector along the Y-axis.
double operator*(GfVec2d const &v) const
See GfDot().
friend size_t hash_value(GfVec2d const &vec)
Hash.
static size_t Combine(Args &&...args)
Produce a hash code by combining the hash codes of several objects.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
bool operator==(GfVec2d const &other) const
Equality comparison.
static GfVec2d Axis(size_t i)
GfVec2d()=default
Default constructor does no initialization.
GfVec2d & Set(double s0, double s1)
Set all elements with passed arguments.
#define PXR_NAMESPACE_CLOSE_SCOPE
GfVec2d GfCompDiv(GfVec2d const &v1, GfVec2d const &v2)
Returns component-wise quotient of vectors v1 and v2.
double GfGetLength(GfVec2d const &v)
Returns the geometric length of v.
GfVec2d & Set(double const *a)
Set all elements with a pointer to data.
GfVec2d GfGetComplement(GfVec2d const &a, GfVec2d const &b)
double const & operator[](size_t i) const
Indexing.
GfVec2d GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
GfVec2d GetProjection(GfVec2d const &v) const
#define GF_MIN_VECTOR_LENGTH
GfVec2d & operator-=(GfVec2d const &other)
Subtraction.