![]() |
Scanframe Modular Application 0.1.0
|
Generic type Quaternion. More...
#include <TQuaternion.h>
Classes | |
union | data_type |
Storage union of the 3D coordinate making the x,y,z,w accessible as an array. More... | |
Public Types | |
enum | EElement : size_t { realW = 0 , imagX = 1 , imagY = 2 , imagZ = 3 } |
Enumerate for identifying a matrix axis. More... | |
typedef T | value_type |
Type declaration of the coordinate storage values. | |
Public Member Functions | |
TQuaternion ()=default | |
Default Constructor. | |
TQuaternion (const TQuaternion &) | |
Copy Constructor. | |
TQuaternion (T real, const TVector3D< T > &imag) | |
Initializing constructor is used in operators and sets the member variables directly. | |
TQuaternion (const TVector3D< T > &axis, T angle) | |
Constructor for creating rotations by specifying the angle of rotation and the axis around which to rotate, this axis does not have to be normalized. | |
TQuaternion (T real_w, T imag_x, T imag_y, T imag_z) | |
Initializing constructor for 4 element parts. | |
TQuaternion & | assign (T real_w, T imag_x, T imag_y, T imag_z) |
Assigns of another instance elements. | |
TQuaternion & | assign (const TQuaternion &) |
Assigns of another instance elements. | |
TQuaternion & | operator= (const TQuaternion &) |
Assignment operator. | |
T & | operator[] (size_t) |
Array access operator. | |
const T & | operator[] (size_t) const |
Array access const operator to the elements. | |
T | real () const |
Gets the real part of this instance. | |
T & | real () |
Gets the real part reference of this instance. | |
TVector3D< T > | imaginary () const |
Get the imaginary part as a 3D-vector. | |
T | w () const |
Gets the w or real part of this instance. Same as real() method. | |
T & | w () |
Gets the w or real part reference of this instance. Same as real() method. | |
T | x () const |
Get the imaginary X-part of this instance. | |
T & | x () |
Get the imaginary X-part reference of this instance. | |
T | y () const |
Get the imaginary Y-part of this instance. | |
T & | y () |
Get the imaginary Y-part reference of this instance. | |
T | z () const |
Get the imaginary Z-part of this instance. | |
T & | z () |
Get the imaginary Z-part reference of this instance. | |
TQuaternion | conjugate () const |
Gets a copy of this instance where the imaginary (vector) part of a quaternion is negated. The conjugate of a quaternion is a simple operation that reflects the imaginary components of the quaternion while leaving the real component unchanged. It is often used in quaternion operations such as finding the inverse or performing transformations. | |
TQuaternion | inverse () const |
Gets the inverse of the current instance. The inverse of a quaternion is a quaternion that "reverses" the effect of the original quaternion when combined through quaternion multiplication. For unit quaternions, the inverse undoes the rotation described by the quaternion. This property is analogous to the inverse of a matrix or a number. | |
TQuaternion & | invert () |
Turns this instance into it inverse. | |
TQuaternion & | normalize () |
Normalizes this instance. | |
TQuaternion | normalized () const |
Get a normalizes copy of this instance. | |
T | magnitudeSqr () const |
Gets the squared magnitude which is used in computations and the magnitude() method for the actual magnitude. | |
T | magnitude () const |
Gets the magnitude of this quaternion. The magnitude (or norm) of a quaternion q=a+bi+cj+dk, where a, b, c, and d are real numbers, is calculated similarly to the magnitude of a 4-dimensional vector. All element values squared and added together. | |
TMatrix44< T > | toMatrix (TMatrix44< T > &) const |
Sets the orientation part of the passed TMatrix instance. | |
TMatrix44< T > | toMatrix () const |
Get the matrix having only the orientation part set using this instance normalized version. Before the matrix is calculated the quaternion is normalized. | |
TQuaternion & | fromMatrix (const T[4][4]) |
Transforms a rotation matrix to this Quaternion. Throws an exception when the passed matrix is not a rotation matrix. | |
TVector3D< T > | transform (TVector3D< T > v) const |
Transforms a 3D-vector not using the quaternion directly instead of a matrix. | |
TQuaternion | operator- () const |
Negation operator. | |
TQuaternion & | operator+= (const TQuaternion &) |
Addition assignment operator. | |
TQuaternion & | operator-= (const TQuaternion &) |
Subtraction assignment operator. | |
TQuaternion & | operator*= (const TQuaternion &) |
Multiplication assignment operator. | |
TQuaternion & | operator/= (const TQuaternion &) |
Division assignment operator. | |
TQuaternion & | operator^= (const TQuaternion &) |
operator. | |
TQuaternion & | operator*= (T c) |
Multiplication assignment operator. | |
TQuaternion & | operator/= (T c) |
Division operator. | |
TQuaternion | operator* (T) const |
Pointer cast operator. | |
TQuaternion | operator/ (T) const |
operator. | |
bool | isEqual (const TQuaternion &quat, T tol=tolerance) const |
Compares the passed quaternion within the set tolerance. | |
bool | operator== (const TQuaternion &) const |
operator. | |
bool | operator!= (const TQuaternion &) const |
operator. | |
TQuaternion | squared () const |
Squares this instance. If the quaternion is a unit quaternion (meaning it has magnitude 1), squaring it produces another quaternion with the same magnitude. When a unit quaternion represents a rotation, squaring the quaternion effectively doubles the rotation angle while keeping the axis the same. | |
TQuaternion | log () const |
Gets the logarithm form of this instance. The logarithm log(q) of a quaternion is a mathematical operation that maps the quaternion from its rotational form to a form that can be linearly interpolated in logarithmic space. This is particularly useful for spherical blending or spline interpolation of rotations, where transformations are more natural in logarithmic form. To move back from the logarithmic form to a quaternion, use the quaternion exponential exp(), which reconstructs the quaternion from its angle-axis form. By converting a quaternion to its logarithmic form, it allows linearly interpolate between two rotations. This is helpful in spline-based interpolation techniques for smooth rotational blending. Before the logarithm is calculated the quaternion is normalized and result is scaled back accordingly. | |
TQuaternion | exp () const |
Gets the exponential of a quaternion which is the inverse of log(). Moves back from the logarithmic form to a quaternion, which reconstructs the quaternion from its angle-axis form. | |
TQuaternion | interpolate (const TQuaternion &q, T t) const |
Spherical Linear Interpolation (SLERP) function. Used to smoothly blending or transitioning between two quaternions, typically representing rotations in 3D space. Interpolation is used in animation that require smooth rotational transitions, as it avoids issues like gimbal lock and provides a smooth, natural path between orientations. | |
TQuaternion | interpolateLogarithmic (const TQuaternion &q, T t) const |
Implements a logarithmic interpolation function. | |
std::string | toString () const |
Gets the string representation of the quaternion formed like '(x,y,z,r)'. | |
TQuaternion & | fromString (const std::string &s) noexcept(false) |
Gets the quaternion values from the string representation formed like '(1,2,3,4)'. Throws an exception when the string is not in the correct format. | |
Static Public Attributes | |
static constexpr auto | tolerance = TVector3D<T>::tolerance |
Tolerance for when comparing in the equal operator. | |
Protected Attributes | |
union sf::TQuaternion::data_type | _data |
Generic type Quaternion.
typedef T sf::TQuaternion< T >::value_type |
Type declaration of the coordinate storage values.
enum sf::TQuaternion::EElement : size_t |
|
default |
Default Constructor.
sf::TQuaternion< T >::TQuaternion | ( | const TQuaternion< T > & | ) |
Copy Constructor.
sf::TQuaternion< T >::TQuaternion | ( | T | real, |
const TVector3D< T > & | imag | ||
) |
Initializing constructor is used in operators and sets the member variables directly.
sf::TQuaternion< T >::TQuaternion | ( | const TVector3D< T > & | axis, |
T | angle | ||
) |
Constructor for creating rotations by specifying the angle of rotation and the axis around which to rotate, this axis does not have to be normalized.
sf::TQuaternion< T >::TQuaternion | ( | T | real_w, |
T | imag_x, | ||
T | imag_y, | ||
T | imag_z | ||
) |
Initializing constructor for 4 element parts.
TQuaternion & sf::TQuaternion< T >::assign | ( | const TQuaternion< T > & | ) |
Assigns of another instance elements.
TQuaternion & sf::TQuaternion< T >::assign | ( | T | real_w, |
T | imag_x, | ||
T | imag_y, | ||
T | imag_z | ||
) |
Assigns of another instance elements.
TQuaternion sf::TQuaternion< T >::conjugate | ( | ) | const |
Gets a copy of this instance where the imaginary (vector) part of a quaternion is negated. The conjugate of a quaternion is a simple operation that reflects the imaginary components of the quaternion while leaving the real component unchanged. It is often used in quaternion operations such as finding the inverse or performing transformations.
TQuaternion sf::TQuaternion< T >::exp | ( | ) | const |
Gets the exponential of a quaternion which is the inverse of log(). Moves back from the logarithmic form to a quaternion, which reconstructs the quaternion from its angle-axis form.
TQuaternion & sf::TQuaternion< T >::fromMatrix | ( | const T | [4][4] | ) |
Transforms a rotation matrix to this Quaternion. Throws an exception when the passed matrix is not a rotation matrix.
std::invalid_argument |
TQuaternion & sf::TQuaternion< T >::fromString | ( | const std::string & | s | ) |
Gets the quaternion values from the string representation formed like '(1,2,3,4)'. Throws an exception when the string is not in the correct format.
std::invalid_argument |
TVector3D< T > sf::TQuaternion< T >::imaginary | ( | ) | const |
Get the imaginary part as a 3D-vector.
TQuaternion sf::TQuaternion< T >::interpolate | ( | const TQuaternion< T > & | q, |
T | t | ||
) | const |
Spherical Linear Interpolation (SLERP) function. Used to smoothly blending or transitioning between two quaternions, typically representing rotations in 3D space. Interpolation is used in animation that require smooth rotational transitions, as it avoids issues like gimbal lock and provides a smooth, natural path between orientations.
q | Quaternion to transition to. |
t | Transition ranges from 0 to 1. |
TQuaternion sf::TQuaternion< T >::interpolateLogarithmic | ( | const TQuaternion< T > & | q, |
T | t | ||
) | const |
Implements a logarithmic interpolation function.
q | Targeted quaternion value. |
t | Value from 0.0 to 1.0 |
TQuaternion sf::TQuaternion< T >::inverse | ( | ) | const |
Gets the inverse of the current instance. The inverse of a quaternion is a quaternion that "reverses" the effect of the original quaternion when combined through quaternion multiplication. For unit quaternions, the inverse undoes the rotation described by the quaternion. This property is analogous to the inverse of a matrix or a number.
TQuaternion & sf::TQuaternion< T >::invert | ( | ) |
Turns this instance into it inverse.
bool sf::TQuaternion< T >::isEqual | ( | const TQuaternion< T > & | quat, |
T | tol = tolerance |
||
) | const |
Compares the passed quaternion within the set tolerance.
quat | Vector to compare with. |
tol | The tolerance when comparing which has a default. |
TQuaternion sf::TQuaternion< T >::log | ( | ) | const |
Gets the logarithm form of this instance. The logarithm log(q) of a quaternion is a mathematical operation that maps the quaternion from its rotational form to a form that can be linearly interpolated in logarithmic space. This is particularly useful for spherical blending or spline interpolation of rotations, where transformations are more natural in logarithmic form. To move back from the logarithmic form to a quaternion, use the quaternion exponential exp(), which reconstructs the quaternion from its angle-axis form. By converting a quaternion to its logarithmic form, it allows linearly interpolate between two rotations. This is helpful in spline-based interpolation techniques for smooth rotational blending. Before the logarithm is calculated the quaternion is normalized and result is scaled back accordingly.
T sf::TQuaternion< T >::magnitude | ( | ) | const |
Gets the magnitude of this quaternion. The magnitude (or norm) of a quaternion q=a+bi+cj+dk, where a, b, c, and d are real numbers, is calculated similarly to the magnitude of a 4-dimensional vector. All element values squared and added together.
T sf::TQuaternion< T >::magnitudeSqr | ( | ) | const |
Gets the squared magnitude which is used in computations and the magnitude() method for the actual magnitude.
TQuaternion & sf::TQuaternion< T >::normalize | ( | ) |
Normalizes this instance.
TQuaternion sf::TQuaternion< T >::normalized | ( | ) | const |
Get a normalizes copy of this instance.
bool sf::TQuaternion< T >::operator!= | ( | const TQuaternion< T > & | ) | const |
operator.
TQuaternion sf::TQuaternion< T >::operator* | ( | T | ) | const |
Pointer cast operator.
TQuaternion & sf::TQuaternion< T >::operator*= | ( | const TQuaternion< T > & | ) |
Multiplication assignment operator.
TQuaternion & sf::TQuaternion< T >::operator*= | ( | T | c | ) |
Multiplication assignment operator.
TQuaternion & sf::TQuaternion< T >::operator+= | ( | const TQuaternion< T > & | ) |
Addition assignment operator.
TQuaternion sf::TQuaternion< T >::operator- | ( | ) | const |
Negation operator.
TQuaternion & sf::TQuaternion< T >::operator-= | ( | const TQuaternion< T > & | ) |
Subtraction assignment operator.
TQuaternion sf::TQuaternion< T >::operator/ | ( | T | ) | const |
operator.
TQuaternion & sf::TQuaternion< T >::operator/= | ( | const TQuaternion< T > & | ) |
Division assignment operator.
TQuaternion & sf::TQuaternion< T >::operator/= | ( | T | c | ) |
Division operator.
TQuaternion & sf::TQuaternion< T >::operator= | ( | const TQuaternion< T > & | ) |
Assignment operator.
bool sf::TQuaternion< T >::operator== | ( | const TQuaternion< T > & | ) | const |
operator.
T & sf::TQuaternion< T >::operator[] | ( | size_t | ) |
Array access operator.
std::out_of_range |
const T & sf::TQuaternion< T >::operator[] | ( | size_t | ) | const |
Array access const operator to the elements.
std::out_of_range |
TQuaternion & sf::TQuaternion< T >::operator^= | ( | const TQuaternion< T > & | ) |
operator.
T & sf::TQuaternion< T >::real | ( | ) |
Gets the real part reference of this instance.
T sf::TQuaternion< T >::real | ( | ) | const |
Gets the real part of this instance.
TQuaternion sf::TQuaternion< T >::squared | ( | ) | const |
Squares this instance. If the quaternion is a unit quaternion (meaning it has magnitude 1), squaring it produces another quaternion with the same magnitude. When a unit quaternion represents a rotation, squaring the quaternion effectively doubles the rotation angle while keeping the axis the same.
TMatrix44< T > sf::TQuaternion< T >::toMatrix | ( | ) | const |
Get the matrix having only the orientation part set using this instance normalized version. Before the matrix is calculated the quaternion is normalized.
TMatrix44< T > sf::TQuaternion< T >::toMatrix | ( | TMatrix44< T > & | ) | const |
Sets the orientation part of the passed TMatrix instance.
std::string sf::TQuaternion< T >::toString | ( | ) | const |
Gets the string representation of the quaternion formed like '(x,y,z,r)'.
TVector3D< T > sf::TQuaternion< T >::transform | ( | TVector3D< T > | v | ) | const |
Transforms a 3D-vector not using the quaternion directly instead of a matrix.
T & sf::TQuaternion< T >::w | ( | ) |
Gets the w or real part reference of this instance. Same as real() method.
T sf::TQuaternion< T >::w | ( | ) | const |
Gets the w or real part of this instance. Same as real() method.
T & sf::TQuaternion< T >::x | ( | ) |
Get the imaginary X-part reference of this instance.
T sf::TQuaternion< T >::x | ( | ) | const |
Get the imaginary X-part of this instance.
T & sf::TQuaternion< T >::y | ( | ) |
Get the imaginary Y-part reference of this instance.
T sf::TQuaternion< T >::y | ( | ) | const |
Get the imaginary Y-part of this instance.
T & sf::TQuaternion< T >::z | ( | ) |
Get the imaginary Z-part reference of this instance.
T sf::TQuaternion< T >::z | ( | ) | const |
Get the imaginary Z-part of this instance.
|
protected |
|
staticconstexpr |
Tolerance for when comparing in the equal operator.
Used as: std::fabs(x1 - x2) < tolerance