24 #ifndef PXR_BASE_GF_QUATERNION_H 25 #define PXR_BASE_GF_QUATERNION_H 31 #include "pxr/base/gf/api.h" 34 #include <boost/functional/hash.hpp> 38 PXR_NAMESPACE_OPEN_SCOPE
65 : _real(realVal), _imaginary(0)
71 : _real(real), _imaginary(imaginary) {
81 _imaginary = imaginary;
129 boost::hash_combine(h, q.
GetReal());
144 return ! (*
this == q);
157 return (*
this) *= 1.0 / s;
163 _imaginary += q._imaginary;
170 _imaginary -= q._imaginary;
235 double _GetLengthSquared()
const {
236 return (_real * _real +
GfDot(_imaginary, _imaginary));
255 PXR_NAMESPACE_CLOSE_SCOPE
257 #endif // PXR_BASE_GF_QUATERNION_H friend GfQuaternion operator *(const GfQuaternion &q1, const GfQuaternion &q2)
Returns the product of quaternions q1 and q2.
friend GfQuaternion operator -(const GfQuaternion &q1, const GfQuaternion &q2)
Component-wise binary difference operator.
GfQuaternion & operator/=(double s)
Scales this quaternion by 1 / s.
friend size_t hash_value(const GfQuaternion &q)
Hash.
GF_API GfQuaternion GfSlerp(double alpha, const GfQuaternion &q0, const GfQuaternion &q1)
bool operator !=(const GfQuaternion &q) const
Component-wise quaternion inequality test.
GfQuaternion(int realVal)
This constructor initializes the real part to the argument and the imaginary parts to zero.
static GfQuaternion GetZero()
Returns the zero quaternion, which has a real part of 0 and an imaginary part of (0,...
friend GfQuaternion operator+(const GfQuaternion &q1, const GfQuaternion &q2)
Component-wise binary sum operator.
GF_API friend GfQuaternion GfSlerp(double alpha, const GfQuaternion &q0, const GfQuaternion &q1)
Spherically interpolate between q0 and q1.
GfQuaternion(double real, const GfVec3d &imaginary)
This constructor initializes the real and imaginary parts.
bool operator==(const GfQuaternion &q) const
Component-wise quaternion equality test.
Basic type: complex number with scalar real part and vector imaginary part.
GfQuaternion & operator+=(const GfQuaternion &q)
Component-wise unary sum operator.
friend GfQuaternion operator *(const GfQuaternion &q, double s)
Returns the product of quaternion q and scalar s.
double GfDot(const GfQuaternion &q1, const GfQuaternion &q2)
Returns 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.
static GfQuaternion GetIdentity()
Returns the identity quaternion, which has a real part of 1 and an imaginary part of (0,...
double GetReal() const
Returns the real part of the quaternion.
friend GfQuaternion operator/(const GfQuaternion &q, double s)
Returns the product of quaternion q and scalar 1 / s.
GfQuaternion & operator -=(const GfQuaternion &q)
Component-wise unary difference operator.
GF_API std::ostream & operator<<(std::ostream &out, const GfQuaternion &q)
Output a GfQuaternion using the format (r + (x, y, z)).
GF_API double GetLength() const
Returns geometric length of this quaternion.
GF_API GfQuaternion & operator *=(const GfQuaternion &q)
Post-multiplies quaternion q into this quaternion.
Basic type for a vector of 3 double components.
void SetReal(double real)
Sets the real part of the quaternion.
void SetImaginary(const GfVec3d &imaginary)
Sets the imaginary part of the quaternion.
const GfVec3d & GetImaginary() const
Returns the imaginary part of the quaternion.
GfQuaternion()
The default constructor leaves the quaternion undefined.
friend GfQuaternion operator *(double s, const GfQuaternion &q)
Returns the product of quaternion q and scalar s.
GF_API GfQuaternion GetNormalized(double eps=GF_MIN_VECTOR_LENGTH) const
Returns a normalized (unit-length) version of this quaternion.
GF_API GfQuaternion GetInverse() const
Returns the inverse of this quaternion.
#define GF_MIN_VECTOR_LENGTH
This constant is used to determine whether the length of a vector is too small to handle accurately.