28 #ifndef PXR_BASE_GF_VEC3F_H
29 #define PXR_BASE_GF_VEC3F_H
41 #include <hboost/functional/hash.hpp>
88 : _data{ p[0], p[1], p[2] }
139 return Set(a[0], a[1], a[2]);
143 float const *
data()
const {
return _data; }
144 float *
data() {
return _data; }
154 hboost::hash_combine(h, vec[0]);
155 hboost::hash_combine(h, vec[1]);
156 hboost::hash_combine(h, vec[2]);
162 return _data[0] == other[0] &&
163 _data[1] == other[1] &&
164 _data[2] == other[2];
167 return !(*
this == other);
183 return GfVec3f(-_data[0], -_data[1], -_data[2]);
188 _data[0] += other[0];
189 _data[1] += other[1];
190 _data[2] += other[2];
199 _data[0] -= other[0];
200 _data[1] -= other[1];
201 _data[2] -= other[2];
228 return *
this *= (1.0 /
s);
231 return *
this * (1.0 /
s);
236 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2];
244 return v * (*
this *
v);
258 return *
this * *
this;
279 *
this /= (length > eps) ? length : eps;
430 return delta.
GetLengthSq() <= tolerance * tolerance;
449 v1[1] * v2[2] - v1[2] * v2[1],
450 v1[2] * v2[0] - v1[0] * v2[2],
451 v1[0] * v2[1] - v1[1] * v2[0]);
470 #endif // PXR_BASE_GF_VEC3F_H
GLboolean GLboolean GLboolean b
friend GfVec3f operator+(GfVec3f const &l, GfVec3f const &r)
GfVec3f & operator-=(GfVec3f const &other)
Subtraction.
*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
bool operator==(GfVec3f const &other) const
Equality comparison.
GfVec3f GetProjection(GfVec3f const &v) const
static GfVec3f Axis(size_t i)
float const * data() const
Direct data access.
static const size_t dimension
GfVec3f GfGetNormalized(GfVec3f const &v, float eps=GF_MIN_VECTOR_LENGTH)
constexpr GfVec3f(float s0, float s1, float s2)
Initialize all elements with explicit arguments.
bool operator!=(GfVec3f const &other) const
vfloat4 sqrt(const vfloat4 &a)
friend size_t hash_value(GfVec3f const &vec)
Hash.
GfVec3f GfGetComplement(GfVec3f const &a, GfVec3f const &b)
static GfVec3f YAxis()
Create a unit vector along the Y-axis.
static GF_API bool OrthogonalizeBasis(GfVec3f *tx, GfVec3f *ty, GfVec3f *tz, const bool normalize, double eps=GF_MIN_ORTHO_TOLERANCE)
float GetLengthSq() const
Squared length.
GfVec3f operator^(GfVec3f const &v1, GfVec3f const &v2)
GfVec3f operator*(double s) const
constexpr GfVec3f(Scl const *p)
Construct with pointer to values.
GF_API void BuildOrthonormalFrame(GfVec3f *v1, GfVec3f *v2, float eps=GF_MIN_VECTOR_LENGTH) const
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
float GetLength() const
Length.
float & operator[](size_t i)
static GfVec3f ZAxis()
Create a unit vector along the Z-axis.
GfVec3f()=default
Default constructor does no initialization.
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
friend GfVec3f operator*(double s, GfVec3f const &v)
bool GfIsClose(GfVec3f const &v1, GfVec3f const &v2, double tolerance)
float operator*(GfVec3f const &v) const
See GfDot().
GfVec3f GfGetProjection(GfVec3f const &a, GfVec3f const &b)
GLint GLenum GLboolean normalized
GLfloat GLfloat GLfloat v2
GF_API bool GfOrthogonalizeBasis(GfVec3f *tx, GfVec3f *ty, GfVec3f *tz, bool normalize, double eps=GF_MIN_ORTHO_TOLERANCE)
GfVec3f & operator/=(double s)
Division by scalar.
float const & operator[](size_t i) const
Indexing.
GLboolean GLboolean GLboolean GLboolean a
GF_API std::ostream & operator<<(std::ostream &, GfVec3f const &)
float const * GetArray() const
GfVec3f & Set(float s0, float s1, float s2)
Set all elements with passed arguments.
float ScalarType
Scalar element type and dimension.
static GfVec3f XAxis()
Create a unit vector along the X-axis.
GF_API GfVec3f GfSlerp(double alpha, GfVec3f const &v0, GfVec3f const &v1)
Spherical linear interpolation in three dimensions.
float GfGetLength(GfVec3f const &v)
Returns the geometric length of v.
GfVec3f GetComplement(GfVec3f const &b) const
GfVec3f GfCompMult(GfVec3f const &v1, GfVec3f const &v2)
Returns component-wise multiplication of vectors v1 and v2.
GLuint GLsizei GLsizei * length
GLfloat GLfloat GLfloat GLfloat h
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
GF_API void GfBuildOrthonormalFrame(GfVec3f const &v0, GfVec3f *v1, GfVec3f *v2, float eps=GF_MIN_VECTOR_LENGTH)
GfVec3f GetNormalized(float eps=GF_MIN_VECTOR_LENGTH) const
float GfDot(GfVec3f const &v1, GfVec3f const &v2)
Returns the dot (inner) product of two vectors.
friend GfVec3f operator-(GfVec3f const &l, GfVec3f const &r)
GfVec3f operator/(double s) const
float GfNormalize(GfVec3f *v, float eps=GF_MIN_VECTOR_LENGTH)
GfVec3f GfCompDiv(GfVec3f const &v1, GfVec3f const &v2)
Returns component-wise quotient of vectors v1 and v2.
#define PXR_NAMESPACE_CLOSE_SCOPE
GLsizei const GLfloat * value
float Normalize(float eps=GF_MIN_VECTOR_LENGTH)
GfVec3f operator-() const
Create a vec with negated elements.
GfVec3f GfCross(GfVec3f const &v1, GfVec3f const &v2)
Returns the cross product of v1 and v2.
GfVec3f & operator+=(GfVec3f const &other)
Addition.
GLfloat GLfloat GLfloat alpha
#define GF_MIN_VECTOR_LENGTH
constexpr GfVec3f(float value)
Initialize all elements to a single value.
#define GF_MIN_ORTHO_TOLERANCE
constexpr T normalize(UT_FixedVector< T, D > &a) noexcept
GfVec3f & Set(float const *a)
Set all elements with a pointer to data.
GfVec3f & operator*=(double s)
Multiplication by scalar.