28 #ifndef PXR_BASE_GF_VEC4D_H
29 #define PXR_BASE_GF_VEC4D_H
79 constexpr
GfVec4d(
double s0,
double s1,
double s2,
double 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 double const *
data()
const {
return _data; }
150 double *
data() {
return _data; }
154 double const &
operator[](
size_t i)
const {
return _data[i]; }
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 GfVec4d(-_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_VEC4D_H
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().
GLsizei const GLfloat * value
static GfVec4d WAxis()
Create a unit vector along the W-axis.
GfVec4d()=default
Default constructor does no initialization.
GLboolean GLboolean GLboolean GLboolean a
GLuint GLsizei GLsizei * length
GfVec4d operator*(double s) const
GfVec4d operator/(double s) const
**But if you need a result
GLfloat GLfloat GLfloat v2
GfVec4d GfGetComplement(GfVec4d const &a, GfVec4d const &b)
friend GfVec4d operator-(GfVec4d const &l, GfVec4d const &r)
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)
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)
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.
GLint GLenum GLboolean normalized
GLboolean GLboolean GLboolean b
double GfGetLength(GfVec4d const &v)
Returns the geometric length of v.
bool operator!=(GfVec4d const &other) const
GfVec4d & operator+=(GfVec4d const &other)
Addition.
double const * GetArray() const
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.
static size_t Combine(Args &&...args)
Produce a hash code by combining the hash codes of several objects.
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
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.