28 #ifndef PXR_BASE_GF_VEC3D_H
29 #define PXR_BASE_GF_VEC3D_H
79 constexpr
GfVec3d(
double s0,
double s1,
double s2)
87 : _data{ p[0], p[1], p[2] }
138 return Set(a[0], a[1], a[2]);
142 double const *
data()
const {
return _data; }
143 double *
data() {
return _data; }
147 double const &
operator[](
size_t i)
const {
return _data[i]; }
157 return _data[0] == other[0] &&
158 _data[1] == other[1] &&
159 _data[2] == other[2];
162 return !(*
this == other);
178 return GfVec3d(-_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_VEC3D_H
GfVec3d operator/(double s) const
double & operator[](size_t i)
*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
GfVec3d operator^(GfVec3d const &v1, GfVec3d const &v2)
bool operator!=(GfVec3d const &other) const
double ScalarType
Scalar element type and dimension.
GLsizei const GLfloat * value
constexpr GfVec3d(double s0, double s1, double s2)
Initialize all elements with explicit arguments.
GLboolean GLboolean GLboolean GLboolean a
GLuint GLsizei GLsizei * length
bool GfIsClose(GfVec3d const &v1, GfVec3d const &v2, double tolerance)
static GfVec3d YAxis()
Create a unit vector along the Y-axis.
GF_API GfVec3d GfSlerp(double alpha, GfVec3d const &v0, GfVec3d const &v1)
Spherical linear interpolation in three dimensions.
**But if you need a result
constexpr GfVec3d(Scl const *p)
Construct with pointer to values.
GF_API std::ostream & operator<<(std::ostream &, GfVec3d const &)
GLfloat GLfloat GLfloat v2
GfVec3d GfCross(GfVec3d const &v1, GfVec3d const &v2)
Returns the cross product of v1 and v2.
double const * data() const
Direct data access.
static GfVec3d ZAxis()
Create a unit vector along the Z-axis.
double GetLengthSq() const
Squared length.
bool operator==(GfVec3d const &other) const
Equality comparison.
GfVec3d & operator-=(GfVec3d const &other)
Subtraction.
static GfVec3d XAxis()
Create a unit vector along the X-axis.
double GfGetLength(GfVec3d const &v)
Returns the geometric length of v.
GfVec3d GfCompMult(GfVec3d const &v1, GfVec3d const &v2)
Returns component-wise multiplication of vectors v1 and v2.
double GfDot(GfVec3d const &v1, GfVec3d const &v2)
Returns the dot (inner) product of two vectors.
GfVec3d & Set(double const *a)
Set all elements with a pointer to data.
double operator*(GfVec3d const &v) const
See GfDot().
GfVec3d GfCompDiv(GfVec3d const &v1, GfVec3d const &v2)
Returns component-wise quotient of vectors v1 and v2.
friend GfVec3d operator+(GfVec3d const &l, GfVec3d const &r)
GfVec3d GetProjection(GfVec3d const &v) const
GLfloat GLfloat GLfloat alpha
GfVec3d & operator/=(double s)
Division by scalar.
GLint GLenum GLboolean normalized
double const * GetArray() const
GLboolean GLboolean GLboolean b
static const size_t dimension
GfVec3d operator*(double s) const
GfVec3d & operator*=(double s)
Multiplication by scalar.
double GfNormalize(GfVec3d *v, double eps=GF_MIN_VECTOR_LENGTH)
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
friend GfVec3d operator*(double s, GfVec3d const &v)
static GfVec3d Axis(size_t i)
double const & operator[](size_t i) const
Indexing.
constexpr GfVec3d(double value)
Initialize all elements to a single value.
GfVec3d & Set(double s0, double s1, double s2)
Set all elements with passed arguments.
GF_API void BuildOrthonormalFrame(GfVec3d *v1, GfVec3d *v2, double eps=GF_MIN_VECTOR_LENGTH) const
#define PXR_NAMESPACE_CLOSE_SCOPE
GfVec3d GetComplement(GfVec3d const &b) const
friend GfVec3d operator-(GfVec3d const &l, GfVec3d const &r)
friend size_t hash_value(GfVec3d const &vec)
Hash.
GF_API bool GfOrthogonalizeBasis(GfVec3d *tx, GfVec3d *ty, GfVec3d *tz, bool normalize, double eps=GF_MIN_ORTHO_TOLERANCE)
static GF_API bool OrthogonalizeBasis(GfVec3d *tx, GfVec3d *ty, GfVec3d *tz, const bool normalize, double eps=GF_MIN_ORTHO_TOLERANCE)
GfVec3d GfGetComplement(GfVec3d const &a, GfVec3d const &b)
GfVec3d operator-() const
Create a vec with negated elements.
GfVec3d GfGetProjection(GfVec3d const &a, GfVec3d const &b)
GfVec3d GfGetNormalized(GfVec3d const &v, double eps=GF_MIN_VECTOR_LENGTH)
GF_API void GfBuildOrthonormalFrame(GfVec3d const &v0, GfVec3d *v1, GfVec3d *v2, double eps=GF_MIN_VECTOR_LENGTH)
GfVec3d & operator+=(GfVec3d const &other)
Addition.
double Normalize(double eps=GF_MIN_VECTOR_LENGTH)
#define GF_MIN_VECTOR_LENGTH
#define GF_MIN_ORTHO_TOLERANCE
constexpr T normalize(UT_FixedVector< T, D > &a) noexcept
GfVec3d()=default
Default constructor does no initialization.
GfVec3d GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
double GetLength() const
Length.