Loading...
Searching...
No Matches
CubbyFlow::Quaternion< T > Class Template Reference

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

#include <Core/Math/Quaternion.hpp>

Public Member Functions

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

Static Public Member Functions

static Quaternion MakeIdentity ()
 Returns identity matrix.
 

Public Attributes

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

Detailed Description

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

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

Constructor & Destructor Documentation

◆ Quaternion() [1/9]

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

Make an identity quaternion.

◆ Quaternion() [2/9]

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

Constructs a quaternion with given elements.

◆ Quaternion() [3/9]

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

Constructs a quaternion with given elements.

◆ Quaternion() [4/9]

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

Constructs a quaternion with given rotation axis and angle.

◆ Quaternion() [5/9]

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/9]

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/9]

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

Constructs a quaternion with 3x3 rotational matrix.

◆ Quaternion() [8/9]

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

Copy constructor.

◆ Quaternion() [9/9]

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

Default move constructor.

◆ ~Quaternion()

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

Default destructor.

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) const

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 >
Quaternion< T > CubbyFlow::Quaternion< T >::Mul ( const Quaternion< T > &  other) const

Returns this quaternion * other quaternion.

◆ Mul() [2/2]

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

Returns this quaternion * vector.

◆ 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=() [1/2]

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

Copy assignment operator.

◆ operator=() [2/2]

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

Default move assignment operator.

◆ 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 ( T  angleInRadians)

Rotate this quaternion with given angle in radians.

◆ Set() [1/7]

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

Sets the quaternion with 3x3 rotational matrix.

◆ Set() [2/7]

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

Sets the quaternion with other quaternion.

◆ 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,
T  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 ( T  newW,
T  newX,
T  newY,
T  newZ 
)

Sets the quaternion with given elements.

◆ 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: