Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::render3d::Quaternion< T > Class Template Reference

Unit quaternion for robust 3D rotation representation without gimbal lock. More...

#include <Math3D.hpp>

Classes

struct  Components
 Explicit bundle of quaternion scalar and imaginary components. More...

Public Types

using value_type = T

Public Member Functions

constexpr Quaternion () noexcept=default
 Default constructor. Initializes to identity quaternion (w = 1).
constexpr Quaternion (const Components &components) noexcept
 Constructs quaternion from explicit components bundle.
constexpr Quaternion (T real_val, const math::Vector3< T > &imag_vec) noexcept
 Constructs quaternion from scalar real part and 3D imaginary vector.
constexpr T w () const noexcept
constexpr T x () const noexcept
constexpr T y () const noexcept
constexpr T z () const noexcept
T length () const noexcept
Quaternion normalized () const
constexpr Quaternion conjugate () const noexcept
constexpr Quaternion operator* (const Quaternion &rhs) const noexcept
 Hamilton quaternion multiplication (q1 * q2).
math::Vector3< T > rotate (const math::Vector3< T > &vector3) const
 Rotates a 3D vector by this quaternion.
Matrix4< T > toMatrix4 () const
 Converts unit quaternion to a 4x4 rotation matrix.

Static Public Member Functions

static Quaternion fromAxisAngle (const math::Vector3< T > &axis, T angle_rad)
 Creates quaternion from rotation axis and angle.

Private Attributes

T w_ {static_cast<T>(1)}
T x_ {static_cast<T>(0)}
T y_ {static_cast<T>(0)}
T z_ {static_cast<T>(0)}

Detailed Description

template<typename T = float>
requires std::is_floating_point_v<T>
class correlation::render3d::Quaternion< T >

Unit quaternion for robust 3D rotation representation without gimbal lock.

Template Parameters
TFloating-point scalar type.

Member Typedef Documentation

◆ value_type

template<typename T = float>
using correlation::render3d::Quaternion< T >::value_type = T

Constructor & Destructor Documentation

◆ Quaternion() [1/3]

template<typename T = float>
correlation::render3d::Quaternion< T >::Quaternion ( )
constexprdefaultnoexcept

Default constructor. Initializes to identity quaternion (w = 1).

Here is the caller graph for this function:

◆ Quaternion() [2/3]

template<typename T = float>
correlation::render3d::Quaternion< T >::Quaternion ( const Components & components)
inlineexplicitconstexprnoexcept

Constructs quaternion from explicit components bundle.

Parameters
componentsStruct holding real and imaginary parts.
Here is the call graph for this function:

◆ Quaternion() [3/3]

template<typename T = float>
correlation::render3d::Quaternion< T >::Quaternion ( T real_val,
const math::Vector3< T > & imag_vec )
inlineconstexprnoexcept

Constructs quaternion from scalar real part and 3D imaginary vector.

Parameters
real_valReal scalar component.
imag_vecImaginary 3D vector.

Member Function Documentation

◆ conjugate()

template<typename T = float>
Quaternion correlation::render3d::Quaternion< T >::conjugate ( ) const
inlinenodiscardconstexprnoexcept
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fromAxisAngle()

template<typename T = float>
Quaternion correlation::render3d::Quaternion< T >::fromAxisAngle ( const math::Vector3< T > & axis,
T angle_rad )
inlinestaticnodiscard

Creates quaternion from rotation axis and angle.

Parameters
axisNormalized rotation axis.
angle_radRotation angle in radians.
Returns
Rotation quaternion.
Here is the call graph for this function:

◆ length()

template<typename T = float>
T correlation::render3d::Quaternion< T >::length ( ) const
inlinenodiscardnoexcept
Here is the caller graph for this function:

◆ normalized()

template<typename T = float>
Quaternion correlation::render3d::Quaternion< T >::normalized ( ) const
inlinenodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*()

template<typename T = float>
Quaternion correlation::render3d::Quaternion< T >::operator* ( const Quaternion< T > & rhs) const
inlinenodiscardconstexprnoexcept

Hamilton quaternion multiplication (q1 * q2).

Parameters
rhsRight-hand side quaternion.
Returns
Combined rotation.
Here is the call graph for this function:

◆ rotate()

template<typename T = float>
math::Vector3< T > correlation::render3d::Quaternion< T >::rotate ( const math::Vector3< T > & vector3) const
inlinenodiscard

Rotates a 3D vector by this quaternion.

Parameters
vector3Input 3D vector.
Returns
Rotated vector.
Here is the call graph for this function:

◆ toMatrix4()

template<typename T = float>
Matrix4< T > correlation::render3d::Quaternion< T >::toMatrix4 ( ) const
inlinenodiscard

Converts unit quaternion to a 4x4 rotation matrix.

Returns
Rotation matrix.
Here is the call graph for this function:

◆ w()

template<typename T = float>
T correlation::render3d::Quaternion< T >::w ( ) const
inlinenodiscardconstexprnoexcept

◆ x()

template<typename T = float>
T correlation::render3d::Quaternion< T >::x ( ) const
inlinenodiscardconstexprnoexcept
Here is the caller graph for this function:

◆ y()

template<typename T = float>
T correlation::render3d::Quaternion< T >::y ( ) const
inlinenodiscardconstexprnoexcept
Here is the caller graph for this function:

◆ z()

template<typename T = float>
T correlation::render3d::Quaternion< T >::z ( ) const
inlinenodiscardconstexprnoexcept
Here is the caller graph for this function:

Member Data Documentation

◆ w_

template<typename T = float>
T correlation::render3d::Quaternion< T >::w_ {static_cast<T>(1)}
private

◆ x_

template<typename T = float>
T correlation::render3d::Quaternion< T >::x_ {static_cast<T>(0)}
private

◆ y_

template<typename T = float>
T correlation::render3d::Quaternion< T >::y_ {static_cast<T>(0)}
private

◆ z_

template<typename T = float>
T correlation::render3d::Quaternion< T >::z_ {static_cast<T>(0)}
private

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