Jet  v1.3.3
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
jet::Quaternion< T > Class Template Reference

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

#include <jet/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 > &lst)
 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 > &lst)
 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 > &matrix)
 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 jet::Quaternion< T >

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

Constructor & Destructor Documentation

◆ Quaternion() [1/8]

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

Make an identity quaternion.

◆ Quaternion() [2/8]

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

Constructs a quaternion with given elements.

◆ Quaternion() [3/8]

template<typename T >
jet::Quaternion< T >::Quaternion ( const std::initializer_list< T > &  lst)

Constructs a quaternion with given elements.

◆ Quaternion() [4/8]

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

Constructs a quaternion with given rotation axis and angle.

◆ Quaternion() [5/8]

template<typename T >
jet::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 >
jet::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 >
jet::Quaternion< T >::Quaternion ( const Matrix3x3< T > &  m33)
explicit

Constructs a quaternion with 3x3 rotational matrix.

◆ Quaternion() [8/8]

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

Copy constructor.

Member Function Documentation

◆ angle()

template<typename T >
T jet::Quaternion< T >::angle ( ) const

Returns the rotational angle.

◆ axis()

template<typename T >
Vector3<T> jet::Quaternion< T >::axis ( ) const

Returns the rotational axis.

◆ castTo()

template<typename T >
template<typename U >
Quaternion<U> jet::Quaternion< T >::castTo ( ) const

Returns quaternion with other base type.

◆ dot()

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

Computes the dot product with other quaternion.

◆ getAxisAngle()

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

Returns the axis and angle.

◆ imul()

template<typename T >
void jet::Quaternion< T >::imul ( const Quaternion< T > &  other)

Returns this quaternion *= other quaternion.

◆ inverse()

template<typename T >
Quaternion jet::Quaternion< T >::inverse ( ) const

Returns the inverse quaternion.

◆ l2Norm()

template<typename T >
T jet::Quaternion< T >::l2Norm ( ) const

Returns L2 norm of this quaternion.

◆ makeIdentity()

template<typename T >
static Quaternion jet::Quaternion< T >::makeIdentity ( )
static

Returns identity matrix.

◆ matrix3()

template<typename T >
Matrix3x3<T> jet::Quaternion< T >::matrix3 ( ) const

Converts to the 3x3 rotation matrix.

◆ matrix4()

template<typename T >
Matrix4x4<T> jet::Quaternion< T >::matrix4 ( ) const

Converts to the 4x4 rotation matrix.

◆ mul() [1/2]

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

Returns this quaternion * other quaternion.

◆ mul() [2/2]

template<typename T >
Vector3<T> jet::Quaternion< T >::mul ( const Vector3< T > &  v) const

Returns this quaternion * vector.

◆ normalize()

template<typename T >
void jet::Quaternion< T >::normalize ( )

Normalizes the quaternion.

◆ normalized()

template<typename T >
Quaternion jet::Quaternion< T >::normalized ( ) const

Returns normalized quaternion.

◆ operator!=()

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

Returns true if not equal.

◆ operator*=()

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

Returns this quaternion *= other quaternion.

◆ operator=()

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

Assigns other quaternion.

◆ operator==()

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

Returns true if equal.

◆ operator[]() [1/2]

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

Returns the reference to the i-th element.

◆ operator[]() [2/2]

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

Returns the const reference to the i-th element.

◆ rmul()

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

Returns other quaternion * this quaternion.

◆ rotate()

template<typename T >
void jet::Quaternion< T >::rotate ( angleInRadians)

Rotate this quaternion with given angle in radians.

◆ set() [1/7]

template<typename T >
void jet::Quaternion< T >::set ( const Matrix3x3< T > &  matrix)

Sets the quaternion with 3x3 rotational matrix.

◆ set() [2/7]

template<typename T >
void jet::Quaternion< T >::set ( const Quaternion< T > &  other)

Sets the quaternion with other quaternion.

◆ set() [3/7]

template<typename T >
void jet::Quaternion< T >::set ( const std::initializer_list< T > &  lst)

Sets the quaternion with given elements.

◆ set() [4/7]

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

Sets the quaternion with given rotation axis and angle.

◆ set() [5/7]

template<typename T >
void jet::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 jet::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 jet::Quaternion< T >::set ( newW,
newX,
newY,
newZ 
)

Sets the quaternion with given elements.

◆ setIdentity()

template<typename T >
void jet::Quaternion< T >::setIdentity ( )

Makes this quaternion identity.

Member Data Documentation

◆ w

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

Real part.

Imaginary part (i).

◆ x

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

Imaginary part (j).

◆ y

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

Imaginary part (k).

◆ z

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

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