28 #ifndef PXR_BASE_GF_VEC4F_H
29 #define PXR_BASE_GF_VEC4F_H
79 constexpr
GfVec4f(
float s0,
float s1,
float s2,
float s3)
80 : _data{ s0, s1, s2, s3 }
87 : _data{ p[0], p[1], p[2], p[3] }
145 return Set(a[0], a[1], a[2], a[3]);
149 float const *
data()
const {
return _data; }
150 float *
data() {
return _data; }
164 return _data[0] == other[0] &&
165 _data[1] == other[1] &&
166 _data[2] == other[2] &&
167 _data[3] == other[3];
170 return !(*
this == other);
186 return GfVec4f(-_data[0], -_data[1], -_data[2], -_data[3]);
191 _data[0] += other[0];
192 _data[1] += other[1];
193 _data[2] += other[2];
194 _data[3] += other[3];
203 _data[0] -= other[0];
204 _data[1] -= other[1];
205 _data[2] -= other[2];
206 _data[3] -= other[3];
234 return *
this *= (1.0 /
s);
237 return *
this * (1.0 /
s);
242 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2] + _data[3] * v[3];
250 return v * (*
this *
v);
264 return *
this * *
this;
284 *
this /= (length > eps) ? length : eps;
417 return delta.
GetLengthSq() <= tolerance * tolerance;
424 #endif // PXR_BASE_GF_VEC4F_H
GfVec4f & operator*=(double s)
Multiplication by scalar.
GfVec4f & operator/=(double s)
Division by scalar.
friend GfVec4f operator-(GfVec4f const &l, GfVec4f const &r)
float Normalize(float eps=GF_MIN_VECTOR_LENGTH)
static GfVec4f XAxis()
Create a unit vector along the X-axis.
*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
GfVec4f GetProjection(GfVec4f const &v) const
GfVec4f GetComplement(GfVec4f const &b) const
GLsizei const GLfloat * value
GfVec4f & operator+=(GfVec4f const &other)
Addition.
GLboolean GLboolean GLboolean GLboolean a
GLuint GLsizei GLsizei * length
float ScalarType
Scalar element type and dimension.
**But if you need a result
GLfloat GLfloat GLfloat v2
static GfVec4f WAxis()
Create a unit vector along the W-axis.
friend GfVec4f operator+(GfVec4f const &l, GfVec4f const &r)
GfVec4f GfGetNormalized(GfVec4f const &v, float eps=GF_MIN_VECTOR_LENGTH)
GF_API std::ostream & operator<<(std::ostream &, GfVec4f const &)
float GfNormalize(GfVec4f *v, float eps=GF_MIN_VECTOR_LENGTH)
GfVec4f()=default
Default constructor does no initialization.
float GetLengthSq() const
Squared length.
static GfVec4f YAxis()
Create a unit vector along the Y-axis.
float const * GetArray() const
GfVec4f operator-() const
Create a vec with negated elements.
static GfVec4f ZAxis()
Create a unit vector along the Z-axis.
constexpr GfVec4f(float value)
Initialize all elements to a single value.
float GfGetLength(GfVec4f const &v)
Returns the geometric length of v.
float GetLength() const
Length.
GLint GLenum GLboolean normalized
GLboolean GLboolean GLboolean b
GfVec4f operator/(double s) const
constexpr GfVec4f(Scl const *p)
Construct with pointer to values.
GfVec4f & Set(float s0, float s1, float s2, float s3)
Set all elements with passed arguments.
float operator*(GfVec4f const &v) const
See GfDot().
bool operator!=(GfVec4f const &other) const
static size_t Combine(Args &&...args)
Produce a hash code by combining the hash codes of several objects.
GfVec4f GetNormalized(float eps=GF_MIN_VECTOR_LENGTH) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
float const & operator[](size_t i) const
Indexing.
bool GfIsClose(GfVec4f const &v1, GfVec4f const &v2, double tolerance)
GfVec4f GfGetProjection(GfVec4f const &a, GfVec4f const &b)
float const * data() const
Direct data access.
GfVec4f & Set(float const *a)
Set all elements with a pointer to data.
float GfDot(GfVec4f const &v1, GfVec4f const &v2)
Returns the dot (inner) product of two vectors.
#define PXR_NAMESPACE_CLOSE_SCOPE
static GfVec4f Axis(size_t i)
friend size_t hash_value(GfVec4f const &vec)
Hash.
GfVec4f GfGetComplement(GfVec4f const &a, GfVec4f const &b)
GfVec4f operator*(double s) const
constexpr GfVec4f(float s0, float s1, float s2, float s3)
Initialize all elements with explicit arguments.
GfVec4f GfCompDiv(GfVec4f const &v1, GfVec4f const &v2)
Returns component-wise quotient of vectors v1 and v2.
bool operator==(GfVec4f const &other) const
Equality comparison.
static const size_t dimension
float & operator[](size_t i)
GfVec4f GfCompMult(GfVec4f const &v1, GfVec4f const &v2)
Returns component-wise multiplication of vectors v1 and v2.
#define GF_MIN_VECTOR_LENGTH
friend GfVec4f operator*(double s, GfVec4f const &v)
GfVec4f & operator-=(GfVec4f const &other)
Subtraction.