Allolib
1.0
C++ Components For Interactive Multimedia
|
#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/math/al_Quat.hpp>
Public Member Functions | |
Quat (const T &w=T(1), const T &x=T(0), const T &y=T(0), const T &z=T(0)) | |
Default constructor creates an identity quaternion. | |
template<class U > | |
Quat (const Quat< U > &v) | |
template<class U > | |
Quat (const Vec< 3, U > &xyz) | |
Construct 'pure imaginary' quaternion. More... | |
template<class U > | |
Quat (const T &w, const Vec< 3, U > &xyz) | |
Construct quaternion from real and imaginary parts. More... | |
T & | operator[] (int i) |
Set component with index. | |
const T & | operator[] (int i) const |
Get component with index. | |
bool | operator== (const Quat &v) const |
Returns true if all components are equal. | |
bool | operator!= (const Quat &v) const |
Returns true if any components are not equal. | |
Quat | operator- () const |
Quat | operator+ (const Quat &v) const |
Quat | operator+ (const T &v) const |
Quat | operator- (const Quat &v) const |
Quat | operator- (const T &v) const |
Quat | operator/ (const Quat &v) const |
Quat | operator/ (const T &v) const |
Quat | operator* (const Quat &v) const |
Quat | operator* (const T &v) const |
template<class U > | |
Quat & | operator= (const Quat< U > &v) |
Quat & | operator= (const T &v) |
Quat & | operator+= (const Quat &v) |
Quat & | operator+= (const T &v) |
Quat & | operator-= (const Quat &v) |
Quat & | operator-= (const T &v) |
Quat & | operator*= (const Quat &v) |
Quat & | operator*= (const T &v) |
Quat & | operator/= (const Quat &v) |
Quat & | operator/= (const T &v) |
Quat | conj () const |
Returns the conjugate. | |
T | dot (const Quat &v) const |
Returns dot product with another quaternion. | |
Quat | inverse () const |
Returns inverse (same as conjugate if normalized as q^-1 = q_conj/q_mag^2) | |
T | mag () const |
Get magnitude. | |
T | magSqr () const |
Get magnitude squared. | |
Quat | pow (T v) const |
Return quaternion raised to a power. | |
Quat | recip () const |
Returns multiplicative inverse. | |
Quat | sgn () const |
Returns signum, q/|q|, the closest point on unit 3-sphere. | |
Quat | multiply (const Quat &q2) const |
Quat | reverseMultiply (const Quat &q2) const |
Quat & | normalize () |
Normalize magnitude to one. More... | |
Quat & | set (const T &w, const T &x, const T &y, const T &z) |
Set components. | |
template<class U > | |
Quat & | set (const Quat< U > &q) |
Set from other quaternion. | |
Quat & | setIdentity () |
Set to identity. | |
Quat & | fromAxisAngle (const T &angle, const T &ux, const T &uy, const T &uz) |
Set as versor rotated by angle, in radians, around unit vector (ux,uy,uz) | |
Quat & | fromAxisAngle (const T &angle, const Vec< 3, T > &axis) |
Set as versor rotated by angle, in radians, around unit vector. | |
Quat & | fromAxisX (const T &angle) |
Set as versor rotated by angle, in radians, around x-axis. | |
Quat & | fromAxisY (const T &angle) |
Set as versor rotated by angle, in radians, around y-axis. | |
Quat & | fromAxisZ (const T &angle) |
Set as versor rotated by angle, in radians, around z-axis. | |
Quat & | fromEuler (const Vec< 3, T > &aeb) |
Set as versor rotated by YXZ Euler angles, in radians. | |
Quat & | fromEuler (const T &az, const T &el, const T &ba) |
Set as versor rotated by YXZ Euler angles, in radians. | |
Quat & | fromMatrix (const T *matrix) |
Quat & | fromMatrix (const Mat< 4, T > &v) |
Quat & | fromMatrixTransposed (const T *matrix) |
Set as versor from row-major 4-by-4 projective space transformation matrix. | |
Quat & | fromMatrixTransposed (const Mat< 4, T > &v) |
Set as versor from row-major 4-by-4 projective space transformation matrix. | |
void | toCoordinateFrame (Vec< 3, T > &ux, Vec< 3, T > &uy, Vec< 3, T > &uz) const |
Convert to coordinate frame unit vectors. | |
template<typename T2 > | |
void | toMatrix (T2 *matrix) const |
Convert to column-major 4-by-4 projective space transformation matrix. | |
template<typename T2 > | |
void | toMatrixTransposed (T2 *matrix) const |
Convert to row-major 4-by-4 projective space transformation matrix. | |
void | toAxisAngle (T &angle, T &ax, T &ay, T &az) const |
Convert to axis-angle form, in radians. | |
void | toAxisAngle (T &angle, Vec< 3, T > &axis) const |
void | toEuler (T &az, T &el, T &ba) const |
Convert to YXZ Euler angles (azimuth, elevation, bank), in radians. | |
void | toEuler (T *aeb) const |
Convert to YXZ Euler angle vector (azimuth, elevation, bank), in radians. | |
void | toEuler (Vec< 3, T > &aeb) const |
Convert to YXZ Euler angle vector (azimuth, elevation, bank), in radians. | |
template<typename T2 > | |
void | toVectorX (T2 &ax, T2 &ay, T2 &az) const |
Get local x unit vector (1,0,0) in absolute coordinates. | |
template<typename T2 > | |
void | toVectorX (Vec< 3, T2 > &v) const |
template<typename T2 = T> | |
Vec< 3, T2 > | toVectorX () const |
template<typename T2 > | |
void | toVectorY (T2 &ax, T2 &ay, T2 &az) const |
Get local y unit vector (0,1,0) in absolute coordinates. | |
template<typename T2 > | |
void | toVectorY (Vec< 3, T2 > &v) const |
template<typename T2 = T> | |
Vec< 3, T2 > | toVectorY () const |
template<typename T2 > | |
void | toVectorZ (T2 &ax, T2 &ay, T2 &az) const |
Get local z unit vector (0,0,1) in absolute coordinates. | |
template<typename T2 > | |
void | toVectorZ (Vec< 3, T2 > &v) const |
template<typename T2 = T> | |
Vec< 3, T2 > | toVectorZ () const |
Vec< 3, T > | rotate (const Vec< 3, T > &v) const |
Vec< 3, T > | rotateTransposed (const Vec< 3, T > &v) const |
This is rotation by the quaternion's conjugate. | |
Quat | slerp (const Quat &target, T amt) const |
Spherical interpolation. | |
void | slerpTo (const Quat &target, T amt) |
In-place spherical interpolation. | |
void | towardPoint (const Vec< 3, T > &pos, const Quat< T > &q, const Vec< 3, T > &v, float amt) |
Get the quaternion from a given point and quaterion toward another point. More... | |
void | print (std::ostream &stream) const |
utility for debug printing: | |
Static Public Member Functions | |
static Quat | getRotationTo (const Vec< 3, T > &usrc, const Vec< 3, T > &udst) |
static Quat | getBillboardRotation (const Vec< 3, T > &forward, const Vec< 3, T > &up) |
static Quat | identity () |
Returns identity. | |
static Quat | rotor (const Vec< 3, T > &v1, const Vec< 3, T > &v2) |
Get rotor from two unit vectors. More... | |
static Quat | slerp (const Quat &from, const Quat &to, T amt) |
Spherical linear interpolation of a quaternion. More... | |
static void | slerpBuffer (const Quat &from, const Quat &to, Quat< T > *buffer, int numFrames) |
Fill an array of Quats with a full spherical interpolation. More... | |
static T | accuracyMax () |
static T | accuracyMin () |
static T | eps () |
Public Attributes | |
union { | |
struct { | |
T w | |
w component | |
T x | |
x component | |
T y | |
y component | |
T z | |
z component | |
} | |
T components [4] | |
component vector | |
}; | |
Quaternion
Definition at line 63 of file al_Quat.hpp.
[in] | v | quaternion to set values from |
Definition at line 82 of file al_Quat.hpp.
|
inline |
Construct 'pure imaginary' quaternion.
[in] | xyz | vector to set x,y,z components from; w is set to 0 |
Definition at line 89 of file al_Quat.hpp.
|
inline |
Construct quaternion from real and imaginary parts.
[in] | w | real part (w) |
[in] | xyz | vector to set imaginary (x,y,z) components from |
Definition at line 96 of file al_Quat.hpp.
Set as versor from column-major 4-by-4 projective space transformation matrix
Definition at line 314 of file al_Quat.hpp.
Set as versor from column-major 4-by-4 projective space transformation matrix
Definition at line 579 of file al_Quat.hpp.
|
static |
Similar to getRotationTo, but this function maintains an up vector Intended for billboarding in omni
Typical use case for omni billboarding:
Definition at line 1031 of file al_Quat.hpp.
|
static |
Calculate the rotation required to move from unit vector src to unit vector dst NOTE: both arguments must be UNIT VECTORS (normalized) rotation occurs around the axis created by the cross product of src and dst if the vectors are nearly opposing, the Y axis is used instead if the Y axis isn't suitable, the Z axis is used instead
a typical use case: rotate object A to face object B:
Definition at line 985 of file al_Quat.hpp.
Rotate vector NOTE: quaternion should be normalized for accurate results.
Definition at line 841 of file al_Quat.hpp.
|
static |
Get rotor from two unit vectors.
Alternatively expressed as Q = (1+gp(v1, v2))/sqrt(2*(1+dot(b, a))).
Definition at line 1134 of file al_Quat.hpp.
|
static |
Spherical linear interpolation of a quaternion.
[in] | from | The quaternion to interpolate from |
[in] | to | The quaternion to interpolate to |
[in] | amt | The amount to interpolate, range [0, 1] |
Definition at line 863 of file al_Quat.hpp.
|
static |
Fill an array of Quats with a full spherical interpolation.
Sinusoidal generator based on recursive formula x0 = c x1 - x2
Constructor
Generate next value.
< Multiplication factor. [-2, 2] range gives stable sinusoids.
Definition at line 913 of file al_Quat.hpp.
void al::Quat< T >::towardPoint | ( | const Vec< 3, T > & | pos, |
const Quat< T > & | q, | ||
const Vec< 3, T > & | v, | ||
float | amt | ||
) |
Get the quaternion from a given point and quaterion toward another point.
Get the quaternion from a given point and quaterion toward another point
Definition at line 1088 of file al_Quat.hpp.