CubbyFlow::Quaternion< T > Class Template Reference

Quaternion class defined as q = w + xi + yj + zk. More...

#include <Core/Math/Quaternion.h>

Public Member Functions

 Quaternion ()
 Make an identity quaternion. More...
 
 Quaternion (T newW, T newX, T newY, T newZ)
 Constructs a quaternion with given elements. More...
 
 Quaternion (const std::initializer_list< T > &list)
 Constructs a quaternion with given elements. More...
 
 Quaternion (const Vector3< T > &axis, T angle)
 Constructs a quaternion with given rotation axis and angle. More...
 
 Quaternion (const Vector3< T > &from, const Vector3< T > &to)
 Constructs a quaternion with from and to vectors. More...
 
 Quaternion (const Vector3< T > &axis0, const Vector3< T > &axis1, const Vector3< T > &axis2)
 Constructs a quaternion with three basis vectors. More...
 
 Quaternion (const Matrix3x3< T > &m33)
 Constructs a quaternion with 3x3 rotational matrix. More...
 
 Quaternion (const Quaternion &other)
 Copy constructor. More...
 
void Set (const Quaternion &other)
 Sets the quaternion with other quaternion. More...
 
void Set (T newW, T newX, T newY, T newZ)
 Sets the quaternion with given elements. More...
 
void Set (const std::initializer_list< T > &list)
 Sets the quaternion with given elements. More...
 
void Set (const Vector3< T > &axis, T angle)
 Sets the quaternion with given rotation axis and angle. More...
 
void Set (const Vector3< T > &from, const Vector3< T > &to)
 Sets the quaternion with from and to vectors. More...
 
void Set (const Vector3< T > &rotationBasis0, const Vector3< T > &rotationBasis1, const Vector3< T > &rotationBasis2)
 Sets quaternion with three basis vectors. More...
 
void Set (const Matrix3x3< T > &m)
 Sets the quaternion with 3x3 rotational matrix. More...
 
template<typename U >
Quaternion< U > CastTo () const
 Returns quaternion with other base type. More...
 
Quaternion Normalized () const
 Returns normalized quaternion. More...
 
Vector3< T > Mul (const Vector3< T > &v) const
 Returns this quaternion * vector. More...
 
Quaternion Mul (const Quaternion &other) const
 Returns this quaternion * other quaternion. More...
 
Dot (const Quaternion< T > &other)
 Computes the dot product with other quaternion. More...
 
Quaternion RMul (const Quaternion &other) const
 Returns other quaternion * this quaternion. More...
 
void IMul (const Quaternion &other)
 Returns this quaternion *= other quaternion. More...
 
void SetIdentity ()
 Makes this quaternion identity. More...
 
void Rotate (T angleInRadians)
 Rotate this quaternion with given angle in radians. More...
 
void Normalize ()
 Normalizes the quaternion. More...
 
Vector3< T > Axis () const
 Returns the rotational axis. More...
 
Angle () const
 Returns the rotational angle. More...
 
void GetAxisAngle (Vector3< T > *axis, T *angle) const
 Returns the axis and angle. More...
 
Quaternion Inverse () const
 Returns the inverse quaternion. More...
 
Matrix3x3< T > Matrix3 () const
 Converts to the 3x3 rotation matrix. More...
 
Matrix4x4< T > Matrix4 () const
 Converts to the 4x4 rotation matrix. More...
 
L2Norm () const
 Returns L2 norm of this quaternion. More...
 
Quaternionoperator= (const Quaternion &other)
 Assigns other quaternion. More...
 
Quaternionoperator*= (const Quaternion &other)
 Returns this quaternion *= other quaternion. More...
 
T & operator[] (size_t i)
 Returns the reference to the i-th element. More...
 
const T & operator[] (size_t i) const
 Returns the const reference to the i-th element. More...
 
bool operator== (const Quaternion &other) const
 Returns true if equal. More...
 
bool operator!= (const Quaternion &other) const
 Returns true if not equal. More...
 

Static Public Member Functions

static Quaternion MakeIdentity ()
 Returns identity matrix. More...
 

Public Attributes

w
 Real part. More...
 
x
 Imaginary part (j). More...
 
y
 Imaginary part (k). More...
 
z
 

Detailed Description

template<typename T>
class CubbyFlow::Quaternion< T >

Quaternion class defined as q = w + xi + yj + zk.

Constructor & Destructor Documentation

◆ Quaternion() [1/8]

template<typename T >
CubbyFlow::Quaternion< T >::Quaternion ( )

Make an identity quaternion.

◆ Quaternion() [2/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( newW,
newX,
newY,
newZ 
)

Constructs a quaternion with given elements.

◆ Quaternion() [3/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( const std::initializer_list< T > &  list)

Constructs a quaternion with given elements.

◆ Quaternion() [4/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( const Vector3< T > &  axis,
angle 
)

Constructs a quaternion with given rotation axis and angle.

◆ Quaternion() [5/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( const Vector3< T > &  from,
const Vector3< T > &  to 
)

Constructs a quaternion with from and to vectors.

◆ Quaternion() [6/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( const Vector3< T > &  axis0,
const Vector3< T > &  axis1,
const Vector3< T > &  axis2 
)

Constructs a quaternion with three basis vectors.

◆ Quaternion() [7/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( const Matrix3x3< T > &  m33)
explicit

Constructs a quaternion with 3x3 rotational matrix.

◆ Quaternion() [8/8]

template<typename T>
CubbyFlow::Quaternion< T >::Quaternion ( const Quaternion< T > &  other)

Copy constructor.

Member Function Documentation

◆ Angle()

template<typename T >
T CubbyFlow::Quaternion< T >::Angle ( ) const

Returns the rotational angle.

◆ Axis()

template<typename T >
Vector3< T > CubbyFlow::Quaternion< T >::Axis ( ) const

Returns the rotational axis.

◆ CastTo()

template<typename T >
template<typename U >
Quaternion< U > CubbyFlow::Quaternion< T >::CastTo ( ) const

Returns quaternion with other base type.

◆ Dot()

template<typename T>
T CubbyFlow::Quaternion< T >::Dot ( const Quaternion< T > &  other)

Computes the dot product with other quaternion.

◆ GetAxisAngle()

template<typename T>
void CubbyFlow::Quaternion< T >::GetAxisAngle ( Vector3< T > *  axis,
T *  angle 
) const

Returns the axis and angle.

◆ IMul()

template<typename T >
void CubbyFlow::Quaternion< T >::IMul ( const Quaternion< T > &  other)

Returns this quaternion *= other quaternion.

◆ Inverse()

template<typename T >
Quaternion< T > CubbyFlow::Quaternion< T >::Inverse ( ) const

Returns the inverse quaternion.

◆ L2Norm()

template<typename T >
T CubbyFlow::Quaternion< T >::L2Norm ( ) const

Returns L2 norm of this quaternion.

◆ MakeIdentity()

template<typename T >
Quaternion< T > CubbyFlow::Quaternion< T >::MakeIdentity ( )
static

Returns identity matrix.

◆ Matrix3()

template<typename T >
Matrix3x3< T > CubbyFlow::Quaternion< T >::Matrix3 ( ) const

Converts to the 3x3 rotation matrix.

◆ Matrix4()

template<typename T >
Matrix4x4< T > CubbyFlow::Quaternion< T >::Matrix4 ( ) const

Converts to the 4x4 rotation matrix.

◆ Mul() [1/2]

template<typename T>
Vector3< T > CubbyFlow::Quaternion< T >::Mul ( const Vector3< T > &  v) const

Returns this quaternion * vector.

◆ Mul() [2/2]

template<typename T>
Quaternion< T > CubbyFlow::Quaternion< T >::Mul ( const Quaternion< T > &  other) const

Returns this quaternion * other quaternion.

◆ Normalize()

template<typename T >
void CubbyFlow::Quaternion< T >::Normalize ( )

Normalizes the quaternion.

◆ Normalized()

template<typename T >
Quaternion< T > CubbyFlow::Quaternion< T >::Normalized ( ) const

Returns normalized quaternion.

◆ operator!=()

template<typename T >
bool CubbyFlow::Quaternion< T >::operator!= ( const Quaternion< T > &  other) const

Returns true if not equal.

◆ operator*=()

template<typename T >
Quaternion< T > & CubbyFlow::Quaternion< T >::operator*= ( const Quaternion< T > &  other)

Returns this quaternion *= other quaternion.

◆ operator=()

template<typename T >
Quaternion< T > & CubbyFlow::Quaternion< T >::operator= ( const Quaternion< T > &  other)

Assigns other quaternion.

◆ operator==()

template<typename T >
bool CubbyFlow::Quaternion< T >::operator== ( const Quaternion< T > &  other) const

Returns true if equal.

◆ operator[]() [1/2]

template<typename T >
T & CubbyFlow::Quaternion< T >::operator[] ( size_t  i)

Returns the reference to the i-th element.

◆ operator[]() [2/2]

template<typename T >
const T & CubbyFlow::Quaternion< T >::operator[] ( size_t  i) const

Returns the const reference to the i-th element.

◆ RMul()

template<typename T >
Quaternion< T > CubbyFlow::Quaternion< T >::RMul ( const Quaternion< T > &  other) const

Returns other quaternion * this quaternion.

◆ Rotate()

template<typename T>
void CubbyFlow::Quaternion< T >::Rotate ( angleInRadians)

Rotate this quaternion with given angle in radians.

◆ Set() [1/7]

template<typename T >
void CubbyFlow::Quaternion< T >::Set ( const Quaternion< T > &  other)

Sets the quaternion with other quaternion.

◆ Set() [2/7]

template<typename T>
void CubbyFlow::Quaternion< T >::Set ( newW,
newX,
newY,
newZ 
)

Sets the quaternion with given elements.

◆ Set() [3/7]

template<typename T>
void CubbyFlow::Quaternion< T >::Set ( const std::initializer_list< T > &  list)

Sets the quaternion with given elements.

◆ Set() [4/7]

template<typename T>
void CubbyFlow::Quaternion< T >::Set ( const Vector3< T > &  axis,
angle 
)

Sets the quaternion with given rotation axis and angle.

◆ Set() [5/7]

template<typename T>
void CubbyFlow::Quaternion< T >::Set ( const Vector3< T > &  from,
const Vector3< T > &  to 
)

Sets the quaternion with from and to vectors.

◆ Set() [6/7]

template<typename T>
void CubbyFlow::Quaternion< T >::Set ( const Vector3< T > &  rotationBasis0,
const Vector3< T > &  rotationBasis1,
const Vector3< T > &  rotationBasis2 
)

Sets quaternion with three basis vectors.

◆ Set() [7/7]

template<typename T>
void CubbyFlow::Quaternion< T >::Set ( const Matrix3x3< T > &  m)

Sets the quaternion with 3x3 rotational matrix.

◆ SetIdentity()

template<typename T >
void CubbyFlow::Quaternion< T >::SetIdentity ( )

Makes this quaternion identity.

Member Data Documentation

◆ w

template<typename T>
T CubbyFlow::Quaternion< T >::w

Real part.

Imaginary part (i).

◆ x

template<typename T>
T CubbyFlow::Quaternion< T >::x

Imaginary part (j).

◆ y

template<typename T>
T CubbyFlow::Quaternion< T >::y

Imaginary part (k).

◆ z

template<typename T>
T CubbyFlow::Quaternion< T >::z

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