Harlinn.Windows 0.1
Loading...
Searching...
No Matches
Harlinn::Math::Quaternion< T > Class Template Reference

#include <VectorMath.h>

Inheritance diagram for Harlinn::Math::Quaternion< T >:
[legend]
Collaboration diagram for Harlinn::Math::Quaternion< T >:
[legend]

Classes

struct  AxisAngle
 

Public Types

using value_type = T
 
using size_type = size_t
 
using ValueType = value_type
 
using SizeType = size_type
 
using Traits = SIMD::Traits<ValueType, Size>
 
using SIMDType = typename Traits::SIMDType
 
using ArrayType = typename Traits::ArrayType
 
using reference = typename ArrayType::reference
 
using const_reference = typename ArrayType::const_reference
 
using pointer = typename ArrayType::pointer
 
using const_pointer = typename ArrayType::const_pointer
 
using iterator = typename ArrayType::iterator
 
using const_iterator = typename ArrayType::const_iterator
 
using reverse_iterator = typename ArrayType::reverse_iterator
 
using const_reverse_iterator = typename ArrayType::const_reverse_iterator
 
using Simd = QuaternionSimd<Quaternion>
 
using Vector = typename Vector<value_type, 3>
 
using VectorSimd = typename Vector::Simd
 
using Normal = Normal3f
 
using NormalSimd = typename Normal::Simd
 
using Matrix = SquareMatrix<ValueType, 4>
 
using MatrixSimd = SquareMatrixSimd<Matrix, 4>
 

Public Member Functions

constexpr Quaternion () noexcept
 
constexpr Quaternion (ValueType xv, ValueType yv, ValueType zv, ValueType wv) noexcept
 
constexpr Quaternion (const ArrayType &a) noexcept
 
template<TupleType T>
requires IsCompatible<T, Vector>
constexpr Quaternion (const T &xyz, ValueType wv) noexcept
 
template<SimdType T>
requires IsCompatible<T, Vector>
constexpr Quaternion (const T &xyz, ValueType wv) noexcept
 
 Quaternion (const Simd &qsimd) noexcept
 
 Quaternion (ValueType pitch, ValueType yaw, ValueType roll) noexcept
 Creates a quaternion based on the pitch, yaw, and roll (Euler angles).
 
 Quaternion (const Quaternion &other) noexcept
 
AxisAngle ToAxisAngle () const noexcept
 Returns the axis and angle of rotation about that axis for the quaternion.
 
VectorSimd ToEuler () const noexcept
 Computes rotation about y-axis (y), then x-axis (x), then z-axis (z)
 
Quaternionoperator= (const Simd &qsimd) noexcept
 
Quaternionoperator= (const Quaternion &other) noexcept
 
Simd ToSimd () const noexcept
 
 operator Simd () const noexcept
 
bool operator== (const Simd &other) const noexcept
 
bool operator!= (const Simd &other) const noexcept
 
bool operator== (const Quaternion &other) const noexcept
 
bool operator!= (const Quaternion &other) const noexcept
 
Simd operator- () const noexcept
 
const_reference operator[] (size_t index) const noexcept
 
reference operator[] (size_t index) noexcept
 
const_pointer data () const noexcept
 
pointer data () noexcept
 
constexpr size_t size () const noexcept
 
const_reference front () const noexcept
 
reference front () noexcept
 
const_reference back () const noexcept
 
reference back () noexcept
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
iterator begin () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 
iterator end () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rend () const noexcept
 
reverse_iterator rend () noexcept
 

Static Public Member Functions

template<SimdType T>
requires IsCompatible<T, VectorSimd>
static Simd FromNormalizedAxisAndAngle (const T &normalizedAxis, float angle) noexcept
 Creates a rotation quaternion around a normalized axis.
 
template<TupleType T>
requires IsCompatible<T, Vector>
static Simd FromNormalizedAxisAndAngle (const T &normalizedAxis, float angle) noexcept
 Creates a rotation quaternion around a normalized axis.
 
template<SimdType T>
requires IsCompatible<T, VectorSimd>
static Simd FromAxisAndAngle (const T &axis, float angle) noexcept
 Creates a rotation quaternion around an axis.
 
template<TupleType T>
requires IsCompatible<T, Vector>
static Simd FromAxisAndAngle (const T &axis, float angle) noexcept
 Creates a rotation quaternion around an axis.
 
static Simd FromMatrix (const MatrixSimd &matrix) noexcept
 Creates a rotation quaternion from a rotation matrix.
 
static Simd FromMatrix (const Matrix &matrix) noexcept
 Creates a rotation quaternion from a rotation matrix.
 
template<SimdType T, SimdType U>
requires IsCompatible<T, VectorSimd, U>
static Simd ShortestArc (const T &fromDir, const U &toDir) noexcept
 Creates the shortest-arc rotation between two directions.
 
template<SimdType T, TupleType U>
requires IsCompatible<T, VectorSimd, U>
static Simd ShortestArc (const T &fromDir, const U &toDir) noexcept
 Creates the shortest-arc rotation between two directions.
 
template<TupleType T, SimdType U>
requires IsCompatible<T, VectorSimd, U>
static Simd ShortestArc (const T &fromDir, const U &toDir) noexcept
 Creates the shortest-arc rotation between two directions.
 
template<TupleType T, TupleType U>
requires IsCompatible<T, VectorSimd, U>
static Simd ShortestArc (const T &fromDir, const U &toDir) noexcept
 Creates the shortest-arc rotation between two directions.
 
static constexpr Quaternion Identity () noexcept
 Returns the identity quaternion.
 

Public Attributes

union { 
 
   ArrayType   values 
 
   struct { 
 
      Vector   v 
 
      ValueType   w 
 
   }  
 
};  
 

Static Public Attributes

static constexpr size_type Size = 4
 
static constexpr size_type Capacity = Size
 

Detailed Description

template<FloatingPointType T>
class Harlinn::Math::Quaternion< T >
Template Parameters
T

Member Typedef Documentation

◆ ArrayType

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::ArrayType = typename Traits::ArrayType

◆ const_iterator

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::const_iterator = typename ArrayType::const_iterator

◆ const_pointer

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::const_pointer = typename ArrayType::const_pointer

◆ const_reference

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::const_reference = typename ArrayType::const_reference

◆ const_reverse_iterator

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::const_reverse_iterator = typename ArrayType::const_reverse_iterator

◆ iterator

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::iterator = typename ArrayType::iterator

◆ Matrix

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::Matrix = SquareMatrix<ValueType, 4>

◆ MatrixSimd

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::MatrixSimd = SquareMatrixSimd<Matrix, 4>

◆ Normal

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::Normal = Normal3f

◆ NormalSimd

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::NormalSimd = typename Normal::Simd

◆ pointer

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::pointer = typename ArrayType::pointer

◆ reference

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::reference = typename ArrayType::reference

◆ reverse_iterator

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::reverse_iterator = typename ArrayType::reverse_iterator

◆ Simd

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::Simd = QuaternionSimd<Quaternion>

◆ SIMDType

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::SIMDType = typename Traits::SIMDType

◆ size_type

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::size_type = size_t

◆ SizeType

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::SizeType = size_type

◆ Traits

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::Traits = SIMD::Traits<ValueType, Size>

◆ value_type

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::value_type = T

◆ ValueType

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::ValueType = value_type

◆ Vector

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::Vector = typename Vector<value_type, 3>

◆ VectorSimd

template<FloatingPointType T>
using Harlinn::Math::Quaternion< T >::VectorSimd = typename Vector::Simd

Constructor & Destructor Documentation

◆ Quaternion() [1/8]

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::Quaternion ( )
inlineconstexprnoexcept

◆ Quaternion() [2/8]

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::Quaternion ( ValueType xv,
ValueType yv,
ValueType zv,
ValueType wv )
inlineconstexprnoexcept

◆ Quaternion() [3/8]

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::Quaternion ( const ArrayType & a)
inlineconstexprnoexcept

◆ Quaternion() [4/8]

template<FloatingPointType T>
template<TupleType T>
requires IsCompatible<T, Vector>
Harlinn::Math::Quaternion< T >::Quaternion ( const T & xyz,
ValueType wv )
inlineconstexprnoexcept

◆ Quaternion() [5/8]

template<FloatingPointType T>
template<SimdType T>
requires IsCompatible<T, Vector>
Harlinn::Math::Quaternion< T >::Quaternion ( const T & xyz,
ValueType wv )
inlineconstexprnoexcept

◆ Quaternion() [6/8]

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::Quaternion ( const Simd & qsimd)
inlinenoexcept

◆ Quaternion() [7/8]

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::Quaternion ( ValueType pitch,
ValueType yaw,
ValueType roll )
inlinenoexcept

Creates a quaternion based on the pitch, yaw, and roll (Euler angles).

Parameters
pitchAngle of rotation around the x-axis, in radians.
yawAngle of rotation around the y-axis, in radians.
rollAngle of rotation around the z-axis, in radians.

◆ Quaternion() [8/8]

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::Quaternion ( const Quaternion< T > & other)
inlinenoexcept

Member Function Documentation

◆ back() [1/2]

template<FloatingPointType T>
const_reference Harlinn::Math::Quaternion< T >::back ( ) const
inlinenoexcept

◆ back() [2/2]

template<FloatingPointType T>
reference Harlinn::Math::Quaternion< T >::back ( )
inlinenoexcept

◆ begin() [1/2]

template<FloatingPointType T>
const_iterator Harlinn::Math::Quaternion< T >::begin ( ) const
inlinenoexcept

◆ begin() [2/2]

template<FloatingPointType T>
iterator Harlinn::Math::Quaternion< T >::begin ( )
inlinenoexcept

◆ cbegin()

template<FloatingPointType T>
const_iterator Harlinn::Math::Quaternion< T >::cbegin ( ) const
inlinenoexcept

◆ cend()

template<FloatingPointType T>
const_iterator Harlinn::Math::Quaternion< T >::cend ( ) const
inlinenoexcept

◆ data() [1/2]

template<FloatingPointType T>
const_pointer Harlinn::Math::Quaternion< T >::data ( ) const
inlinenoexcept

◆ data() [2/2]

template<FloatingPointType T>
pointer Harlinn::Math::Quaternion< T >::data ( )
inlinenoexcept

◆ end() [1/2]

template<FloatingPointType T>
const_iterator Harlinn::Math::Quaternion< T >::end ( ) const
inlinenoexcept

◆ end() [2/2]

template<FloatingPointType T>
iterator Harlinn::Math::Quaternion< T >::end ( )
inlinenoexcept

◆ FromAxisAndAngle() [1/2]

template<FloatingPointType T>
template<SimdType T>
requires IsCompatible<T, VectorSimd>
static Simd Harlinn::Math::Quaternion< T >::FromAxisAndAngle ( const T & axis,
float angle )
inlinestaticnoexcept

Creates a rotation quaternion around an axis.

Parameters
normalizedAxisA vector describing the axis of rotation.
angleThe angle of rotation in radians.
Returns
The rotation quaternion.

◆ FromAxisAndAngle() [2/2]

template<FloatingPointType T>
template<TupleType T>
requires IsCompatible<T, Vector>
static Simd Harlinn::Math::Quaternion< T >::FromAxisAndAngle ( const T & axis,
float angle )
inlinestaticnoexcept

Creates a rotation quaternion around an axis.

Parameters
normalizedAxisA vector describing the axis of rotation.
angleThe angle of rotation in radians.
Returns
The rotation quaternion.

◆ FromMatrix() [1/2]

template<FloatingPointType T>
static Simd Harlinn::Math::Quaternion< T >::FromMatrix ( const Matrix & matrix)
inlinestaticnoexcept

Creates a rotation quaternion from a rotation matrix.

Parameters
matrixThe rotation matrix.
Returns
The rotation quaternion.

◆ FromMatrix() [2/2]

template<FloatingPointType T>
static Simd Harlinn::Math::Quaternion< T >::FromMatrix ( const MatrixSimd & matrix)
inlinestaticnoexcept

Creates a rotation quaternion from a rotation matrix.

Parameters
matrixThe rotation matrix.
Returns
The rotation quaternion.

◆ FromNormalizedAxisAndAngle() [1/2]

template<FloatingPointType T>
template<SimdType T>
requires IsCompatible<T, VectorSimd>
static Simd Harlinn::Math::Quaternion< T >::FromNormalizedAxisAndAngle ( const T & normalizedAxis,
float angle )
inlinestaticnoexcept

Creates a rotation quaternion around a normalized axis.

Parameters
normalizedAxisA normalized vector describing the axis of rotation.
angleThe angle of rotation in radians.
Returns
The rotation quaternion.

◆ FromNormalizedAxisAndAngle() [2/2]

template<FloatingPointType T>
template<TupleType T>
requires IsCompatible<T, Vector>
static Simd Harlinn::Math::Quaternion< T >::FromNormalizedAxisAndAngle ( const T & normalizedAxis,
float angle )
inlinestaticnoexcept

Creates a rotation quaternion around a normalized axis.

Parameters
normalizedAxisA normalized vector describing the axis of rotation.
angleThe angle of rotation in radians.
Returns
The rotation quaternion.

◆ front() [1/2]

template<FloatingPointType T>
const_reference Harlinn::Math::Quaternion< T >::front ( ) const
inlinenoexcept

◆ front() [2/2]

template<FloatingPointType T>
reference Harlinn::Math::Quaternion< T >::front ( )
inlinenoexcept

◆ Identity()

template<FloatingPointType T>
static constexpr Quaternion Harlinn::Math::Quaternion< T >::Identity ( )
inlinestaticconstexprnoexcept

Returns the identity quaternion.

Returns
The identity quaternion.

◆ operator Simd()

template<FloatingPointType T>
Harlinn::Math::Quaternion< T >::operator Simd ( ) const
inlinenoexcept

◆ operator!=() [1/2]

template<FloatingPointType T>
bool Harlinn::Math::Quaternion< T >::operator!= ( const Quaternion< T > & other) const
inlinenoexcept

◆ operator!=() [2/2]

template<FloatingPointType T>
bool Harlinn::Math::Quaternion< T >::operator!= ( const Simd & other) const
inlinenoexcept

◆ operator-()

template<FloatingPointType T>
Simd Harlinn::Math::Quaternion< T >::operator- ( ) const
inlinenoexcept

◆ operator=() [1/2]

template<FloatingPointType T>
Quaternion & Harlinn::Math::Quaternion< T >::operator= ( const Quaternion< T > & other)
inlinenoexcept

◆ operator=() [2/2]

template<FloatingPointType T>
Quaternion & Harlinn::Math::Quaternion< T >::operator= ( const Simd & qsimd)
inlinenoexcept

◆ operator==() [1/2]

template<FloatingPointType T>
bool Harlinn::Math::Quaternion< T >::operator== ( const Quaternion< T > & other) const
inlinenoexcept

◆ operator==() [2/2]

template<FloatingPointType T>
bool Harlinn::Math::Quaternion< T >::operator== ( const Simd & other) const
inlinenoexcept

◆ operator[]() [1/2]

template<FloatingPointType T>
const_reference Harlinn::Math::Quaternion< T >::operator[] ( size_t index) const
inlinenoexcept

◆ operator[]() [2/2]

template<FloatingPointType T>
reference Harlinn::Math::Quaternion< T >::operator[] ( size_t index)
inlinenoexcept

◆ rbegin() [1/2]

template<FloatingPointType T>
const_reverse_iterator Harlinn::Math::Quaternion< T >::rbegin ( ) const
inlinenoexcept

◆ rbegin() [2/2]

template<FloatingPointType T>
reverse_iterator Harlinn::Math::Quaternion< T >::rbegin ( )
inlinenoexcept

◆ rend() [1/2]

template<FloatingPointType T>
const_reverse_iterator Harlinn::Math::Quaternion< T >::rend ( ) const
inlinenoexcept

◆ rend() [2/2]

template<FloatingPointType T>
reverse_iterator Harlinn::Math::Quaternion< T >::rend ( )
inlinenoexcept

◆ ShortestArc() [1/4]

template<FloatingPointType T>
template<SimdType T, SimdType U>
requires IsCompatible<T, VectorSimd, U>
static Simd Harlinn::Math::Quaternion< T >::ShortestArc ( const T & fromDir,
const U & toDir )
inlinestaticnoexcept

Creates the shortest-arc rotation between two directions.

Parameters
fromDirThe from direction.

///

Parameters
toDirThe to direction.
Returns
The rotation quaternion.

◆ ShortestArc() [2/4]

template<FloatingPointType T>
template<SimdType T, TupleType U>
requires IsCompatible<T, VectorSimd, U>
static Simd Harlinn::Math::Quaternion< T >::ShortestArc ( const T & fromDir,
const U & toDir )
inlinestaticnoexcept

Creates the shortest-arc rotation between two directions.

Parameters
fromDirThe from direction.

///

Parameters
toDirThe to direction.
Returns
The rotation quaternion.

◆ ShortestArc() [3/4]

template<FloatingPointType T>
template<TupleType T, SimdType U>
requires IsCompatible<T, VectorSimd, U>
static Simd Harlinn::Math::Quaternion< T >::ShortestArc ( const T & fromDir,
const U & toDir )
inlinestaticnoexcept

Creates the shortest-arc rotation between two directions.

Parameters
fromDirThe from direction.

///

Parameters
toDirThe to direction.
Returns
The rotation quaternion.

◆ ShortestArc() [4/4]

template<FloatingPointType T>
template<TupleType T, TupleType U>
requires IsCompatible<T, VectorSimd, U>
static Simd Harlinn::Math::Quaternion< T >::ShortestArc ( const T & fromDir,
const U & toDir )
inlinestaticnoexcept

Creates the shortest-arc rotation between two directions.

Parameters
fromDirThe from direction.

///

Parameters
toDirThe to direction.
Returns
The rotation quaternion.

◆ size()

template<FloatingPointType T>
size_t Harlinn::Math::Quaternion< T >::size ( ) const
inlineconstexprnoexcept

◆ ToAxisAngle()

template<FloatingPointType T>
AxisAngle Harlinn::Math::Quaternion< T >::ToAxisAngle ( ) const
inlinenoexcept

Returns the axis and angle of rotation about that axis for the quaternion.

Returns

◆ ToEuler()

template<FloatingPointType T>
VectorSimd Harlinn::Math::Quaternion< T >::ToEuler ( ) const
inlinenoexcept

Computes rotation about y-axis (y), then x-axis (x), then z-axis (z)

Returns
The rotation about y-axis (y), then x-axis (x), then z-axis (z)

Adopted from https://github.com/microsoft/DirectXTK12

◆ ToSimd()

template<FloatingPointType T>
Simd Harlinn::Math::Quaternion< T >::ToSimd ( ) const
inlinenoexcept

Member Data Documentation

◆ [union]

union { ... } Harlinn::Math::Quaternion< T >

◆ Capacity

template<FloatingPointType T>
size_type Harlinn::Math::Quaternion< T >::Capacity = Size
staticconstexpr

◆ Size

template<FloatingPointType T>
size_type Harlinn::Math::Quaternion< T >::Size = 4
staticconstexpr

◆ v

template<FloatingPointType T>
Vector Harlinn::Math::Quaternion< T >::v

◆ values

template<FloatingPointType T>
ArrayType Harlinn::Math::Quaternion< T >::values

◆ w

template<FloatingPointType T>
ValueType Harlinn::Math::Quaternion< T >::w

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