Loading...
Searching...
No Matches
GfQuaternion Class Reference

Basic type: complex number with scalar real part and vector imaginary part. More...

#include <quaternion.h>

Public Member Functions

 GfQuaternion ()
 The default constructor leaves the quaternion undefined.
 
 GfQuaternion (int realVal)
 This constructor initializes the real part to the argument and the imaginary parts to zero.
 
 GfQuaternion (double real, const GfVec3d &imaginary)
 This constructor initializes the real and imaginary parts.
 
void SetReal (double real)
 Sets the real part of the quaternion.
 
void SetImaginary (const GfVec3d &imaginary)
 Sets the imaginary part of the quaternion.
 
double GetReal () const
 Returns the real part of the quaternion.
 
const GfVec3dGetImaginary () const
 Returns the imaginary part of the quaternion.
 
GF_API double GetLength () const
 Returns geometric length of this quaternion.
 
GF_API GfQuaternion GetNormalized (double eps=GF_MIN_VECTOR_LENGTH) const
 Returns a normalized (unit-length) version of this quaternion.
 
GF_API double Normalize (double eps=GF_MIN_VECTOR_LENGTH)
 Normalizes this quaternion in place to unit length, returning the length before normalization.
 
GF_API GfQuaternion GetInverse () const
 Returns the inverse of this quaternion.
 
bool operator== (const GfQuaternion &q) const
 Component-wise quaternion equality test.
 
bool operator!= (const GfQuaternion &q) const
 Component-wise quaternion inequality test.
 
GF_API GfQuaternionoperator*= (const GfQuaternion &q)
 Post-multiplies quaternion q into this quaternion.
 
GF_API GfQuaternionoperator*= (double s)
 Scales this quaternion by s.
 
GfQuaternionoperator/= (double s)
 Scales this quaternion by 1 / s.
 
GfQuaternionoperator+= (const GfQuaternion &q)
 Component-wise unary sum operator.
 
GfQuaternionoperator-= (const GfQuaternion &q)
 Component-wise unary difference operator.
 

Static Public Member Functions

static GfQuaternion GetZero ()
 Returns the zero quaternion, which has a real part of 0 and an imaginary part of (0,0,0).
 
static GfQuaternion GetIdentity ()
 Returns the identity quaternion, which has a real part of 1 and an imaginary part of (0,0,0).
 

Friends

size_t hash_value (const GfQuaternion &q)
 Hash.
 
GfQuaternion operator+ (const GfQuaternion &q1, const GfQuaternion &q2)
 Component-wise binary sum operator.
 
GfQuaternion operator- (const GfQuaternion &q1, const GfQuaternion &q2)
 Component-wise binary difference operator.
 
GfQuaternion operator* (const GfQuaternion &q1, const GfQuaternion &q2)
 Returns the product of quaternions q1 and q2.
 
GfQuaternion operator* (const GfQuaternion &q, double s)
 Returns the product of quaternion q and scalar s.
 
GfQuaternion operator* (double s, const GfQuaternion &q)
 Returns the product of quaternion q and scalar s.
 
GfQuaternion operator/ (const GfQuaternion &q, double s)
 Returns the product of quaternion q and scalar 1 / s.
 
GF_API friend GfQuaternion GfSlerp (double alpha, const GfQuaternion &q0, const GfQuaternion &q1)
 Spherically interpolate between q0 and q1.
 
GF_API GfQuaternion GfSlerp (const GfQuaternion &q0, const GfQuaternion &q1, double alpha)
 

Detailed Description

Basic type: complex number with scalar real part and vector imaginary part.

This class represents a generalized complex number that has a scalar real part and a vector of three imaginary values. Quaternions are used by the GfRotation class to represent arbitrary-axis rotations.

Definition at line 49 of file quaternion.h.

Constructor & Destructor Documentation

◆ GfQuaternion() [1/3]

GfQuaternion ( )
inline

The default constructor leaves the quaternion undefined.

Definition at line 54 of file quaternion.h.

◆ GfQuaternion() [2/3]

GfQuaternion ( int  realVal)
inlineexplicit

This constructor initializes the real part to the argument and the imaginary parts to zero.

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

Definition at line 63 of file quaternion.h.

◆ GfQuaternion() [3/3]

GfQuaternion ( double  real,
const GfVec3d imaginary 
)
inline

This constructor initializes the real and imaginary parts.

Definition at line 69 of file quaternion.h.

Member Function Documentation

◆ GetIdentity()

static GfQuaternion GetIdentity ( )
inlinestatic

Returns the identity quaternion, which has a real part of 1 and an imaginary part of (0,0,0).

Definition at line 101 of file quaternion.h.

◆ GetImaginary()

const GfVec3d & GetImaginary ( ) const
inline

Returns the imaginary part of the quaternion.

Definition at line 89 of file quaternion.h.

◆ GetInverse()

GF_API GfQuaternion GetInverse ( ) const

Returns the inverse of this quaternion.

◆ GetLength()

GF_API double GetLength ( ) const

Returns geometric length of this quaternion.

◆ GetNormalized()

GF_API GfQuaternion GetNormalized ( double  eps = GF_MIN_VECTOR_LENGTH) const

Returns a normalized (unit-length) version of this quaternion.

direction as this. If the length of this quaternion is smaller than eps, this returns the identity quaternion.

◆ GetReal()

double GetReal ( ) const
inline

Returns the real part of the quaternion.

Definition at line 84 of file quaternion.h.

◆ GetZero()

static GfQuaternion GetZero ( )
inlinestatic

Returns the zero quaternion, which has a real part of 0 and an imaginary part of (0,0,0).

Definition at line 95 of file quaternion.h.

◆ Normalize()

GF_API double Normalize ( double  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 GfQuaternion 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 139 of file quaternion.h.

◆ operator*=() [1/2]

GF_API GfQuaternion & operator*= ( const GfQuaternion q)

Post-multiplies quaternion q into this quaternion.

◆ operator*=() [2/2]

GF_API GfQuaternion & operator*= ( double  s)

Scales this quaternion by s.

◆ operator+=()

GfQuaternion & operator+= ( const GfQuaternion q)
inline

Component-wise unary sum operator.

Definition at line 157 of file quaternion.h.

◆ operator-=()

GfQuaternion & operator-= ( const GfQuaternion q)
inline

Component-wise unary difference operator.

Definition at line 164 of file quaternion.h.

◆ operator/=()

GfQuaternion & operator/= ( double  s)
inline

Scales this quaternion by 1 / s.

Definition at line 152 of file quaternion.h.

◆ operator==()

bool operator== ( const GfQuaternion 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 132 of file quaternion.h.

◆ SetImaginary()

void SetImaginary ( const GfVec3d imaginary)
inline

Sets the imaginary part of the quaternion.

Definition at line 79 of file quaternion.h.

◆ SetReal()

void SetReal ( double  real)
inline

Sets the real part of the quaternion.

Definition at line 74 of file quaternion.h.

Friends And Related Function Documentation

◆ GfSlerp

GF_API friend GfQuaternion GfSlerp ( double  alpha,
const GfQuaternion q0,
const GfQuaternion q1 
)
friend

Spherically interpolate between q0 and q1.

If the interpolant alpha is zero, then the result is q0, while alpha of one yields q1.

◆ hash_value

size_t hash_value ( const GfQuaternion q)
friend

Hash.

Definition at line 126 of file quaternion.h.

◆ operator* [1/3]

GfQuaternion operator* ( const GfQuaternion q,
double  s 
)
friend

Returns the product of quaternion q and scalar s.

Definition at line 192 of file quaternion.h.

◆ operator* [2/3]

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

Returns the product of quaternions q1 and q2.

Definition at line 185 of file quaternion.h.

◆ operator* [3/3]

GfQuaternion operator* ( double  s,
const GfQuaternion q 
)
friend

Returns the product of quaternion q and scalar s.

Definition at line 198 of file quaternion.h.

◆ operator+

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

Component-wise binary sum operator.

Definition at line 171 of file quaternion.h.

◆ operator-

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

Component-wise binary difference operator.

Definition at line 178 of file quaternion.h.

◆ operator/

GfQuaternion operator/ ( const GfQuaternion q,
double  s 
)
friend

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

Definition at line 204 of file quaternion.h.


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