Loading...
Searching...
No Matches
GfQuath Class Reference

Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients, stored as a 3-vector. More...

#include <quath.h>

Public Types

typedef GfHalf ScalarType
 
typedef GfVec3h ImaginaryType
 

Public Member Functions

 GfQuath ()=default
 GfQuath value-initializes to zero and performs no default initialization, like float or double.
 
 GfQuath (GfHalf realVal)
 Initialize the real coefficient to realVal and the imaginary coefficients to zero.
 
 GfQuath (GfHalf real, GfHalf i, GfHalf j, GfHalf k)
 Initialize the real and imaginary coefficients.
 
 GfQuath (GfHalf real, const GfVec3h &imaginary)
 Initialize the real and imaginary coefficients.
 
GF_API GfQuath (class GfQuatd const &other)
 Construct from GfQuatd.
 
GF_API GfQuath (class GfQuatf const &other)
 Construct from GfQuatf.
 
GfHalf GetReal () const
 Return the real coefficient.
 
void SetReal (GfHalf real)
 Set the real coefficient.
 
const GfVec3hGetImaginary () const
 Return the imaginary coefficient.
 
void SetImaginary (const GfVec3h &imaginary)
 Set the imaginary coefficients.
 
void SetImaginary (GfHalf i, GfHalf j, GfHalf k)
 Set the imaginary coefficients.
 
GfHalf GetLength () const
 Return geometric length of this quaternion.
 
GfQuath GetNormalized (GfHalf eps=GF_MIN_VECTOR_LENGTH) const
 length of this quaternion is smaller than eps, return the identity quaternion.
 
GF_API GfHalf Normalize (GfHalf eps=GF_MIN_VECTOR_LENGTH)
 Normalizes this quaternion in place to unit length, returning the length before normalization.
 
GfQuath GetConjugate () const
 Return this quaternion's conjugate, which is the quaternion with the same real coefficient and negated imaginary coefficients.
 
GfQuath GetInverse () const
 Return this quaternion's inverse, or reciprocal.
 
GF_API GfVec3h Transform (const GfVec3h &point) const
 Transform the GfVec3h point.
 
GfQuath operator- () const
 Component-wise negation.
 
bool operator== (const GfQuath &q) const
 Component-wise quaternion equality test.
 
bool operator!= (const GfQuath &q) const
 Component-wise quaternion inequality test.
 
GF_API GfQuathoperator*= (const GfQuath &q)
 Post-multiply quaternion q into this quaternion.
 
GfQuathoperator*= (GfHalf s)
 Multiply this quaternion's coefficients by s.
 
GfQuathoperator/= (GfHalf s)
 Divide this quaternion's coefficients by s.
 
GfQuathoperator+= (const GfQuath &q)
 Add quaternion q to this quaternion.
 
GfQuathoperator-= (const GfQuath &q)
 Component-wise unary difference operator.
 

Static Public Member Functions

static GfQuath GetZero ()
 Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.
 
static GfQuath GetIdentity ()
 Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.
 

Friends

size_t hash_value (const GfQuath &q)
 Hash.
 
GfQuath operator+ (const GfQuath &q1, const GfQuath &q2)
 Component-wise binary sum operator.
 
GfQuath operator- (const GfQuath &q1, const GfQuath &q2)
 Component-wise binary difference operator.
 
GfQuath operator* (const GfQuath &q1, const GfQuath &q2)
 Returns the product of quaternions q1 and q2.
 
GfQuath operator* (const GfQuath &q, GfHalf s)
 Returns the product of quaternion q and scalar s.
 
GfQuath operator* (GfHalf s, const GfQuath &q)
 Returns the product of quaternion q and scalar s.
 
GfQuath operator/ (const GfQuath &q, GfHalf s)
 Returns the product of quaternion q and scalar 1 / s.
 

Detailed Description

Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients, stored as a 3-vector.

Definition at line 43 of file quath.h.

Member Typedef Documentation

◆ ImaginaryType

Definition at line 47 of file quath.h.

◆ ScalarType

typedef GfHalf ScalarType

Definition at line 46 of file quath.h.

Constructor & Destructor Documentation

◆ GfQuath() [1/6]

GfQuath ( )
default

GfQuath value-initializes to zero and performs no default initialization, like float or double.

◆ GfQuath() [2/6]

GfQuath ( GfHalf  realVal)
inlineexplicit

Initialize the real coefficient to realVal and the imaginary coefficients to zero.

Since quaternions typically must be normalized, reasonable values for realVal are -1, 0, or 1. Other values are legal but are likely to be meaningless.

Definition at line 60 of file quath.h.

◆ GfQuath() [3/6]

GfQuath ( GfHalf  real,
GfHalf  i,
GfHalf  j,
GfHalf  k 
)
inline

Initialize the real and imaginary coefficients.

Definition at line 63 of file quath.h.

◆ GfQuath() [4/6]

GfQuath ( GfHalf  real,
const GfVec3h imaginary 
)
inline

Initialize the real and imaginary coefficients.

Definition at line 69 of file quath.h.

◆ GfQuath() [5/6]

GF_API GfQuath ( class GfQuatd const &  other)
explicit

Construct from GfQuatd.

◆ GfQuath() [6/6]

GF_API GfQuath ( class GfQuatf const &  other)
explicit

Construct from GfQuatf.

Member Function Documentation

◆ GetConjugate()

GfQuath GetConjugate ( ) const
inline

Return this quaternion's conjugate, which is the quaternion with the same real coefficient and negated imaginary coefficients.

Definition at line 128 of file quath.h.

◆ GetIdentity()

static GfQuath GetIdentity ( )
inlinestatic

Return the identity quaternion, with real coefficient 1 and an imaginary coefficients all zero.

Definition at line 87 of file quath.h.

◆ GetImaginary()

const GfVec3h & GetImaginary ( ) const
inline

Return the imaginary coefficient.

Definition at line 96 of file quath.h.

◆ GetInverse()

GfQuath GetInverse ( ) const
inline

Return this quaternion's inverse, or reciprocal.

This is the quaternion's conjugate divided by it's squared length.

Definition at line 134 of file quath.h.

◆ GetLength()

GfHalf GetLength ( ) const
inline

Return geometric length of this quaternion.

Definition at line 109 of file quath.h.

◆ GetNormalized()

GfQuath GetNormalized ( GfHalf  eps = GF_MIN_VECTOR_LENGTH) const
inline

length of this quaternion is smaller than eps, return the identity quaternion.

Definition at line 114 of file quath.h.

◆ GetReal()

GfHalf GetReal ( ) const
inline

Return the real coefficient.

Definition at line 90 of file quath.h.

◆ GetZero()

static GfQuath GetZero ( )
inlinestatic

Return the zero quaternion, with real coefficient 0 and an imaginary coefficients all zero.

Definition at line 83 of file quath.h.

◆ Normalize()

GF_API GfHalf Normalize ( GfHalf  eps = GF_MIN_VECTOR_LENGTH)

Normalizes this quaternion in place to unit length, returning the length before normalization.

If the length of this quaternion is smaller than eps, this sets the quaternion to identity.

◆ operator!=()

bool operator!= ( const GfQuath q) const
inline

Component-wise quaternion inequality test.

The real and imaginary parts must match exactly for quaternions to be considered equal.

Definition at line 167 of file quath.h.

◆ operator*=() [1/2]

GF_API GfQuath & operator*= ( const GfQuath q)

Post-multiply quaternion q into this quaternion.

◆ operator*=() [2/2]

GfQuath & operator*= ( GfHalf  s)
inline

Multiply this quaternion's coefficients by s.

Definition at line 176 of file quath.h.

◆ operator+=()

GfQuath & operator+= ( const GfQuath q)
inline

Add quaternion q to this quaternion.

Definition at line 190 of file quath.h.

◆ operator-()

GfQuath operator- ( ) const
inline

Component-wise negation.

Definition at line 154 of file quath.h.

◆ operator-=()

GfQuath & operator-= ( const GfQuath q)
inline

Component-wise unary difference operator.

Definition at line 197 of file quath.h.

◆ operator/=()

GfQuath & operator/= ( GfHalf  s)
inline

Divide this quaternion's coefficients by s.

Definition at line 183 of file quath.h.

◆ operator==()

bool operator== ( const GfQuath q) const
inline

Component-wise quaternion equality test.

The real and imaginary parts must match exactly for quaternions to be considered equal.

Definition at line 160 of file quath.h.

◆ SetImaginary() [1/2]

void SetImaginary ( const GfVec3h imaginary)
inline

Set the imaginary coefficients.

Definition at line 99 of file quath.h.

◆ SetImaginary() [2/2]

void SetImaginary ( GfHalf  i,
GfHalf  j,
GfHalf  k 
)
inline

Set the imaginary coefficients.

Definition at line 104 of file quath.h.

◆ SetReal()

void SetReal ( GfHalf  real)
inline

Set the real coefficient.

Definition at line 93 of file quath.h.

◆ Transform()

GF_API GfVec3h Transform ( const GfVec3h point) const

Transform the GfVec3h point.

If the quaternion is normalized, the transformation is a rotation. Given a GfQuath q, q.Transform(point) is equivalent to:

(q * GfQuath(0, point) * q.GetInverse()).GetImaginary()

but is more efficient.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( const GfQuath q)
friend

Hash.

Definition at line 149 of file quath.h.

◆ operator* [1/3]

GfQuath operator* ( const GfQuath q,
GfHalf  s 
)
friend

Returns the product of quaternion q and scalar s.

Definition at line 223 of file quath.h.

◆ operator* [2/3]

GfQuath operator* ( const GfQuath q1,
const GfQuath q2 
)
friend

Returns the product of quaternions q1 and q2.

Definition at line 217 of file quath.h.

◆ operator* [3/3]

GfQuath operator* ( GfHalf  s,
const GfQuath q 
)
friend

Returns the product of quaternion q and scalar s.

Definition at line 229 of file quath.h.

◆ operator+

GfQuath operator+ ( const GfQuath q1,
const GfQuath q2 
)
friend

Component-wise binary sum operator.

Definition at line 205 of file quath.h.

◆ operator-

GfQuath operator- ( const GfQuath q1,
const GfQuath q2 
)
friend

Component-wise binary difference operator.

Definition at line 211 of file quath.h.

◆ operator/

GfQuath operator/ ( const GfQuath q,
GfHalf  s 
)
friend

Returns the product of quaternion q and scalar 1 / s.

Definition at line 235 of file quath.h.


The documentation for this class was generated from the following file: