Antkeeper  0.0.1
Classes | Namespaces | Typedefs | Functions
quaternion.hpp File Reference
#include <engine/math/numbers.hpp>
#include <engine/math/matrix.hpp>
#include <engine/math/vector.hpp>
#include <array>
#include <cmath>
#include <utility>

Go to the source code of this file.

Classes

struct  math::quaternion< T >
 Quaternion composed of a real scalar part and imaginary vector part. More...
 

Namespaces

 math
 Mathematical functions and data types.
 
 math::quaternion_types
 Quaternion types.
 
 math::types
 Linear algebra data types.
 
 math::operators
 Mathematical operators.
 

Typedefs

template<class T >
using math::quaternion_types::quat = quaternion< T >
 Quaternion composed of a real scalar part and imaginary vector part. More...
 
using math::quaternion_types::fquat = quat< float >
 Quaternion with single-precision floating-point scalars. More...
 
using math::quaternion_types::dquat = quat< double >
 Quaternion with double-precision floating-point scalars. More...
 

Functions

template<class T >
constexpr quaternion< T > math::add (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Adds two quaternions. More...
 
template<class T >
constexpr quaternion< T > math::add (const quaternion< T > &a, T b) noexcept
 Adds a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > math::conjugate (const quaternion< T > &q) noexcept
 Calculates the conjugate of a quaternion. More...
 
template<class T >
constexpr T math::dot (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Calculates the dot product of two quaternions. More...
 
template<class T >
constexpr quaternion< T > math::div (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Divides a quaternion by another quaternion. More...
 
template<class T >
constexpr quaternion< T > math::div (const quaternion< T > &a, T b) noexcept
 Divides a quaternion by a scalar. More...
 
template<class T >
constexpr quaternion< T > math::div (T a, const quaternion< T > &b) noexcept
 Divides a scalar by a quaternion. More...
 
template<class T >
math::inv_length (const quaternion< T > &q)
 Calculates the inverse length of a quaternion. More...
 
template<class T >
math::length (const quaternion< T > &q)
 Calculates the length of a quaternion. More...
 
template<class T >
constexpr quaternion< T > math::lerp (const quaternion< T > &a, const quaternion< T > &b, T t) noexcept
 Performs linear interpolation between two quaternions. More...
 
template<class T >
quaternion< T > math::look_rotation (const vec3< T > &forward, vec3< T > up)
 Creates a unit quaternion rotation using forward and up vectors. More...
 
template<class T >
constexpr quaternion< T > math::mul (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Multiplies two quaternions. More...
 
template<class T >
constexpr quaternion< T > math::mul (const quaternion< T > &a, T b) noexcept
 Multiplies a quaternion by a scalar. More...
 
template<class T >
constexpr vec3< T > math::mul (const quaternion< T > &q, const vec3< T > &v) noexcept
 Rotates a vector by a unit quaternion. More...
 
template<class T >
constexpr vec3< T > math::mul (const vec3< T > &v, const quaternion< T > &q) noexcept
 Rotates a vector by the inverse of a unit quaternion. More...
 
template<class T >
constexpr quaternion< T > math::negate (const quaternion< T > &q) noexcept
 Negates a quaternion. More...
 
template<class T >
quaternion< T > math::nlerp (const quaternion< T > &a, const quaternion< T > &b, T t)
 Performs normalized linear interpolation between two quaternions. More...
 
template<class T >
quaternion< T > math::normalize (const quaternion< T > &q)
 Normalizes a quaternion. More...
 
template<class T >
quaternion< T > math::angle_axis (T angle, const vec3< T > &axis)
 Creates a rotation from an angle and axis. More...
 
template<class T >
quaternion< T > math::rotation (const vec3< T > &from, const vec3< T > &to, T tolerance=T{1e-6})
 Constructs a quaternion representing the minimum rotation from one direction to another direction. More...
 
template<class T >
quaternion< T > math::rotate_towards (const vec3< T > &from, const vec3< T > &to, T max_angle)
 Constructs a quaternion representing an angle-limited rotation from one direction towards another direction. More...
 
template<class T >
quaternion< T > math::slerp (const quaternion< T > &a, const quaternion< T > &b, T t, T tolerance=T{1e-6})
 Performs spherical linear interpolation between two quaternions. More...
 
template<class T >
constexpr T math::sqr_length (const quaternion< T > &q) noexcept
 Calculates the square length of a quaternion. More...
 
template<class T >
constexpr quaternion< T > math::sub (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Subtracts a quaternion from another quaternion. More...
 
template<class T >
std::array< quaternion< T >, 2 > math::swing_twist (const quaternion< T > &q, const vec3< T > &twist_axis, T tolerance=T{1e-6})
 Decomposes a quaternion into swing and twist rotation components. More...
 
template<class T >
quaternion< T > math::quaternion_cast (const mat3< T > &m)
 Converts a 3x3 rotation matrix to a quaternion. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator+ (const quaternion< T > &a, const quaternion< T > &b) noexcept
 
template<class T >
constexpr quaternion< T > math::operators::operator/ (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Divides a quaternion by another quaternion. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator/ (const quaternion< T > &a, T b) noexcept
 Divides a quaternion by a scalar. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator/ (T a, const quaternion< T > &b) noexcept
 Divides a scalar by a quaternion. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator* (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Multiplies two quaternions. More...
 
template<class T >
constexpr vec3< T > math::operators::operator* (const quaternion< T > &q, const vec3< T > &v) noexcept
 Rotates a vector by a unit quaternion. More...
 
template<class T >
constexpr vec3< T > math::operators::operator* (const vec3< T > &v, const quaternion< T > &q) noexcept
 Rotates a vector by the inverse of a unit quaternion. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator- (const quaternion< T > &a, const quaternion< T > &b) noexcept
 Subtracts a quaternion from another quaternion. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator- (const quaternion< T > &q) noexcept
 Negates a quaternion. More...
 
template<class T >
constexpr quaternion< T > math::sub (const quaternion< T > &a, T b) noexcept
 Subtracts a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > math::sub (T a, const quaternion< T > &b) noexcept
 Subtracts a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator+ (const quaternion< T > &a, T b) noexcept
 
template<class T >
constexpr quaternion< T > math::operators::operator+ (T a, const quaternion< T > &b) noexcept
 
template<class T >
constexpr quaternion< T > math::operators::operator* (const quaternion< T > &a, T b) noexcept
 Multiplies a quaternion by a scalar. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator* (T a, const quaternion< T > &b) noexcept
 Multiplies a quaternion by a scalar. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator- (const quaternion< T > &a, T b) noexcept
 Subtracts a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > math::operators::operator- (T a, const quaternion< T > &b) noexcept
 Subtracts a quaternion and a scalar. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator+= (quaternion< T > &a, const quaternion< T > &b) noexcept
 Adds two values and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator+= (quaternion< T > &a, T b) noexcept
 Adds two values and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator-= (quaternion< T > &a, const quaternion< T > &b) noexcept
 Subtracts the first value by the second value and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator-= (quaternion< T > &a, T b) noexcept
 Subtracts the first value by the second value and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator*= (quaternion< T > &a, const quaternion< T > &b) noexcept
 Multiplies two values and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator*= (quaternion< T > &a, T b) noexcept
 Multiplies two values and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator/= (quaternion< T > &a, const quaternion< T > &b) noexcept
 Divides the first value by the second value and stores the result in the first value. More...
 
template<class T >
constexpr quaternion< T > & math::operators::operator/= (quaternion< T > &a, T b) noexcept
 Divides the first value by the second value and stores the result in the first value. More...