Castor3D 0.16.0
Multiplatform 3D engine
Public Member Functions | Static Public Member Functions | List of all members
castor::QuaternionT< T > Class Template Reference

Quaternion representation class. More...

#include <Quaternion.hpp>

Inheritance diagram for castor::QuaternionT< T >:
Inheritance graph
[legend]
Collaboration diagram for castor::QuaternionT< T >:
Collaboration graph
[legend]

Public Member Functions

 QuaternionT ()
 Constructor.
 
 QuaternionT (QuaternionT const &rhs)
 Copy Constructor.
 
 QuaternionT (QuaternionT &&rhs) noexcept
 Move Constructor.
 
 QuaternionT (double const *values)
 Constructor.
 
 QuaternionT (float const *values)
 Constructor.
 
 QuaternionT (Point4f const &values)
 Constructor.
 
 QuaternionT (Point4d const &values)
 Constructor.
 
 ~QuaternionT () noexcept=default
 Destructor.
 
QuaternionT< T > & operator= (QuaternionT< T > const &rhs)
 Copy assignment operator.
 
QuaternionT< T > & operator= (QuaternionT< T > &&rhs) noexcept
 Move assignment operator.
 
QuaternionT< T > & operator+= (QuaternionT< T > const &rhs)
 addition assignment operator
 
QuaternionT< T > & operator-= (QuaternionT< T > const &rhs)
 Substraction assignment operator.
 
QuaternionT< T > & operator*= (QuaternionT< T > const &rhs)
 Multiplication assignment operator.
 
QuaternionT< T > & operator*= (double rhs)
 Multiplication assignment operator.
 
QuaternionT< T > & operator*= (float rhs)
 Multiplication assignment operator.
 
template<Vector3fT PtT>
PtT & transform (PtT const &vector, PtT &result) const
 Transforms a vector and gives the result.
 
template<Vector3dT PtT>
PtT & transform (PtT const &vector, PtT &result) const
 Transforms a vector and gives the result.
 
void toMatrix (float *matrix) const
 Fills a rotation matrix from this Quaternion.
 
void toMatrix (double *matrix) const
 Fills a rotation matrix from this Quaternion.
 
void toMatrix (Matrix4x4f &matrix) const
 Fills a rotation matrix from this Quaternion.
 
void toMatrix (Matrix4x4d &matrix) const
 Fills a rotation matrix from this Quaternion.
 
void toAxisAngle (Point3f &vector, Angle &angle) const
 Gives the axis and the angle from this Quaternion.
 
void toAxisAngle (Point3d &vector, Angle &angle) const
 Gives the axis and the angle from this Quaternion.
 
void toAxes (Point3f &x, Point3f &y, Point3f &z) const
 Computes 3 axes from this quaternion.
 
void toAxes (Point3d &x, Point3d &y, Point3d &z) const
 Computes 3 axes from this quaternion.
 
void conjugate ()
 sets this Quaternion to its conjugate
 
QuaternionT< T > getConjugate () const
 Retrieves the conjugate of this Quaternion.
 
double getMagnitude () const
 Retrieves the magnitude of this Quaternion.
 
AngleT< T > getPitch () const
 
AngleT< T > getYaw () const
 
AngleT< T > getRoll () const
 
QuaternionT< T > mix (QuaternionT< T > const &target, double factor) const
 Spherical linear interpolation another quaternions.
 
QuaternionT< T > mix (QuaternionT< T > const &target, float factor) const
 Spherical linear interpolation another quaternions.
 
QuaternionT< T > lerp (QuaternionT< T > const &target, double factor) const
 Linear interpolation of two quaternions.
 
QuaternionT< T > lerp (QuaternionT< T > const &target, float factor) const
 Linear interpolation of two quaternions.
 
QuaternionT< T > slerp (QuaternionT< T > const &target, double factor) const
 Spherical linear interpolation with another quaternions.
 
QuaternionT< T > slerp (QuaternionT< T > const &target, float factor) const
 Spherical linear interpolation with another quaternions.
 
PointData< T, 4u > * operator-> ()
 
PointData< T, 4u > const * operator-> () const
 
- Public Member Functions inherited from castor::DataHolderT< QuaternionDataT< T > >
 DataHolderT () noexcept=default
 
 DataHolderT (QuaternionDataT< T > d) noexcept
 
QuaternionDataT< T > & getData ()
 
QuaternionDataT< T > const & getData () const
 
void setData (QuaternionDataT< T > data)
 
- Public Member Functions inherited from castor::Coords< T, Count >
void swap (Coords &rhs) noexcept
 Swaps this pont data with the parameter ones.
 
uint32_t size () const
 
T const & operator[] (uint32_t index) const
 Retrieves the data at given index.
 
T & operator[] (uint32_t index)
 Retrieves the data at given index.
 
T * ptr ()
 Retrieves a non constant pointer on datas.
 
T const * constPtr () const
 Retrieves a constant pointer on datas.
 
iterator begin ()
 Retrieves an iterator to the first element.
 
const_iterator begin () const
 Retrieves a constant iterator to the first element.
 
iterator end ()
 Retrieves an iterator to the last element.
 
const_iterator end () const
 Retrieves a constant iterator to the last element.
 
 Coords ()=default
 
 Coords (Point< T, Count > &rhs)
 
 Coords (T *rhs)
 
Coordsoperator= (T *rhs)
 
Coordsoperator= (Point< T, Count > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator+= (Coords< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator-= (Coords< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator*= (Coords< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator/= (Coords< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator+= (Point< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator-= (Point< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator*= (Point< U, UCount > const &rhs)
 
template<typename U , uint32_t UCount>
Coordsoperator/= (Point< U, UCount > const &rhs)
 
template<typename U >
Coordsoperator+= (U const *coords)
 
template<typename U >
Coordsoperator-= (U const *coords)
 
template<typename U >
Coordsoperator*= (U const *coords)
 
template<typename U >
Coordsoperator/= (U const *coords)
 
Coordsoperator+= (T const &coord)
 
Coordsoperator-= (T const &coord)
 
Coordsoperator*= (T const &coord)
 
Coordsoperator/= (T const &coord)
 

Static Public Member Functions

static QuaternionT< T > fromMatrix (Matrix4x4f const &matrix)
 Updates this Quaternion from a rotation matrix.
 
static QuaternionT< T > fromMatrix (Matrix4x4d const &matrix)
 Updates this Quaternion from a rotation matrix.
 
static QuaternionT< T > fromMatrix (float const *matrix)
 Updates this Quaternion from a rotation matrix.
 
static QuaternionT< T > fromMatrix (double const *matrix)
 Updates this Quaternion from a rotation matrix.
 
static QuaternionT< T > fromAxisAngle (Point3f const &vector, Angle const &angle)
 Updates this Quaternion from an axis and an angle.
 
static QuaternionT< T > fromAxisAngle (Point3d const &vector, Angle const &angle)
 Updates this Quaternion from an axis and an angle.
 
static QuaternionT< T > fromAxes (Point3f const &x, Point3f const &y, Point3f const &z)
 Updates this Quaternion from 3 axes.
 
static QuaternionT< T > fromAxes (Point3d const &x, Point3d const &y, Point3d const &z)
 Updates this Quaternion from 3 axes.
 
static QuaternionT< T > fromComponents (float x, float y, float z, float w)
 Updates this Quaternion from 4 components.
 
static QuaternionT< T > fromComponents (double x, double y, double z, double w)
 Updates this Quaternion from 4 components.
 
static QuaternionT< T > identity ()
 Retrieves the Quaternion identity.
 
static QuaternionT< T > null ()
 Retrieves the null Quaternion.
 

Additional Inherited Members

- Public Types inherited from castor::Coords< T, Count >
using iterator = value_type *
 
using const_iterator = value_type const *
 

Detailed Description

template<typename T>
class castor::QuaternionT< T >

Quaternion representation class.

Remarks
A quaternion can be seen as an axis and an angle.
A quaternion is an axis and an angle, it's one of the best ways to represent orientations and rotations

Constructor & Destructor Documentation

◆ QuaternionT() [1/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( )

Constructor.

◆ QuaternionT() [2/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( QuaternionT< T > const & rhs)

Copy Constructor.

Parameters
[in]rhsThe Quaternion object to copy

◆ QuaternionT() [3/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( QuaternionT< T > && rhs)
noexcept

Move Constructor.

Parameters
[in]rhsThe Quaternion object to move

◆ QuaternionT() [4/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( double const * values)
explicit

Constructor.

Parameters
[in]valuesThe Quaternion values

◆ QuaternionT() [5/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( float const * values)
explicit

Constructor.

Parameters
[in]valuesThe Quaternion values

◆ QuaternionT() [6/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( Point4f const & values)
explicit

Constructor.

Parameters
[in]valuesThe quaternion values

◆ QuaternionT() [7/7]

template<typename T >
castor::QuaternionT< T >::QuaternionT ( Point4d const & values)
explicit

Constructor.

Parameters
[in]valuesThe quaternion values

◆ ~QuaternionT()

template<typename T >
castor::QuaternionT< T >::~QuaternionT ( )
defaultnoexcept

Destructor.

Member Function Documentation

◆ conjugate()

template<typename T >
void castor::QuaternionT< T >::conjugate ( )

sets this Quaternion to its conjugate

◆ fromAxes() [1/2]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromAxes ( Point3d const & x,
Point3d const & y,
Point3d const & z )
static

Updates this Quaternion from 3 axes.

Parameters
[in]x,y,zThe axes

◆ fromAxes() [2/2]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromAxes ( Point3f const & x,
Point3f const & y,
Point3f const & z )
static

Updates this Quaternion from 3 axes.

Parameters
[in]x,y,zThe axes

◆ fromAxisAngle() [1/2]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromAxisAngle ( Point3d const & vector,
Angle const & angle )
static

Updates this Quaternion from an axis and an angle.

Parameters
[in]vectorThe axis
[in]angleThe angle

◆ fromAxisAngle() [2/2]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromAxisAngle ( Point3f const & vector,
Angle const & angle )
static

Updates this Quaternion from an axis and an angle.

Parameters
[in]vectorThe axis
[in]angleThe angle

◆ fromComponents() [1/2]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromComponents ( double x,
double y,
double z,
double w )
static

Updates this Quaternion from 4 components.

Parameters
[in]x,y,z,wThe components

◆ fromComponents() [2/2]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromComponents ( float x,
float y,
float z,
float w )
static

Updates this Quaternion from 4 components.

Parameters
[in]x,y,z,wThe components

◆ fromMatrix() [1/4]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromMatrix ( double const * matrix)
static

Updates this Quaternion from a rotation matrix.

Parameters
[in]matrixThe rotation matrix

◆ fromMatrix() [2/4]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromMatrix ( float const * matrix)
static

Updates this Quaternion from a rotation matrix.

Parameters
[in]matrixThe rotation matrix

◆ fromMatrix() [3/4]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromMatrix ( Matrix4x4d const & matrix)
static

Updates this Quaternion from a rotation matrix.

Parameters
[in]matrixThe rotation matrix

◆ fromMatrix() [4/4]

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::fromMatrix ( Matrix4x4f const & matrix)
static

Updates this Quaternion from a rotation matrix.

Parameters
[in]matrixThe rotation matrix

◆ getConjugate()

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::getConjugate ( ) const

Retrieves the conjugate of this Quaternion.

Returns
The conjugate

◆ getMagnitude()

template<typename T >
double castor::QuaternionT< T >::getMagnitude ( ) const

Retrieves the magnitude of this Quaternion.

Returns
The magnitude

◆ getPitch()

template<typename T >
AngleT< T > castor::QuaternionT< T >::getPitch ( ) const
Returns
The pitch angle.

◆ getRoll()

template<typename T >
AngleT< T > castor::QuaternionT< T >::getRoll ( ) const
Returns
The roll angle.

◆ getYaw()

template<typename T >
AngleT< T > castor::QuaternionT< T >::getYaw ( ) const
Returns
The yaw angle.

◆ identity()

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::identity ( )
static

Retrieves the Quaternion identity.

◆ lerp() [1/2]

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::lerp ( QuaternionT< T > const & target,
double factor ) const

Linear interpolation of two quaternions.

Parameters
[in]targetThe target quaternion
[in]factorThe interpolation factor. The interpolation is defined in the range [0, 1].
Returns
The result of the interpolation

◆ lerp() [2/2]

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::lerp ( QuaternionT< T > const & target,
float factor ) const

Linear interpolation of two quaternions.

Parameters
[in]targetThe target quaternion
[in]factorThe interpolation factor. The interpolation is defined in the range [0, 1].
Returns
The result of the interpolation

◆ mix() [1/2]

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::mix ( QuaternionT< T > const & target,
double factor ) const

Spherical linear interpolation another quaternions.

Remarks
The interpolation is oriented and the rotation is performed at constant speed.
Parameters
[in]targetThe target quaternion
[in]factorThe interpolation factor. The interpolation is defined beyond the range [0, 1].
Returns
The result of the interpolation

◆ mix() [2/2]

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::mix ( QuaternionT< T > const & target,
float factor ) const

Spherical linear interpolation another quaternions.

Remarks
The interpolation is oriented and the rotation is performed at constant speed.
Parameters
[in]targetThe target quaternion
[in]factorThe interpolation factor. The interpolation is defined beyond the range [0, 1].
Returns
The result of the interpolation

◆ null()

template<typename T >
static QuaternionT< T > castor::QuaternionT< T >::null ( )
static

Retrieves the null Quaternion.

◆ operator*=() [1/3]

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator*= ( double rhs)

Multiplication assignment operator.

Parameters
[in]rhsThe scalar to multiply
Returns
A reference to this Quaternion object

◆ operator*=() [2/3]

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator*= ( float rhs)

Multiplication assignment operator.

Parameters
[in]rhsThe scalar to multiply
Returns
A reference to this Quaternion object

◆ operator*=() [3/3]

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator*= ( QuaternionT< T > const & rhs)

Multiplication assignment operator.

Parameters
[in]rhsThe Quaternion object to multiply
Returns
A reference to this Quaternion object

◆ operator+=()

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator+= ( QuaternionT< T > const & rhs)

addition assignment operator

Parameters
[in]rhsThe Quaternion object to add
Returns
A reference to this Quaternion object

◆ operator-=()

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator-= ( QuaternionT< T > const & rhs)

Substraction assignment operator.

Parameters
[in]rhsThe Quaternion object to subtract
Returns
A reference to this Quaternion object

◆ operator->() [1/2]

template<typename T >
PointData< T, 4u > * castor::QuaternionT< T >::operator-> ( )
inline

References castor::DataHolderT< QuaternionDataT< T > >::getData().

Here is the call graph for this function:

◆ operator->() [2/2]

template<typename T >
PointData< T, 4u > const * castor::QuaternionT< T >::operator-> ( ) const
inline

References castor::DataHolderT< QuaternionDataT< T > >::getData().

Here is the call graph for this function:

◆ operator=() [1/2]

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator= ( QuaternionT< T > && rhs)
noexcept

Move assignment operator.

Parameters
[in]rhsThe Quaternion object to move
Returns
A reference to this Quaternion object

◆ operator=() [2/2]

template<typename T >
QuaternionT< T > & castor::QuaternionT< T >::operator= ( QuaternionT< T > const & rhs)

Copy assignment operator.

Parameters
[in]rhsThe Quaternion object to copy
Returns
A reference to this Quaternion object

◆ slerp() [1/2]

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::slerp ( QuaternionT< T > const & target,
double factor ) const

Spherical linear interpolation with another quaternions.

Remarks
The interpolation always take the short path and the rotation is performed at constant speed.
Parameters
[in]targetThe target quaternion
[in]factorThe interpolation factor. The interpolation is defined beyond the range [0, 1].
Returns
The result of the interpolation

Referenced by castor3d::InterpolatorT< castor::Quaternion, InterpolatorType::eLinear >::interpolate().

Here is the caller graph for this function:

◆ slerp() [2/2]

template<typename T >
QuaternionT< T > castor::QuaternionT< T >::slerp ( QuaternionT< T > const & target,
float factor ) const

Spherical linear interpolation with another quaternions.

Remarks
The interpolation always take the short path and the rotation is performed at constant speed.
Parameters
[in]targetThe target quaternion
[in]factorThe interpolation factor. The interpolation is defined beyond the range [0, 1].
Returns
The result of the interpolation

◆ toAxes() [1/2]

template<typename T >
void castor::QuaternionT< T >::toAxes ( Point3d & x,
Point3d & y,
Point3d & z ) const

Computes 3 axes from this quaternion.

Parameters
[out]x,y,zThe axes

◆ toAxes() [2/2]

template<typename T >
void castor::QuaternionT< T >::toAxes ( Point3f & x,
Point3f & y,
Point3f & z ) const

Computes 3 axes from this quaternion.

Parameters
[out]x,y,zThe axes

◆ toAxisAngle() [1/2]

template<typename T >
void castor::QuaternionT< T >::toAxisAngle ( Point3d & vector,
Angle & angle ) const

Gives the axis and the angle from this Quaternion.

Parameters
[out]vectorReceives the axis
[out]angleReceives the angle

◆ toAxisAngle() [2/2]

template<typename T >
void castor::QuaternionT< T >::toAxisAngle ( Point3f & vector,
Angle & angle ) const

Gives the axis and the angle from this Quaternion.

Parameters
[out]vectorReceives the axis
[out]angleReceives the angle

Referenced by castor3d::SceneNode::getAxisAngle().

Here is the caller graph for this function:

◆ toMatrix() [1/4]

template<typename T >
void castor::QuaternionT< T >::toMatrix ( double * matrix) const

Fills a rotation matrix from this Quaternion.

Parameters
[out]matrixThe rotation matrix to fill

◆ toMatrix() [2/4]

template<typename T >
void castor::QuaternionT< T >::toMatrix ( float * matrix) const

Fills a rotation matrix from this Quaternion.

Parameters
[out]matrixThe rotation matrix to fill

◆ toMatrix() [3/4]

template<typename T >
void castor::QuaternionT< T >::toMatrix ( Matrix4x4d & matrix) const

Fills a rotation matrix from this Quaternion.

Parameters
[out]matrixThe rotation matrix to fill

◆ toMatrix() [4/4]

template<typename T >
void castor::QuaternionT< T >::toMatrix ( Matrix4x4f & matrix) const

Fills a rotation matrix from this Quaternion.

Parameters
[out]matrixThe rotation matrix to fill

◆ transform() [1/2]

template<typename T >
template<Vector3fT PtT>
PtT & castor::QuaternionT< T >::transform ( PtT const & vector,
PtT & result ) const

Transforms a vector and gives the result.

Parameters
[in]vectorThe vector to transform
[out]resultReceives the result
Returns
A reference to result

◆ transform() [2/2]

template<typename T >
template<Vector3dT PtT>
PtT & castor::QuaternionT< T >::transform ( PtT const & vector,
PtT & result ) const

Transforms a vector and gives the result.

Parameters
[in]vectorThe vector to transform
[out]resultReceives the result
Returns
A reference to result

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