VTK
Public Member Functions | Static Public Member Functions | List of all members
vtkQuaternion< T > Class Template Reference

templated base type for storage of quaternions. More...

#include <vtkQuaternion.h>

Inheritance diagram for vtkQuaternion< T >:
[legend]
Collaboration diagram for vtkQuaternion< T >:
[legend]

Public Member Functions

 vtkQuaternion ()
 Default constructor. More...
 
 vtkQuaternion (const T &scalar)
 Initialize all of the quaternion's elements with the supplied scalar. More...
 
 vtkQuaternion (const T *init)
 Initialize the quaternion's elements with the elements of the supplied array. More...
 
 vtkQuaternion (const T &w, const T &x, const T &y, const T &z)
 Initialize the quaternion element explicitly. More...
 
SquaredNorm () const
 Get the squared norm of the quaternion. More...
 
Norm () const
 Get the norm of the quaternion, i.e. More...
 
void ToIdentity ()
 Set the quaternion to identity in place. More...
 
Normalize ()
 Normalize the quaternion in place. More...
 
vtkQuaternion< T > Normalized () const
 Return the normalized form of this quaternion. More...
 
void Conjugate ()
 Conjugate the quaternion in place. More...
 
vtkQuaternion< T > Conjugated () const
 Return the conjugate form of this quaternion. More...
 
void Invert ()
 Invert the quaternion in place. More...
 
vtkQuaternion< T > Inverse () const
 Return the inverted form of this quaternion. More...
 
void ToUnitLog ()
 Convert this quaternion to a unit log quaternion. More...
 
vtkQuaternion< T > UnitLog () const
 Return the unit log version of this quaternion. More...
 
void ToUnitExp ()
 Convert this quaternion to a unit exponential quaternion. More...
 
vtkQuaternion< T > UnitExp () const
 Return the unit exponential version of this quaternion. More...
 
void NormalizeWithAngleInDegrees ()
 Normalize a quaternion in place and transform it to so its angle is in degrees and its axis normalized. More...
 
vtkQuaternion< T > NormalizedWithAngleInDegrees () const
 Returns a quaternion normalized and transformed so its angle is in degrees and its axis normalized. More...
 
void Set (const T &w, const T &x, const T &y, const T &z)
 Set/Get the w, x, y and z components of the quaternion. More...
 
void Set (T quat[4])
 
void Get (T quat[4]) const
 
void SetW (const T &w)
 Set/Get the w component of the quaternion, i.e. More...
 
const T & GetW () const
 
void SetX (const T &x)
 Set/Get the x component of the quaternion, i.e. More...
 
const T & GetX () const
 
void SetY (const T &y)
 Set/Get the y component of the quaternion, i.e. More...
 
const T & GetY () const
 
void SetZ (const T &z)
 Set/Get the y component of the quaternion, i.e. More...
 
const T & GetZ () const
 
GetRotationAngleAndAxis (T axis[3]) const
 Set/Get the angle (in radians) and the axis corresponding to the axis-angle rotation of this quaternion. More...
 
void SetRotationAngleAndAxis (T angle, T axis[3])
 
void SetRotationAngleAndAxis (const T &angle, const T &x, const T &y, const T &z)
 
template<typename CastTo >
vtkQuaternion< CastTo > Cast () const
 Cast the quaternion to the specified type and return the result. More...
 
void ToMatrix3x3 (T A[3][3]) const
 Convert a quaternion to a 3x3 rotation matrix. More...
 
void FromMatrix3x3 (const T A[3][3])
 Convert a 3x3 matrix into a quaternion. More...
 
vtkQuaternion< T > Slerp (T t, const vtkQuaternion< T > &q) const
 Interpolate quaternions using spherical linear interpolation between this quaternion and q1 to produce the output. More...
 
vtkQuaternion< T > InnerPoint (const vtkQuaternion< T > &q1, const vtkQuaternion< T > &q2) const
 Interpolates between quaternions, using spherical quadrangle interpolation. More...
 
vtkQuaternion< T > operator+ (const vtkQuaternion< T > &q) const
 Performs addition of quaternion of the same basic type. More...
 
vtkQuaternion< T > operator- (const vtkQuaternion< T > &q) const
 Performs subtraction of quaternions of the same basic type. More...
 
vtkQuaternion< T > operator* (const vtkQuaternion< T > &q) const
 Performs multiplication of quaternion of the same basic type. More...
 
vtkQuaternion< T > operator* (const T &scalar) const
 Performs multiplication of the quaternions by a scalar value. More...
 
void operator*= (const T &scalar) const
 Performs in place multiplication of the quaternions by a scalar value. More...
 
vtkQuaternion< T > operator/ (const vtkQuaternion< T > &q) const
 Performs division of quaternions of the same type. More...
 
vtkQuaternion< T > operator/ (const T &scalar) const
 Performs division of the quaternions by a scalar value. More...
 
void operator/= (const T &scalar)
 Performs in place division of the quaternions by a scalar value. More...
 
- Public Member Functions inherited from vtkTuple< T, 4 >
 vtkTuple ()
 The default constructor does not initialize values. More...
 
 vtkTuple (const T &scalar)
 Initialize all of the tuple's elements with the supplied scalar. More...
 
 vtkTuple (const T *init)
 Initialize the tuple's elements with the elements of the supplied array. More...
 
int GetSize () const
 Get the size of the tuple. More...
 
T * GetData ()
 Get a pointer to the underlying data of the tuple. More...
 
const T * GetData () const
 
T & operator[] (int i)
 Get a reference to the underlying data element of the tuple. More...
 
const T & operator[] (int i) const
 
operator() (int i) const
 Get the value of the tuple at the index specified. More...
 
bool Compare (const vtkTuple< T, Size > &other, const T &tol) const
 Equality operator with a tolerance to allow fuzzy comparisons. More...
 
vtkTuple< TR, Size > Cast () const
 Cast the tuple to the specified type, returning the result. More...
 

Static Public Member Functions

static vtkQuaternion< T > Identity ()
 Return the identity quaternion. More...
 

Additional Inherited Members

- Protected Attributes inherited from vtkTuple< T, 4 >
Data [Size]
 The only thing stored in memory! More...
 

Detailed Description

template<typename T>
class vtkQuaternion< T >

templated base type for storage of quaternions.

This class is a templated data type for storing and manipulating quaternions. The quaternions have the form [w, x, y, z]. Given a rotation of angle theta and axis v, the corresponding quaternion is [w, x, y, z] = [cos(theta/2), v*sin(theta/2)]

This class implements the Spherical Linear interpolation (SLERP) and the Spherical Spline Quaternion interpolation (SQUAD). It is advised to use the vtkQuaternionInterpolator when dealing with multiple quaternions and or interpolations.

See also
vtkQuaternionInterpolator
Tests:
vtkQuaternion (Tests)

Definition at line 41 of file vtkQuaternion.h.

Constructor & Destructor Documentation

◆ vtkQuaternion() [1/4]

template<typename T>
vtkQuaternion< T >::vtkQuaternion ( )

Default constructor.

Creates an identity quaternion.

◆ vtkQuaternion() [2/4]

template<typename T>
vtkQuaternion< T >::vtkQuaternion ( const T &  scalar)
inlineexplicit

Initialize all of the quaternion's elements with the supplied scalar.

Definition at line 52 of file vtkQuaternion.h.

◆ vtkQuaternion() [3/4]

template<typename T>
vtkQuaternion< T >::vtkQuaternion ( const T *  init)
inlineexplicit

Initialize the quaternion's elements with the elements of the supplied array.

Note that the supplied pointer must contain at least as many elements as the quaternion, or it will result in access to out of bounds memory.

Definition at line 59 of file vtkQuaternion.h.

◆ vtkQuaternion() [4/4]

template<typename T>
vtkQuaternion< T >::vtkQuaternion ( const T &  w,
const T &  x,
const T &  y,
const T &  z 
)

Initialize the quaternion element explicitly.

Member Function Documentation

◆ SquaredNorm()

template<typename T>
T vtkQuaternion< T >::SquaredNorm ( ) const

Get the squared norm of the quaternion.

◆ Norm()

template<typename T>
T vtkQuaternion< T >::Norm ( ) const

Get the norm of the quaternion, i.e.

its length.

◆ ToIdentity()

template<typename T>
void vtkQuaternion< T >::ToIdentity ( )

Set the quaternion to identity in place.

◆ Identity()

template<typename T>
static vtkQuaternion<T> vtkQuaternion< T >::Identity ( )
static

Return the identity quaternion.

Note that the default constructor also creates an identity quaternion.

◆ Normalize()

template<typename T>
T vtkQuaternion< T >::Normalize ( )

Normalize the quaternion in place.

Return the norm of the quaternion.

◆ Normalized()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::Normalized ( ) const

Return the normalized form of this quaternion.

◆ Conjugate()

template<typename T>
void vtkQuaternion< T >::Conjugate ( )

Conjugate the quaternion in place.

◆ Conjugated()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::Conjugated ( ) const

Return the conjugate form of this quaternion.

◆ Invert()

template<typename T>
void vtkQuaternion< T >::Invert ( )

Invert the quaternion in place.

This is equivalent to conjugate the quaternion and then divide it by its squared norm.

◆ Inverse()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::Inverse ( ) const

Return the inverted form of this quaternion.

◆ ToUnitLog()

template<typename T>
void vtkQuaternion< T >::ToUnitLog ( )

Convert this quaternion to a unit log quaternion.

The unit log quaternion is defined by: [w, x, y, z] = [0.0, v*theta].

◆ UnitLog()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::UnitLog ( ) const

Return the unit log version of this quaternion.

The unit log quaternion is defined by: [w, x, y, z] = [0.0, v*theta].

◆ ToUnitExp()

template<typename T>
void vtkQuaternion< T >::ToUnitExp ( )

Convert this quaternion to a unit exponential quaternion.

The unit exponential quaternion is defined by: [w, x, y, z] = [cos(theta), v*sin(theta)].

◆ UnitExp()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::UnitExp ( ) const

Return the unit exponential version of this quaternion.

The unit exponential quaternion is defined by: [w, x, y, z] = [cos(theta), v*sin(theta)].

◆ NormalizeWithAngleInDegrees()

template<typename T>
void vtkQuaternion< T >::NormalizeWithAngleInDegrees ( )

Normalize a quaternion in place and transform it to so its angle is in degrees and its axis normalized.

◆ NormalizedWithAngleInDegrees()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::NormalizedWithAngleInDegrees ( ) const

Returns a quaternion normalized and transformed so its angle is in degrees and its axis normalized.

◆ Set() [1/2]

template<typename T>
void vtkQuaternion< T >::Set ( const T &  w,
const T &  x,
const T &  y,
const T &  z 
)

Set/Get the w, x, y and z components of the quaternion.

◆ Set() [2/2]

template<typename T>
void vtkQuaternion< T >::Set ( quat[4])

◆ Get()

template<typename T>
void vtkQuaternion< T >::Get ( quat[4]) const

◆ SetW()

template<typename T>
void vtkQuaternion< T >::SetW ( const T &  w)

Set/Get the w component of the quaternion, i.e.

element 0.

◆ GetW()

template<typename T>
const T& vtkQuaternion< T >::GetW ( ) const

◆ SetX()

template<typename T>
void vtkQuaternion< T >::SetX ( const T &  x)

Set/Get the x component of the quaternion, i.e.

element 1.

◆ GetX()

template<typename T>
const T& vtkQuaternion< T >::GetX ( ) const

◆ SetY()

template<typename T>
void vtkQuaternion< T >::SetY ( const T &  y)

Set/Get the y component of the quaternion, i.e.

element 2.

◆ GetY()

template<typename T>
const T& vtkQuaternion< T >::GetY ( ) const

◆ SetZ()

template<typename T>
void vtkQuaternion< T >::SetZ ( const T &  z)

Set/Get the y component of the quaternion, i.e.

element 3.

◆ GetZ()

template<typename T>
const T& vtkQuaternion< T >::GetZ ( ) const

◆ GetRotationAngleAndAxis()

template<typename T>
T vtkQuaternion< T >::GetRotationAngleAndAxis ( axis[3]) const

Set/Get the angle (in radians) and the axis corresponding to the axis-angle rotation of this quaternion.

◆ SetRotationAngleAndAxis() [1/2]

template<typename T>
void vtkQuaternion< T >::SetRotationAngleAndAxis ( angle,
axis[3] 
)

◆ SetRotationAngleAndAxis() [2/2]

template<typename T>
void vtkQuaternion< T >::SetRotationAngleAndAxis ( const T &  angle,
const T &  x,
const T &  y,
const T &  z 
)

◆ Cast()

template<typename T>
template<typename CastTo >
vtkQuaternion<CastTo> vtkQuaternion< T >::Cast ( ) const

Cast the quaternion to the specified type and return the result.

◆ ToMatrix3x3()

template<typename T>
void vtkQuaternion< T >::ToMatrix3x3 ( A[3][3]) const

Convert a quaternion to a 3x3 rotation matrix.

The quaternion does not have to be normalized beforehand.

See also
FromMatrix3x3()

◆ FromMatrix3x3()

template<typename T>
void vtkQuaternion< T >::FromMatrix3x3 ( const T  A[3][3])

Convert a 3x3 matrix into a quaternion.

This will provide the best possible answer even if the matrix is not a pure rotation matrix. The method used is that of B.K.P. Horn.

See also
ToMatrix3x3()

◆ Slerp()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::Slerp ( t,
const vtkQuaternion< T > &  q 
) const

Interpolate quaternions using spherical linear interpolation between this quaternion and q1 to produce the output.

The parametric coordinate t belongs to [0,1] and lies between (this,q1).

See also
vtkQuaternionInterpolator

◆ InnerPoint()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::InnerPoint ( const vtkQuaternion< T > &  q1,
const vtkQuaternion< T > &  q2 
) const

Interpolates between quaternions, using spherical quadrangle interpolation.

See also
vtkQuaternionInterpolator

◆ operator+()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::operator+ ( const vtkQuaternion< T > &  q) const

Performs addition of quaternion of the same basic type.

◆ operator-()

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::operator- ( const vtkQuaternion< T > &  q) const

Performs subtraction of quaternions of the same basic type.

◆ operator*() [1/2]

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::operator* ( const vtkQuaternion< T > &  q) const

Performs multiplication of quaternion of the same basic type.

◆ operator*() [2/2]

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::operator* ( const T &  scalar) const

Performs multiplication of the quaternions by a scalar value.

◆ operator*=()

template<typename T>
void vtkQuaternion< T >::operator*= ( const T &  scalar) const

Performs in place multiplication of the quaternions by a scalar value.

◆ operator/() [1/2]

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::operator/ ( const vtkQuaternion< T > &  q) const

Performs division of quaternions of the same type.

◆ operator/() [2/2]

template<typename T>
vtkQuaternion<T> vtkQuaternion< T >::operator/ ( const T &  scalar) const

Performs division of the quaternions by a scalar value.

◆ operator/=()

template<typename T>
void vtkQuaternion< T >::operator/= ( const T &  scalar)

Performs in place division of the quaternions by a scalar value.


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