28 #ifndef PXR_BASE_GF_QUATD_H 29 #define PXR_BASE_GF_QUATD_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 double ScalarType;
76 explicit GfQuatd (
double realVal) : _imaginary(0), _real(realVal) {}
79 GfQuatd(
double real,
double i,
double j,
double 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_QUATD_H GfQuatd()
Default constructor leaves the quaternion undefined.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
void SetImaginary(double i, double j, double k)
Set the imaginary coefficients.
GfQuatd GetInverse() const
Return this quaternion's inverse, or reciprocal.
GfQuatd operator-() const
Component-wise negation.
double GfDot(const GfQuatd &q1, const GfQuatd &q2)
Return the dot (inner) product of two quaternions.
GF_API double Normalize(double eps=GF_MIN_VECTOR_LENGTH)
Normalizes this quaternion in place to unit length, returning the length before normalization.
friend GfQuatd operator *(const GfQuatd &q, double s)
Returns the product of quaternion q and scalar s.
void SetImaginary(const GfVec3d &imaginary)
Set the imaginary coefficients.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
static GfQuatd GetZero()
Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
GF_API GfQuatd GfSlerp(double alpha, const GfQuatd &q0, const GfQuatd &q1)
Spherically linearly interpolate between q0 and q1.
friend GfQuatd operator *(double s, const GfQuatd &q)
Returns the product of quaternion q and scalar s.
GfQuatd GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
length of this quaternion is smaller than eps, return the identity quaternion.
GfVec3d & Set(double s0, double s1, double s2)
Set all elements with passed arguments.
GF_API GfVec3d Transform(const GfVec3d &point) const
Transform the GfVec3d point.
static GfQuatd GetIdentity()
Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
bool operator==(const GfQuatd &q) const
Component-wise quaternion equality test.
friend GfQuatd operator -(const GfQuatd &q1, const GfQuatd &q2)
Component-wise binary difference operator.
GfQuatd & operator -=(const GfQuatd &q)
Component-wise unary difference operator.
GfQuatd & operator+=(const GfQuatd &q)
Add quaternion q to this quaternion.
void SetReal(double real)
Set the real coefficient.
double GfSqrt(double f)
Return sqrt(f).
GfQuatd & operator *=(double s)
Multiply this quaternion's coefficients by s.
double GetReal() const
Return the real coefficient.
GF_API GfQuatd & operator *=(const GfQuatd &q)
Post-multiply quaternion q into this quaternion.
GF_API std::ostream & operator<<(std::ostream &, GfQuatd const &)
Output a GfQuatd using the format (re, i, j, k)
A metafunction with a static const bool member 'value' that is true for GfQuat types and false for al...
friend GfQuatd operator *(const GfQuatd &q1, const GfQuatd &q2)
Returns the product of quaternions q1 and q2.
friend GfQuatd operator+(const GfQuatd &q1, const GfQuatd &q2)
Component-wise binary sum operator.
Basic type for a vector of 3 double components.
friend size_t hash_value(const GfQuatd &q)
Hash.
double GetLength() const
Return geometric length of this quaternion.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
GfQuatd(double real, const GfVec3d &imaginary)
Initialize the real and imaginary coefficients.
GfQuatd(double realVal)
Initialize the real coefficient to realVal and the imaginary coefficients to zero.
const GfVec3d & GetImaginary() const
Return the imaginary coefficient.
GfQuatd & operator/=(double s)
Divide this quaternion's coefficients by s.
friend GfQuatd operator/(const GfQuatd &q, double s)
Returns the product of quaternion q and scalar 1 / s.
GfQuatd(double real, double i, double j, double k)
Initialize the real and imaginary coefficients.
#define GF_MIN_VECTOR_LENGTH
This constant is used to determine whether the length of a vector is too small to handle accurately.
GfQuatd GetConjugate() const
Return this quaternion's conjugate, which is the quaternion with the same real coefficient and negate...
bool operator!=(const GfQuatd &q) const
Component-wise quaternion inequality test.