Antkeeper  0.0.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
math::quaternion< T > Struct Template Reference

Quaternion composed of a real scalar part and imaginary vector part. More...

#include <quaternion.hpp>

Public Types

using scalar_type = T
 Scalar type. More...
 
using vector_type = vec3< T >
 Vector type. More...
 
using matrix_type = mat3< T >
 Rotation matrix type. More...
 

Public Member Functions

template<class U >
constexpr operator quaternion< U > () const noexcept
 Type-casts the quaternion scalars using static_cast. More...
 
constexpr operator vec4< T > () const noexcept
 Casts the quaternion to a 4-element vector, with the real part as the first element and the imaginary part as the following three elements. More...
 
constexpr scalar_typew () noexcept
 Returns a reference to the quaternion real part. More...
 
constexpr const scalar_typew () const noexcept
 Returns a reference to the quaternion real part. More...
 
constexpr scalar_typex () noexcept
 Returns a reference to the first element of the quaternion imaginary part. More...
 
constexpr const scalar_typex () const noexcept
 Returns a reference to the first element of the quaternion imaginary part. More...
 
constexpr scalar_typey () noexcept
 Returns a reference to the second element of the quaternion imaginary part. More...
 
constexpr const scalar_typey () const noexcept
 Returns a reference to the second element of the quaternion imaginary part. More...
 
constexpr scalar_typez () noexcept
 Returns a reference to the third element of the quaternion imaginary part. More...
 
constexpr const scalar_typez () const noexcept
 Returns a reference to the third element of the quaternion imaginary part. More...
 
constexpr operator matrix_type () const noexcept
 Constructs a matrix representing the rotation described by the quaternion. More...
 
constexpr matrix_type matrix () const noexcept
 Constructs a matrix representing the rotation described by the quaternion. More...
 

Static Public Member Functions

static quaternion rotate_x (scalar_type angle)
 Returns a quaternion representing a rotation about the x-axis. More...
 
static quaternion rotate_y (scalar_type angle)
 Returns a quaternion representing a rotation about the y-axis. More...
 
static quaternion rotate_z (scalar_type angle)
 Returns a quaternion representing a rotation about the z-axis. More...
 
static constexpr quaternion zero () noexcept
 Returns a zero quaternion, where every scalar is equal to zero. More...
 
static constexpr quaternion identity () noexcept
 Returns a rotation identity quaternion. More...
 

Public Attributes

scalar_type r
 Quaternion real part. More...
 
vector_type i
 Quaternion imaginary part. More...
 

Detailed Description

template<class T>
struct math::quaternion< T >

Quaternion composed of a real scalar part and imaginary vector part.

Template Parameters
TScalar type.

Definition at line 38 of file quaternion.hpp.

Member Typedef Documentation

◆ matrix_type

template<class T >
using math::quaternion< T >::matrix_type = mat3<T>

Rotation matrix type.

Definition at line 47 of file quaternion.hpp.

◆ scalar_type

template<class T >
using math::quaternion< T >::scalar_type = T

Scalar type.

Definition at line 41 of file quaternion.hpp.

◆ vector_type

template<class T >
using math::quaternion< T >::vector_type = vec3<T>

Vector type.

Definition at line 44 of file quaternion.hpp.

Member Function Documentation

◆ identity()

template<class T >
static constexpr quaternion math::quaternion< T >::identity ( )
inlinestaticconstexprnoexcept

Returns a rotation identity quaternion.

Definition at line 200 of file quaternion.hpp.

◆ matrix()

template<class T >
constexpr matrix_type math::quaternion< T >::matrix ( ) const
inlineconstexprnoexcept

Constructs a matrix representing the rotation described by the quaternion.

Returns
Rotation matrix.

Definition at line 177 of file quaternion.hpp.

◆ operator matrix_type()

template<class T >
constexpr math::quaternion< T >::operator matrix_type ( ) const
inlineexplicitconstexprnoexcept

Constructs a matrix representing the rotation described by the quaternion.

Returns
Rotation matrix.

Definition at line 157 of file quaternion.hpp.

◆ operator quaternion< U >()

template<class T >
template<class U >
constexpr math::quaternion< T >::operator quaternion< U > ( ) const
inlineexplicitconstexprnoexcept

Type-casts the quaternion scalars using static_cast.

Template Parameters
UTarget scalar type.
Returns
Type-casted quaternion.

Definition at line 146 of file quaternion.hpp.

◆ operator vec4< T >()

template<class T >
constexpr math::quaternion< T >::operator vec4< T > ( ) const
inlineexplicitconstexprnoexcept

Casts the quaternion to a 4-element vector, with the real part as the first element and the imaginary part as the following three elements.

Returns
Vector containing the real and imaginary parts of the quaternion.

Definition at line 188 of file quaternion.hpp.

◆ rotate_x()

template<class T >
static quaternion math::quaternion< T >::rotate_x ( scalar_type  angle)
inlinestatic

Returns a quaternion representing a rotation about the x-axis.

Parameters
angleAngle of rotation, in radians.
Returns
Quaternion representing an x-axis rotation.

Definition at line 110 of file quaternion.hpp.

◆ rotate_y()

template<class T >
static quaternion math::quaternion< T >::rotate_y ( scalar_type  angle)
inlinestatic

Returns a quaternion representing a rotation about the y-axis.

Parameters
angleAngle of rotation, in radians.
Returns
Quaternion representing an y-axis rotation.

Definition at line 122 of file quaternion.hpp.

◆ rotate_z()

template<class T >
static quaternion math::quaternion< T >::rotate_z ( scalar_type  angle)
inlinestatic

Returns a quaternion representing a rotation about the z-axis.

Parameters
angleAngle of rotation, in radians.
Returns
Quaternion representing an z-axis rotation.

Definition at line 133 of file quaternion.hpp.

◆ w() [1/2]

template<class T >
constexpr const scalar_type& math::quaternion< T >::w ( ) const
inlineconstexprnoexcept

Returns a reference to the quaternion real part.

Definition at line 61 of file quaternion.hpp.

◆ w() [2/2]

template<class T >
constexpr scalar_type& math::quaternion< T >::w ( )
inlineconstexprnoexcept

Returns a reference to the quaternion real part.

Definition at line 57 of file quaternion.hpp.

◆ x() [1/2]

template<class T >
constexpr const scalar_type& math::quaternion< T >::x ( ) const
inlineconstexprnoexcept

Returns a reference to the first element of the quaternion imaginary part.

Definition at line 73 of file quaternion.hpp.

◆ x() [2/2]

template<class T >
constexpr scalar_type& math::quaternion< T >::x ( )
inlineconstexprnoexcept

Returns a reference to the first element of the quaternion imaginary part.

Definition at line 69 of file quaternion.hpp.

◆ y() [1/2]

template<class T >
constexpr const scalar_type& math::quaternion< T >::y ( ) const
inlineconstexprnoexcept

Returns a reference to the second element of the quaternion imaginary part.

Definition at line 85 of file quaternion.hpp.

◆ y() [2/2]

template<class T >
constexpr scalar_type& math::quaternion< T >::y ( )
inlineconstexprnoexcept

Returns a reference to the second element of the quaternion imaginary part.

Definition at line 81 of file quaternion.hpp.

◆ z() [1/2]

template<class T >
constexpr const scalar_type& math::quaternion< T >::z ( ) const
inlineconstexprnoexcept

Returns a reference to the third element of the quaternion imaginary part.

Definition at line 97 of file quaternion.hpp.

◆ z() [2/2]

template<class T >
constexpr scalar_type& math::quaternion< T >::z ( )
inlineconstexprnoexcept

Returns a reference to the third element of the quaternion imaginary part.

Definition at line 93 of file quaternion.hpp.

◆ zero()

template<class T >
static constexpr quaternion math::quaternion< T >::zero ( )
inlinestaticconstexprnoexcept

Returns a zero quaternion, where every scalar is equal to zero.

Definition at line 194 of file quaternion.hpp.

Member Data Documentation

◆ i

template<class T >
vector_type math::quaternion< T >::i

Quaternion imaginary part.

Definition at line 53 of file quaternion.hpp.

◆ r

template<class T >
scalar_type math::quaternion< T >::r

Quaternion real part.

Definition at line 50 of file quaternion.hpp.


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