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)
112 _imaginary = imaginary;
117 _imaginary.
Set(i, j, k);
162 size_t h = boost::hash<ScalarType>()(q.
GetReal());
182 return !(*
this == q);
206 _imaginary += q._imaginary;
213 _imaginary -= q._imaginary;
262 _GetLengthSquared()
const {
263 return GfDot(*
this, *
this);
287 PXR_NAMESPACE_CLOSE_SCOPE
289 #endif // PXR_BASE_GF_QUATF_H
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients...
GfQuatf GetNormalized(float eps=GF_MIN_VECTOR_LENGTH) const
length of this quaternion is smaller than eps, return the identity quaternion.
Basic type for a vector of 3 float components.
bool operator!=(const GfQuatf &q) const
Component-wise quaternion inequality test.
float GetReal() const
Return the real coefficient.
GfQuatf operator-() const
Component-wise negation.
void SetImaginary(float i, float j, float k)
Set the imaginary coefficients.
GfQuatf & operator-=(const GfQuatf &q)
Component-wise unary difference operator.
bool operator==(const GfQuatf &q) const
Component-wise quaternion equality test.
float GetLength() const
Return geometric length of this quaternion.
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...
friend GfQuatf operator*(const GfQuatf &q1, const GfQuatf &q2)
Returns the product of quaternions q1 and q2.
GF_API GfQuatd GfSlerp(double alpha, const GfQuatd &q0, const GfQuatd &q1)
Spherically linearly interpolate between q0 and q1.
void SetReal(float real)
Set the real coefficient.
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.
void SetImaginary(const GfVec3f &imaginary)
Set the imaginary coefficients.
decltype(std::declval< Left >()*std::declval< Right >()) GfDot(Left left, Right right)
Returns the dot (inner) product of two vectors.
GfQuatf()
Default constructor leaves the quaternion undefined.
GfVec3f & Set(float s0, float s1, float s2)
Set all elements with passed arguments.
friend size_t hash_value(const GfQuatf &q)
Hash.
double GfSqrt(double f)
Return sqrt(f).
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
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...
GfQuatf GetInverse() const
Return this quaternion's inverse, or reciprocal.
const GfVec3f & GetImaginary() const
Return the imaginary coefficient.
friend GfQuatf operator+(const GfQuatf &q1, const GfQuatf &q2)
Component-wise binary sum operator.
GfQuatf(float realVal)
Initialize the real coefficient to realVal and the imaginary coefficients to zero.
GfQuatf GetConjugate() const
Return this quaternion's conjugate, which is the quaternion with the same real coefficient and negate...
GfQuatf(float real, const GfVec3f &imaginary)
Initialize the real and imaginary coefficients.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients...
GF_API GfVec3f Transform(const GfVec3f &point) const
Transform the GfVec3f point.
GF_API GfQuatf & operator*=(const GfQuatf &q)
Post-multiply quaternion q into this quaternion.
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...