xcal
基于 C++23 的现代图形渲染引擎
|
Quaternion class template 更多...
#include <quaternion.hpp>
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 | |
![]() | |
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) |
![]() | |
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 | |
![]() | |
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 | |
额外继承的成员函数 | |
![]() | |
_Tp | data [_length] |
Component storage array | |
Quaternion class template
T | Type of elements in the quaternion |
在文件 quaternion.hpp 第 27 行定义.
using xcmath::quaternion< _Tp >::DataType = VecInfo<ItemType>::DataType |
Type of data stored in the vector
在文件 quaternion.hpp 第 37 行定义.
using xcmath::quaternion< _Tp >::ItemType = _Tp |
Type of elements in the vector
在文件 quaternion.hpp 第 32 行定义.
Alias for the vector type with a different element type
_T | Type of elements for the new vector |
在文件 quaternion.hpp 第 45 行定义.
|
default |
|
inline |
|
inlineconstexpr |
Construct a quaternion from a scalar
_Tp | Type of the scalar |
r | Scalar value |
在文件 quaternion.hpp 第 99 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().
|
inlineconstexpr |
Construct a quaternion from an axis and angle
_Tp | Type of elements in the axis vector |
axis | Axis of rotation |
angle | Angle of rotation |
在文件 quaternion.hpp 第 115 行定义.
引用了 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().
|
staticconstexpr |
Create quaternion from rotation matrix
mat | Rotation matrix |
T | Type of elements in the quaternion |
mat | Rotation matrix |
在文件 quaternion.hpp 第 397 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().
被这些函数引用 TEST().
|
inlineconstexpr |
Get i-component of the quaternion
在文件 quaternion.hpp 第 227 行定义.
引用了 xcmath::vec< _Tp, 4 >::data.
被这些函数引用 xcmath::quaternion< _Tp >::from_mat(), xcmath::quaternion< _Tp >::inverse(), xcmath::quaternion< _Tp >::norm(), xcmath::quaternion< _Tp >::operator Self< _OTp >(), xcmath::quaternion< _Tp >::operator*(), xcmath::quaternion< _Tp >::operator+(), xcmath::operator+(), xcmath::quaternion< _Tp >::operator+(), xcmath::quaternion< _Tp >::operator-(), xcmath::operator-(), xcmath::quaternion< _Tp >::operator-(), xcmath::quaternion< _Tp >::operator/(), xcmath::operator<<(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), TEST(), TEST(), TEST(), TEST(), TEST() , 以及 xcmath::quaternion< _Tp >::v().
|
inlineconstexpr |
|
inlineconstexpr |
Compute inverse of the quaternion
在文件 quaternion.hpp 第 188 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k(), xcmath::quaternion< _Tp >::norm() , 以及 xcmath::quaternion< _Tp >::r().
被这些函数引用 TEST().
|
inlineconstexpr |
Get j-component of the quaternion
在文件 quaternion.hpp 第 234 行定义.
引用了 xcmath::vec< _Tp, 4 >::data.
被这些函数引用 xcmath::quaternion< _Tp >::from_mat(), xcmath::quaternion< _Tp >::inverse(), xcmath::quaternion< _Tp >::norm(), xcmath::quaternion< _Tp >::operator Self< _OTp >(), xcmath::quaternion< _Tp >::operator*(), xcmath::quaternion< _Tp >::operator+(), xcmath::operator+(), xcmath::quaternion< _Tp >::operator+(), xcmath::quaternion< _Tp >::operator-(), xcmath::operator-(), xcmath::quaternion< _Tp >::operator-(), xcmath::quaternion< _Tp >::operator/(), xcmath::operator<<(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), TEST(), TEST(), TEST(), TEST(), TEST() , 以及 xcmath::quaternion< _Tp >::v().
|
inlineconstexpr |
|
inlineconstexpr |
Get k-component of the quaternion
在文件 quaternion.hpp 第 241 行定义.
引用了 xcmath::vec< _Tp, 4 >::data.
被这些函数引用 xcmath::quaternion< _Tp >::from_mat(), xcmath::quaternion< _Tp >::inverse(), xcmath::quaternion< _Tp >::norm(), xcmath::quaternion< _Tp >::operator Self< _OTp >(), xcmath::quaternion< _Tp >::operator*(), xcmath::quaternion< _Tp >::operator+(), xcmath::operator+(), xcmath::quaternion< _Tp >::operator+(), xcmath::quaternion< _Tp >::operator-(), xcmath::operator-(), xcmath::quaternion< _Tp >::operator-(), xcmath::quaternion< _Tp >::operator/(), xcmath::operator<<(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), TEST(), TEST(), TEST(), TEST(), TEST() , 以及 xcmath::quaternion< _Tp >::v().
|
inlineconstexpr |
|
inlineconstexpr |
Compute norm of the quaternion
在文件 quaternion.hpp 第 172 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().
被这些函数引用 xcmath::quaternion< _Tp >::inverse(), xcmath::quaternion< _Tp >::operator/(), TEST() , 以及 TEST().
|
inlineconstexpr |
|
inlineconstexpr |
Quaternion multiplication operator
other | Quaternion to multiply with |
在文件 quaternion.hpp 第 130 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().
|
inline |
Quaternion addition operator with scalar on the right
_ItemType | Type of elements in the quaternion |
v | Quaternion to add |
other | Scalar value |
在文件 quaternion.hpp 第 281 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().
|
inline |
|
inline |
Quaternion subtraction operator with scalar on the right
_ItemType | Type of elements in the quaternion |
v | Quaternion to subtract |
other | Scalar value |
在文件 quaternion.hpp 第 300 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k() , 以及 xcmath::quaternion< _Tp >::r().
|
inline |
|
inlineconstexpr |
Quaternion division operator
other | Quaternion to divide by |
在文件 quaternion.hpp 第 149 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j(), xcmath::quaternion< _Tp >::k(), xcmath::quaternion< _Tp >::norm() , 以及 xcmath::quaternion< _Tp >::r().
|
inlineconstexpr |
Get scalar part of the quaternion
在文件 quaternion.hpp 第 220 行定义.
引用了 xcmath::vec< _Tp, 4 >::data.
被这些函数引用 xcmath::quaternion< _Tp >::from_mat(), xcmath::quaternion< _Tp >::inverse(), xcmath::quaternion< _Tp >::norm(), xcmath::quaternion< _Tp >::operator Self< _OTp >(), xcmath::quaternion< _Tp >::operator*(), xcmath::quaternion< _Tp >::operator+(), xcmath::operator+(), xcmath::quaternion< _Tp >::operator+(), xcmath::quaternion< _Tp >::operator-(), xcmath::operator-(), xcmath::quaternion< _Tp >::operator-(), xcmath::quaternion< _Tp >::operator/(), xcmath::operator<<(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), xcmath::quaternion< _Tp >::quaternion(), TEST(), TEST(), TEST(), TEST() , 以及 TEST().
|
inlineconstexpr |
|
constexpr |
Convert quaternion to rotation matrix
T | Type of elements in the quaternion |
在文件 quaternion.hpp 第 375 行定义.
被这些函数引用 TEST().
|
inlineconstexpr |
Get vector part of the quaternion
在文件 quaternion.hpp 第 181 行定义.
引用了 xcmath::quaternion< _Tp >::i(), xcmath::quaternion< _Tp >::j() , 以及 xcmath::quaternion< _Tp >::k().
|
staticconstexpr |
Name of the data type
在文件 quaternion.hpp 第 50 行定义.
|
staticconstexpr |
Name of the item type
在文件 quaternion.hpp 第 55 行定义.
|
staticconstexpr |
Length of the vector
在文件 quaternion.hpp 第 60 行定义.