28 #ifndef PXR_BASE_GF_VEC4D_H
29 #define PXR_BASE_GF_VEC4D_H
41 #include <hboost/functional/hash.hpp>
81 : _data{
s0,
s1, s2, s3 }
88 : _data{ p[0], p[1], p[2], p[3] }
146 return Set(a[0], a[1], a[2], a[3]);
150 double const *
data()
const {
return _data; }
151 double *
data() {
return _data; }
155 double const &
operator[](
size_t i)
const {
return _data[i]; }
161 hboost::hash_combine(h, vec[0]);
162 hboost::hash_combine(h, vec[1]);
163 hboost::hash_combine(h, vec[2]);
164 hboost::hash_combine(h, vec[3]);
170 return _data[0] == other[0] &&
171 _data[1] == other[1] &&
172 _data[2] == other[2] &&
173 _data[3] == other[3];
176 return !(*
this == other);
192 return GfVec4d(-_data[0], -_data[1], -_data[2], -_data[3]);
197 _data[0] += other[0];
198 _data[1] += other[1];
199 _data[2] += other[2];
200 _data[3] += other[3];
209 _data[0] -= other[0];
210 _data[1] -= other[1];
211 _data[2] -= other[2];
212 _data[3] -= other[3];
240 return *
this *= (1.0 /
s);
243 return *
this * (1.0 /
s);
248 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2] + _data[3] * v[3];
256 return v * (*
this *
v);
270 return *
this * *
this;
291 *
this /= (length > eps) ? length : eps;
424 return delta.
GetLengthSq() <= tolerance * tolerance;
431 #endif // PXR_BASE_GF_VEC4D_H
GLboolean GLboolean GLboolean b
constexpr GfVec4d(double value)
Initialize all elements to a single value.
*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 const & operator[](size_t i) const
Indexing.
double operator*(GfVec4d const &v) const
See GfDot().
static GfVec4d WAxis()
Create a unit vector along the W-axis.
vfloat4 sqrt(const vfloat4 &a)
GfVec4d()=default
Default constructor does no initialization.
GfVec4d operator*(double s) const
GfVec4d operator/(double s) const
GfVec4d GfGetComplement(GfVec4d const &a, GfVec4d const &b)
friend GfVec4d operator-(GfVec4d const &l, GfVec4d const &r)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GfVec4d GfCompDiv(GfVec4d const &v1, GfVec4d const &v2)
Returns component-wise quotient of vectors v1 and v2.
static GfVec4d ZAxis()
Create a unit vector along the Z-axis.
constexpr GfVec4d(double s0, double s1, double s2, double s3)
Initialize all elements with explicit arguments.
double & operator[](size_t i)
GfVec4d GfGetProjection(GfVec4d const &a, GfVec4d const &b)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
double GetLengthSq() const
Squared length.
double const * data() const
Direct data access.
bool operator==(GfVec4d const &other) const
Equality comparison.
double Normalize(double eps=GF_MIN_VECTOR_LENGTH)
static GfVec4d Axis(size_t i)
GLint GLenum GLboolean normalized
GLfloat GLfloat GLfloat v2
GLboolean GLboolean GLboolean GLboolean a
GfVec4d GfGetNormalized(GfVec4d const &v, double eps=GF_MIN_VECTOR_LENGTH)
double GfNormalize(GfVec4d *v, double eps=GF_MIN_VECTOR_LENGTH)
GfVec4d GetComplement(GfVec4d const &b) const
GfVec4d operator-() const
Create a vec with negated elements.
double GfGetLength(GfVec4d const &v)
Returns the geometric length of v.
bool operator!=(GfVec4d const &other) const
GfVec4d & operator+=(GfVec4d const &other)
Addition.
GLuint GLsizei GLsizei * length
double const * GetArray() const
GLfloat GLfloat GLfloat GLfloat h
static GfVec4d XAxis()
Create a unit vector along the X-axis.
GfVec4d GfCompMult(GfVec4d const &v1, GfVec4d const &v2)
Returns component-wise multiplication of vectors v1 and v2.
friend GfVec4d operator*(double s, GfVec4d const &v)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
double GfDot(GfVec4d const &v1, GfVec4d const &v2)
Returns the dot (inner) product of two vectors.
double ScalarType
Scalar element type and dimension.
static const size_t dimension
GfVec4d GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
double GetLength() const
Length.
friend GfVec4d operator+(GfVec4d const &l, GfVec4d const &r)
#define PXR_NAMESPACE_CLOSE_SCOPE
GLsizei const GLfloat * value
GfVec4d & operator-=(GfVec4d const &other)
Subtraction.
GfVec4d & Set(double const *a)
Set all elements with a pointer to data.
GfVec4d & Set(double s0, double s1, double s2, double s3)
Set all elements with passed arguments.
GF_API std::ostream & operator<<(std::ostream &, GfVec4d const &)
GfVec4d & operator*=(double s)
Multiplication by scalar.
constexpr GfVec4d(Scl const *p)
Construct with pointer to values.
GfVec4d GetProjection(GfVec4d const &v) const
static GfVec4d YAxis()
Create a unit vector along the Y-axis.
bool GfIsClose(GfVec4d const &v1, GfVec4d const &v2, double tolerance)
#define GF_MIN_VECTOR_LENGTH
friend size_t hash_value(GfVec4d const &vec)
Hash.
GfVec4d & operator/=(double s)
Division by scalar.