28 #ifndef PXR_BASE_GF_VEC3F_H
29 #define PXR_BASE_GF_VEC3F_H
79 constexpr
GfVec3f(
float s0,
float s1,
float s2)
87 : _data{ p[0], p[1], p[2] }
138 return Set(a[0], a[1], a[2]);
142 float const *
data()
const {
return _data; }
143 float *
data() {
return _data; }
157 return _data[0] == other[0] &&
158 _data[1] == other[1] &&
159 _data[2] == other[2];
162 return !(*
this == other);
178 return GfVec3f(-_data[0], -_data[1], -_data[2]);
183 _data[0] += other[0];
184 _data[1] += other[1];
185 _data[2] += other[2];
194 _data[0] -= other[0];
195 _data[1] -= other[1];
196 _data[2] -= other[2];
223 return *
this *= (1.0 /
s);
226 return *
this * (1.0 /
s);
231 return _data[0] * v[0] + _data[1] * v[1] + _data[2] * v[2];
239 return v * (*
this *
v);
253 return *
this * *
this;
273 *
this /= (length > eps) ? length : eps;
424 return delta.
GetLengthSq() <= tolerance * tolerance;
443 v1[1] * v2[2] - v1[2] * v2[1],
444 v1[2] * v2[0] - v1[0] * v2[2],
445 v1[0] * v2[1] - v1[1] * v2[0]);
464 #endif // PXR_BASE_GF_VEC3F_H
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.
GLsizei const GLfloat * value
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
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)
GLboolean GLboolean GLboolean GLboolean a
GLuint GLsizei GLsizei * length
GfVec3f operator*(double s) const
**But if you need a result
GLfloat GLfloat GLfloat v2
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
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.
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)
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.
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.
GLfloat GLfloat GLfloat alpha
static GfVec3f XAxis()
Create a unit vector along the X-axis.
GLint GLenum GLboolean normalized
GLboolean GLboolean GLboolean b
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.
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
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
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.
#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.