xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
Public 类型 | Public 成员函数 | 静态 Public 成员函数 | 静态 Public 属性 | 所有成员列表
xcmath::quaternion< _Tp > 模板类 参考

Quaternion class template 更多...

#include <quaternion.hpp>

类 xcmath::quaternion< _Tp > 继承关系图:
[图例]
xcmath::quaternion< _Tp > 的协作图:
[图例]

Public 类型

using ItemType = _Tp
 Type of elements in the vector
 
using DataType = VecInfo< ItemType >::DataType
 Type of data stored in the vector
 
template<class _T >
using Self = quaternion< _T >
 Alias for the vector type with a different element type
 
- Public 类型 继承自 xcmath::vec< _Tp, 4 >
using ItemType = _Tp
 Type of elements in the vector
 
using DataType = typename VecInfo< ItemType >::DataType
 Type of data stored in the vector
 
using SubVec = __subVecHelper< size_t, __len, __lens... >::Type
 
using Self = vec< _T, _length >
 

Public 成员函数

 quaternion ()=default
 
 quaternion (_Tp r, _Tp i, _Tp j, _Tp k)
 
template<typename _OTp >
requires (std::is_convertible_v<ItemType, _OTp>)
constexpr operator Self< _OTp > () const
 
template<class _T >
requires std::is_convertible_v<_T, _Tp>
constexpr quaternion (const _T &r)
 Construct a quaternion from a scalar
 
template<class _T >
requires std::is_arithmetic_v<_Tp>
constexpr quaternion (const vec3< _Tp > &axis, const _T &angle)
 Construct a quaternion from an axis and angle
 
constexpr quaternion< _Tp > operator* (const quaternion< _Tp > &other) const
 Quaternion multiplication operator
 
constexpr quaternion< _Tp > operator/ (const quaternion< _Tp > &other) const
 Quaternion division operator
 
constexpr _Tp norm () const
 Compute norm of the quaternion
 
constexpr vec3< _Tp > v ()
 Get vector part of the quaternion
 
constexpr quaternion< _Tp > inverse ()
 Compute inverse of the quaternion
 
constexpr mat< _Tp, 3, 3 > to_mat () const
 Convert quaternion to rotation matrix
 
constexpr _Tp & r ()
 Get scalar part of the quaternion
 
constexpr _Tp & i ()
 Get i-component of the quaternion
 
constexpr _Tp & j ()
 Get j-component of the quaternion
 
constexpr _Tp & k ()
 Get k-component of the quaternion
 
constexpr const _Tp & r () const
 Get scalar part of the quaternion (const version)
 
constexpr const _Tp & i () const
 Get i-component of the quaternion (const version)
 
constexpr const _Tp & j () const
 Get j-component of the quaternion (const version)
 
constexpr const _Tp & k () const
 Get k-component of the quaternion (const version)
 
template<class _ItemType >
requires (!std::is_same_v<_ItemType, Self<_Tp>>)
auto operator+ (const _ItemType &other)
 Quaternion addition operator with scalar on the right
 
template<class _ItemType >
requires (!std::is_same_v<_ItemType, Self<_Tp>>)
auto operator- (const _ItemType &other)
 Quaternion subtraction operator with scalar on the right
 
template<class _ItemType >
auto operator- (const Self< _ItemType > &other)
 
template<class _ItemType >
auto operator+ (const Self< _ItemType > &other)
 
- Public 成员函数 继承自 xcmath::vec< _Tp, 4 >
constexpr vec ()
 Construct a zero-initialized vector Notw: _Tp must be default constructible
 
constexpr vec (const _Tp1 &arg1, const _T &... args)
 Construct from component values
 
constexpr vec (const _Args &... args)
 Construct from mixed scalars and vectors
 
constexpr vec (const T &fill_value)
 Uniform value constructor
 
constexpr vec (const vec< _Tp, _length > &other)
 Copy constructor
 
constexpr vec (vec< _Tp, _length > &&o)
 Move constructor
 
constexpr vec (const std::initializer_list< ItemType > &list)
 
constexpr const _Tp * begin () const
 Get pointer to the beginning of the data array
 
constexpr const _Tp * end () const
 Get pointer to the end of the data array
 
constexpr _Tp & operator[] (size_t index)
 Access element at specified index
 
constexpr const _Tp & operator[] (size_t index) const
 Access element at specified index (const version)
 
constexpr vec< _Tp, _length > & operator= (const vec< _Tp, _length > &o)
 Copy assignment operator
 
constexpr vec< _Tp, _length > & operator= (vec< _Tp, _length > &&o)
 Move assignment operator
 
constexpr SubVec< sizeof...(idx),(_Ss::length,...)> operator() (Slice< idx... >, _Ss... ns) const
 qualified operator() for slicing and swizzling
 
constexpr vec< ItemType, sizeof...(idx)> operator() (Slice< idx... > s) const
 qualified operator() for slicing and swizzling (const version)
 
constexpr _Tp & x ()
 Get the item at index 0
 
constexpr const _Tp & x () const
 Get the item at index 0 (const version)
 
constexpr _Tp & y ()
 Get the item at index 1
 
constexpr const _Tp & y () const
 Get the item at index 1 (const version)
 
constexpr _Tp & z ()
 Get the item at index 2
 
constexpr const _Tp & z () const
 Get the item at index 2 (const version)
 
constexpr _Tp & w ()
 Get the item at index 3
 
constexpr const _Tp & w () const
 Get the item at index 3 (const version)
 
constexpr const vec< _Tp, 2 > & xy () const
 
constexpr vec< _Tp, 2 > & xy ()
 
constexpr const vec< _Tp, 2 > & yz () const
 
constexpr vec< _Tp, 2 > & yz ()
 
constexpr const vec< _Tp, 2 > & zw () const
 
constexpr vec< _Tp, 2 > & zw ()
 
constexpr const vec< _Tp, 3 > & xyz () const
 
constexpr vec< _Tp, 3 > & xyz ()
 
constexpr const vec< _Tp, 3 > & yzw () const
 
constexpr vec< _Tp, 3 > & yzw ()
 
constexpr vec< _Tp, 2 > xz () const
 
constexpr vec< _Tp, 2 > xw () const
 
constexpr vec< _Tp, 2 > yw () const
 
constexpr vec< _Tp, _length > cross (const vec< _Tp, _length > &other) const
 Compute 3D cross product
 
constexpr _Tp dot (const vec< _Tp, _length > &other) const
 Compute Euclidean inner product
 
constexpr vec< _Tp, _length > normalize () const
 Create unit vector in same direction
 
constexpr _Tp distance (const vec< _Tp, _length > &other) const
 Compute distance to another vector
 
constexpr _Tp mod () const
 Calculate Euclidean norm (magnitude)
 
constexpr _Tp angle (const vec< _Tp, _length > &other) const
 Compute angle with another vector
 
constexpr bool any () const
 Check if any element satisfies a condition
 
constexpr bool every () const
 Check if all elements satisfy a condition
 
constexpr bool all () const
 Check universal quantification of components
 
constexpr operator Self< _OTp > () const
 
auto operator- () const
 Component-wise additive inverse
 
auto operator+ () const
 Unary plus operator
 
auto operator-- ()
 Pre-decrement operator
 
auto & operator-- (int)
 Post-decrement operator
 
auto operator++ ()
 Pre-increment operator
 
auto & operator++ (int)
 Post-increment operator
 

静态 Public 成员函数

static constexpr quaternion< _Tp > from_mat (const mat< _Tp, 3, 3 > &mat)
 Create quaternion from rotation matrix
 

静态 Public 属性

static constexpr auto datatype = TypeName<DataType>
 Name of the data type
 
static constexpr auto itemtype = TypeName<ItemType>
 Name of the item type
 
static constexpr auto length = 4
 Length of the vector
 
- 静态 Public 属性 继承自 xcmath::vec< _Tp, 4 >
static constexpr size_t dim
 
static constexpr auto datatype
 Name of the data type
 
static constexpr auto itemtype
 Name of the item type
 
static constexpr auto length
 Length of the vector
 

额外继承的成员函数

- Protected 属性 继承自 xcmath::vec< _Tp, 4 >
_Tp data [_length]
 Component storage array
 

详细描述

template<typename _Tp>
class xcmath::quaternion< _Tp >

Quaternion class template

模板参数
TType of elements in the quaternion

在文件 quaternion.hpp27 行定义.

成员类型定义说明

◆ DataType

template<typename _Tp >
using xcmath::quaternion< _Tp >::DataType = VecInfo<ItemType>::DataType

Type of data stored in the vector

在文件 quaternion.hpp37 行定义.

◆ ItemType

template<typename _Tp >
using xcmath::quaternion< _Tp >::ItemType = _Tp

Type of elements in the vector

在文件 quaternion.hpp32 行定义.

◆ Self

template<typename _Tp >
template<class _T >
using xcmath::quaternion< _Tp >::Self = quaternion<_T>

Alias for the vector type with a different element type

模板参数
_TType of elements for the new vector

在文件 quaternion.hpp45 行定义.

构造及析构函数说明

◆ quaternion() [1/4]

template<typename _Tp >
xcmath::quaternion< _Tp >::quaternion ( )
default

◆ quaternion() [2/4]

template<typename _Tp >
xcmath::quaternion< _Tp >::quaternion ( _Tp  r,
_Tp  i,
_Tp  j,
_Tp  k 
)
inline

◆ quaternion() [3/4]

template<typename _Tp >
template<class _T >
requires std::is_convertible_v<_T, _Tp>
constexpr xcmath::quaternion< _Tp >::quaternion ( const _T &  r)
inlineconstexpr

Construct a quaternion from a scalar

模板参数
_TpType of the scalar
参数
rScalar value

在文件 quaternion.hpp99 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().

◆ quaternion() [4/4]

template<typename _Tp >
template<class _T >
requires std::is_arithmetic_v<_Tp>
constexpr xcmath::quaternion< _Tp >::quaternion ( const vec3< _Tp > &  axis,
const _T &  angle 
)
inlineconstexpr

Construct a quaternion from an axis and angle

模板参数
_TpType of elements in the axis vector
参数
axisAxis of rotation
angleAngle of rotation

在文件 quaternion.hpp115 行定义.

引用了 xcmath::vec< _Tp, 4 >::angle(), xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k(), xcmath::quaternion< _Tp >::r(), xcmath::vec< _Tp, _length >::x(), xcmath::vec< _Tp, _length >::y() , 以及 xcmath::vec< _Tp, _length >::z().

成员函数说明

◆ from_mat()

template<typename _Tp >
constexpr quaternion< T > xcmath::quaternion< T >::from_mat ( const mat< _Tp, 3, 3 > &  mat)
staticconstexpr

Create quaternion from rotation matrix

参数
matRotation matrix
返回
Quaternion
模板参数
TType of elements in the quaternion
参数
matRotation matrix
返回
Quaternion

在文件 quaternion.hpp397 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().

被这些函数引用 TEST().

◆ i() [1/2]

template<typename _Tp >
constexpr _Tp & xcmath::quaternion< _Tp >::i ( )
inlineconstexpr

◆ i() [2/2]

template<typename _Tp >
constexpr const _Tp & xcmath::quaternion< _Tp >::i ( ) const
inlineconstexpr

Get i-component of the quaternion (const version)

返回
i-component

在文件 quaternion.hpp255 行定义.

引用了 xcmath::vec< _Tp, 4 >::data.

◆ inverse()

template<typename _Tp >
constexpr quaternion< _Tp > xcmath::quaternion< _Tp >::inverse ( )
inlineconstexpr

Compute inverse of the quaternion

返回
Inverse quaternion

在文件 quaternion.hpp188 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k(), xcmath::quaternion< _Tp >::norm() , 以及 xcmath::quaternion< _Tp >::r().

被这些函数引用 TEST().

◆ j() [1/2]

template<typename _Tp >
constexpr _Tp & xcmath::quaternion< _Tp >::j ( )
inlineconstexpr

◆ j() [2/2]

template<typename _Tp >
constexpr const _Tp & xcmath::quaternion< _Tp >::j ( ) const
inlineconstexpr

Get j-component of the quaternion (const version)

返回
j-component

在文件 quaternion.hpp262 行定义.

引用了 xcmath::vec< _Tp, 4 >::data.

◆ k() [1/2]

template<typename _Tp >
constexpr _Tp & xcmath::quaternion< _Tp >::k ( )
inlineconstexpr

◆ k() [2/2]

template<typename _Tp >
constexpr const _Tp & xcmath::quaternion< _Tp >::k ( ) const
inlineconstexpr

Get k-component of the quaternion (const version)

返回
k-component

在文件 quaternion.hpp269 行定义.

引用了 xcmath::vec< _Tp, 4 >::data.

◆ norm()

template<typename _Tp >
constexpr _Tp xcmath::quaternion< _Tp >::norm ( ) const
inlineconstexpr

◆ operator Self< _OTp >()

template<typename _Tp >
template<typename _OTp >
requires (std::is_convertible_v<ItemType, _OTp>)
constexpr xcmath::quaternion< _Tp >::operator Self< _OTp > ( ) const
inlineconstexpr

◆ operator*()

template<typename _Tp >
constexpr quaternion< _Tp > xcmath::quaternion< _Tp >::operator* ( const quaternion< _Tp > &  other) const
inlineconstexpr

Quaternion multiplication operator

参数
otherQuaternion to multiply with
返回
Resulting quaternion

在文件 quaternion.hpp130 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().

◆ operator+() [1/2]

template<typename _Tp >
template<class _ItemType >
requires (!std::is_same_v<_ItemType, Self<_Tp>>)
auto xcmath::quaternion< _Tp >::operator+ ( const _ItemType &  other)
inline

Quaternion addition operator with scalar on the right

模板参数
_ItemTypeType of elements in the quaternion
参数
vQuaternion to add
otherScalar value
返回
Resulting quaternion

在文件 quaternion.hpp281 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().

◆ operator+() [2/2]

template<typename _Tp >
template<class _ItemType >
auto xcmath::quaternion< _Tp >::operator+ ( const Self< _ItemType > &  other)
inline

◆ operator-() [1/2]

template<typename _Tp >
template<class _ItemType >
requires (!std::is_same_v<_ItemType, Self<_Tp>>)
auto xcmath::quaternion< _Tp >::operator- ( const _ItemType &  other)
inline

Quaternion subtraction operator with scalar on the right

模板参数
_ItemTypeType of elements in the quaternion
参数
vQuaternion to subtract
otherScalar value
返回
Resulting quaternion

在文件 quaternion.hpp300 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().

◆ operator-() [2/2]

template<typename _Tp >
template<class _ItemType >
auto xcmath::quaternion< _Tp >::operator- ( const Self< _ItemType > &  other)
inline

◆ operator/()

template<typename _Tp >
constexpr quaternion< _Tp > xcmath::quaternion< _Tp >::operator/ ( const quaternion< _Tp > &  other) const
inlineconstexpr

Quaternion division operator

参数
otherQuaternion to divide by
返回
Resulting quaternion

在文件 quaternion.hpp149 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k(), xcmath::quaternion< _Tp >::norm() , 以及 xcmath::quaternion< _Tp >::r().

◆ r() [1/2]

template<typename _Tp >
constexpr _Tp & xcmath::quaternion< _Tp >::r ( )
inlineconstexpr

◆ r() [2/2]

template<typename _Tp >
constexpr const _Tp & xcmath::quaternion< _Tp >::r ( ) const
inlineconstexpr

Get scalar part of the quaternion (const version)

返回
Scalar part

在文件 quaternion.hpp248 行定义.

引用了 xcmath::vec< _Tp, 4 >::data.

◆ to_mat()

template<typename T >
constexpr mat< T, 3, 3 > xcmath::quaternion< T >::to_mat ( ) const
constexpr

Convert quaternion to rotation matrix

返回
Rotation matrix
模板参数
TType of elements in the quaternion
返回
Rotation matrix

在文件 quaternion.hpp375 行定义.

被这些函数引用 TEST().

◆ v()

template<typename _Tp >
constexpr vec3< _Tp > xcmath::quaternion< _Tp >::v ( )
inlineconstexpr

Get vector part of the quaternion

返回
Vector part as vec3<_Tp>

在文件 quaternion.hpp181 行定义.

引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j() , 以及 xcmath::quaternion< _Tp >::k().

类成员变量说明

◆ datatype

template<typename _Tp >
constexpr auto xcmath::quaternion< _Tp >::datatype = TypeName<DataType>
staticconstexpr

Name of the data type

在文件 quaternion.hpp50 行定义.

◆ itemtype

template<typename _Tp >
constexpr auto xcmath::quaternion< _Tp >::itemtype = TypeName<ItemType>
staticconstexpr

Name of the item type

在文件 quaternion.hpp55 行定义.

◆ length

template<typename _Tp >
constexpr auto xcmath::quaternion< _Tp >::length = 4
staticconstexpr

Length of the vector

在文件 quaternion.hpp60 行定义.


该类的文档由以下文件生成: