28 #ifndef PXR_BASE_GF_QUATF_H 29 #define PXR_BASE_GF_QUATF_H 35 #include "pxr/base/gf/api.h" 38 #include "pxr/base/gf/traits.h" 40 #include <boost/functional/hash.hpp> 44 PXR_NAMESPACE_OPEN_SCOPE
63 typedef float ScalarType;
76 explicit GfQuatf (
float realVal) : _imaginary(0), _real(realVal) {}
79 GfQuatf(
float real,
float i,
float j,
float k)
80 : _imaginary(i, j, k), _real(real)
86 : _imaginary(imaginary), _real(real)
116 _imaginary = imaginary;
121 _imaginary.
Set(i, j, k);
166 size_t h = boost::hash<ScalarType>()(q.
GetReal());
186 return !(*
this == q);
210 _imaginary += q._imaginary;
217 _imaginary -= q._imaginary;
266 _GetLengthSquared()
const {
267 return GfDot(*
this, *
this);
291 PXR_NAMESPACE_CLOSE_SCOPE
293 #endif // PXR_BASE_GF_QUATF_H Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
GF_API GfQuatf & operator *=(const GfQuatf &q)
Post-multiply quaternion q into this quaternion.
GfQuatf operator-() const
Component-wise negation.
Basic type for a vector of 3 float components.
friend GfQuatf operator *(const GfQuatf &q, float s)
Returns the product of quaternion q and scalar s.
void SetImaginary(float i, float j, float k)
Set the imaginary coefficients.
bool operator==(const GfQuatf &q) const
Component-wise quaternion equality test.
GF_API GfQuatf GfSlerp(double alpha, const GfQuatf &q0, const GfQuatf &q1)
Spherically linearly interpolate between q0 and q1.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
static GfQuatf GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
void SetReal(float real)
Set the real coefficient.
GfQuatf & operator -=(const GfQuatf &q)
Component-wise unary difference operator.
GfQuatf(float real, float i, float j, float k)
Initialize the real and imaginary coefficients.
GfQuatf & operator+=(const GfQuatf &q)
Add quaternion q to this quaternion.
GF_API float Normalize(float eps=GF_MIN_VECTOR_LENGTH)
Normalizes this quaternion in place to unit length, returning the length before normalization.
GF_API GfVec3f Transform(const GfVec3f &point) const
Transform the GfVec3f point.
void SetImaginary(const GfVec3f &imaginary)
Set the imaginary coefficients.
bool operator!=(const GfQuatf &q) const
Component-wise quaternion inequality test.
GF_API std::ostream & operator<<(std::ostream &, GfQuatf const &)
Output a GfQuatd using the format (re, i, j, k)
GfQuatf()
Default constructor leaves the quaternion undefined.
GfVec3f & Set(float s0, float s1, float s2)
Set all elements with passed arguments.
GfQuatf GetNormalized(float eps=GF_MIN_VECTOR_LENGTH) const
length of this quaternion is smaller than eps, return the identity quaternion.
float GetReal() const
Return the real coefficient.
float GfDot(const GfQuatf &q1, const GfQuatf &q2)
Return the dot (inner) product of two quaternions.
friend size_t hash_value(const GfQuatf &q)
Hash.
double GfSqrt(double f)
Return sqrt(f).
GfQuatf GetConjugate() const
Return this quaternion's conjugate, which is the quaternion with the same real coefficient and negate...
const GfVec3f & GetImaginary() const
Return the imaginary coefficient.
friend GfQuatf operator *(const GfQuatf &q1, const GfQuatf &q2)
Returns the product of quaternions q1 and q2.
GfQuatf & operator/=(float s)
Divide this quaternion's coefficients by s.
A metafunction with a static const bool member 'value' that is true for GfQuat types and false for al...
float GetLength() const
Return geometric length of this quaternion.
GfQuatf & operator *=(float s)
Multiply this quaternion's coefficients by s.
friend GfQuatf operator *(float s, const GfQuatf &q)
Returns the product of quaternion q and scalar s.
GfQuatf GetInverse() const
Return this quaternion's inverse, or reciprocal.
friend GfQuatf operator+(const GfQuatf &q1, const GfQuatf &q2)
Component-wise binary sum operator.
static GfQuatf GetZero()
Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
GfQuatf(float realVal)
Initialize the real coefficient to realVal and the imaginary coefficients to zero.
GfQuatf(float real, const GfVec3f &imaginary)
Initialize the real and imaginary coefficients.
friend GfQuatf operator -(const GfQuatf &q1, const GfQuatf &q2)
Component-wise binary difference operator.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
friend GfQuatf operator/(const GfQuatf &q, float s)
Returns the product of quaternion q and scalar 1 / s.
#define GF_MIN_VECTOR_LENGTH
This constant is used to determine whether the length of a vector is too small to handle accurately.