Berserk
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
TQuat< T > Class Template Reference

General quaternion math class. More...

#include <TQuat.hpp>

Collaboration diagram for TQuat< T >:
Collaboration graph
[legend]

Public Types

using Vec = TVecN< T, 3 >
 
using Mat = TMatMxN< T, 4, 4 >
 

Public Member Functions

 TQuat ()=default
 
 TQuat (T s, const Vec &v)
 
 TQuat (T s, T x, T y, T z)
 
 TQuat (const Vec &axis, T angle)
 
 TQuat (T roll, T yaw, T pitch)
 
 TQuat (const Mat &mat)
 
 TQuat (const TQuat &other)=default
 
 TQuat (TQuat &&other) noexcept=default
 
 ~TQuat ()=default
 
TQuatoperator= (const TQuat &other)=default
 
TQuatoperator= (TQuat &&other) noexcept=default
 
void Identity ()
 
void Zero ()
 
TQuat operator* (const TQuat &other) const
 
TQuatoperator*= (T a)
 
TQuatoperator/= (T a)
 
T Length2 () const
 
T Length () const
 
TQuat Normalized () const
 
TQuatNormalize ()
 
TQuat Inverse () const
 
TQuat Conjugate () const
 
Vec Rotate (const Vec &v) const
 
Vec RotateReverse (const Vec &v) const
 
Vec GetAxisX () const
 
Vec GetAxisY () const
 
Vec GetAxisZ () const
 
T GetAngle () const
 
Mat AsMatrix () const
 
void GetAxisAngle (Vec &axis, T &angle) const
 
Crc32Hash Hash () const
 
bool operator== (const TQuat &other) const
 
bool operator!= (const TQuat &other) const
 

Static Public Member Functions

static TQuat Rotation (const Vec &axis, T angle)
 
static T Dot (const TQuat &a, const TQuat &b)
 
static T Angle (const TQuat &a, const TQuat &b)
 
static TQuat Lerp (T t, const TQuat &a, const TQuat &b)
 
static TQuat Slerp (T t, const TQuat &a, const TQuat &b)
 
static TQuat Slerp (T t, T ang, const TQuat &a, const TQuat &b)
 
static TQuat LookAt (const TVecN< T, 3 > &direction, const TVecN< T, 3 > &up)
 
static TQuat FaceAt (const TVecN< T, 3 > &direction, const TVecN< T, 3 > &up)
 

Public Attributes

T scalar = 1
 
Vec vec
 

Detailed Description

template<typename T>
class TQuat< T >

General quaternion math class.

Template Parameters
TBase type of quaternion elements

Member Typedef Documentation

◆ Mat

template<typename T >
using TQuat< T >::Mat = TMatMxN<T, 4, 4>

◆ Vec

template<typename T >
using TQuat< T >::Vec = TVecN<T, 3>

Constructor & Destructor Documentation

◆ TQuat() [1/8]

template<typename T >
TQuat< T >::TQuat ( )
default

◆ TQuat() [2/8]

template<typename T >
TQuat< T >::TQuat ( T  s,
const Vec v 
)
inline

◆ TQuat() [3/8]

template<typename T >
TQuat< T >::TQuat ( T  s,
T  x,
T  y,
T  z 
)
inline

◆ TQuat() [4/8]

template<typename T >
TQuat< T >::TQuat ( const Vec axis,
T  angle 
)
inline

Clockwise rotation around an arbitrary axis

◆ TQuat() [5/8]

template<typename T >
TQuat< T >::TQuat ( T  roll,
T  yaw,
T  pitch 
)
inline

◆ TQuat() [6/8]

template<typename T >
TQuat< T >::TQuat ( const Mat mat)
inlineexplicit

◆ TQuat() [7/8]

template<typename T >
TQuat< T >::TQuat ( const TQuat< T > &  other)
default

◆ TQuat() [8/8]

template<typename T >
TQuat< T >::TQuat ( TQuat< T > &&  other)
defaultnoexcept

◆ ~TQuat()

template<typename T >
TQuat< T >::~TQuat ( )
default

Member Function Documentation

◆ Angle()

template<typename T >
static T TQuat< T >::Angle ( const TQuat< T > &  a,
const TQuat< T > &  b 
)
inlinestatic

◆ AsMatrix()

template<typename T >
Mat TQuat< T >::AsMatrix ( ) const
inline

◆ Conjugate()

template<typename T >
TQuat TQuat< T >::Conjugate ( ) const
inline

◆ Dot()

template<typename T >
static T TQuat< T >::Dot ( const TQuat< T > &  a,
const TQuat< T > &  b 
)
inlinestatic

◆ FaceAt()

template<typename T >
static TQuat TQuat< T >::FaceAt ( const TVecN< T, 3 > &  direction,
const TVecN< T, 3 > &  up 
)
inlinestatic
 | y
 |
 |_____ x
/

/ /z

Rotation to orient an object with direction and up vectors

Parameters
directionWhere to look up (rotates z to this dir)
upWhere is up after rotation (rotates y)
Returns
Rotation quaternion

◆ GetAngle()

template<typename T >
T TQuat< T >::GetAngle ( ) const
inline

◆ GetAxisAngle()

template<typename T >
void TQuat< T >::GetAxisAngle ( Vec axis,
T angle 
) const
inline

◆ GetAxisX()

template<typename T >
Vec TQuat< T >::GetAxisX ( ) const
inline

◆ GetAxisY()

template<typename T >
Vec TQuat< T >::GetAxisY ( ) const
inline

◆ GetAxisZ()

template<typename T >
Vec TQuat< T >::GetAxisZ ( ) const
inline

◆ Hash()

template<typename T >
Crc32Hash TQuat< T >::Hash ( ) const
inline

◆ Identity()

template<typename T >
void TQuat< T >::Identity ( )
inline

◆ Inverse()

template<typename T >
TQuat TQuat< T >::Inverse ( ) const
inline

◆ Length()

template<typename T >
T TQuat< T >::Length ( ) const
inline

◆ Length2()

template<typename T >
T TQuat< T >::Length2 ( ) const
inline

◆ Lerp()

template<typename T >
static TQuat TQuat< T >::Lerp ( T  t,
const TQuat< T > &  a,
const TQuat< T > &  b 
)
inlinestatic

◆ LookAt()

template<typename T >
static TQuat TQuat< T >::LookAt ( const TVecN< T, 3 > &  direction,
const TVecN< T, 3 > &  up 
)
inlinestatic
 | y
 |
 |_____ x
/

/ /z

Look at view quaternion for camera (in OpenGL style)

Note
Final are is located in the negative z space
Parameters
directionDirection vector of viewing
upUp vector to define orientation
Returns
Look quaternion to rotate world to the View space

◆ Normalize()

template<typename T >
TQuat& TQuat< T >::Normalize ( )
inline

◆ Normalized()

template<typename T >
TQuat TQuat< T >::Normalized ( ) const
inline

◆ operator!=()

template<typename T >
bool TQuat< T >::operator!= ( const TQuat< T > &  other) const
inline

◆ operator*()

template<typename T >
TQuat TQuat< T >::operator* ( const TQuat< T > &  other) const
inline

◆ operator*=()

template<typename T >
TQuat& TQuat< T >::operator*= ( T  a)
inline

◆ operator/=()

template<typename T >
TQuat& TQuat< T >::operator/= ( T  a)
inline

◆ operator=() [1/2]

template<typename T >
TQuat& TQuat< T >::operator= ( const TQuat< T > &  other)
default

◆ operator=() [2/2]

template<typename T >
TQuat& TQuat< T >::operator= ( TQuat< T > &&  other)
defaultnoexcept

◆ operator==()

template<typename T >
bool TQuat< T >::operator== ( const TQuat< T > &  other) const
inline

◆ Rotate()

template<typename T >
Vec TQuat< T >::Rotate ( const Vec v) const
inline

◆ RotateReverse()

template<typename T >
Vec TQuat< T >::RotateReverse ( const Vec v) const
inline

◆ Rotation()

template<typename T >
static TQuat TQuat< T >::Rotation ( const Vec axis,
T  angle 
)
inlinestatic

Clockwise rotation around an arbitrary axis

◆ Slerp() [1/2]

template<typename T >
static TQuat TQuat< T >::Slerp ( T  t,
const TQuat< T > &  a,
const TQuat< T > &  b 
)
inlinestatic

◆ Slerp() [2/2]

template<typename T >
static TQuat TQuat< T >::Slerp ( T  t,
T  ang,
const TQuat< T > &  a,
const TQuat< T > &  b 
)
inlinestatic

◆ Zero()

template<typename T >
void TQuat< T >::Zero ( )
inline

Member Data Documentation

◆ scalar

template<typename T >
T TQuat< T >::scalar = 1

◆ vec

template<typename T >
Vec TQuat< T >::vec

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