#include
Inherits INumberVector< F, 4, Quat_tpl< F > >.
Public Types | |
typedef INumberVector< F, 4, Quat_tpl< F > > | NV |
Public Member Functions | |
ILINE | Quat_tpl (type_zero) |
ILINE | Quat_tpl (type_identity) |
template | |
ILINE | Quat_tpl (const Quat_tpl< F2 > &q) |
ILINE | Quat_tpl (F qw, F qx, F qy, F qz) |
ILINE | Quat_tpl (F scalar, const Vec3_tpl< F > &vector) |
ILINE | Quat_tpl (const Ang3_tpl< F > &ang) |
template | |
ILINE | Quat_tpl (const Ang3_tpl< F1 > &ang) |
template | |
void | SetFromMatrix (const M &m) |
Extract quat from any matrix type which has members of the form m12, etc. | |
template | |
Quat_tpl (const Matrix33_tpl< F1 > &m) | |
template | |
Quat_tpl (const Matrix34_tpl< F1 > &m) | |
template | |
Quat_tpl (const Matrix44_tpl< F1 > &m) | |
ILINE Quat_tpl< F > | operator! () const |
ILINE void | Invert (void) |
ILINE Quat_tpl< F > | GetInverted () const |
ILINE Vec3_tpl< F > | GetColumn (uint32 i) |
A quaternion is a compressed matrix. Thus there is no problem extracting the rows & columns. | |
ILINE Vec3_tpl< F > | GetColumn0 () const |
ILINE Vec3_tpl< F > | GetColumn1 () const |
ILINE Vec3_tpl< F > | GetColumn2 () const |
ILINE Vec3_tpl< F > | GetRow0 () const |
ILINE Vec3_tpl< F > | GetRow1 () const |
ILINE Vec3_tpl< F > | GetRow2 () const |
ILINE F | GetFwdX () const |
ILINE F | GetFwdY () const |
ILINE F | GetFwdZ () const |
ILINE F | GetRotZ () const |
ILINE void | SetIdentity (void) |
ILINE bool | IsIdentity () const |
Check if identity quaternion. | |
ILINE bool | IsUnit (f32 e=VEC_EPSILON) const |
ILINE void | SetRotationAA (F rad, const Vec3_tpl< F > &axis) |
ILINE void | SetRotationAA (F cosha, F sinha, const Vec3_tpl< F > &axis) |
void | SetRotationXYZ (const Ang3_tpl< F > &a) |
ILINE void | SetRotationX (F r) |
ILINE void | SetRotationY (F r) |
ILINE void | SetRotationZ (F r) |
void | SetRotationV0V1 (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1) |
void | SetRotationVDir (const Vec3_tpl< F > &vdir) |
void | SetRotationVDir (const Vec3_tpl< F > &vdir, F r) |
ILINE void | NormalizeSafe (void) |
ILINE Quat_tpl< F > | GetNormalizedSafe () const |
ILINE void | SetNlerp (const Quat_tpl< F > &p, const Quat_tpl< F > &tq, F t) |
void | SetNlerpCubic (const Quat_tpl< F > &p, const Quat_tpl< F > &tq, F t) |
void | SetSlerp (const Quat_tpl< F > &tp, const Quat_tpl< F > &tq, F t) |
Spherical-interpolation between unit quaternions (geometrical slerp). | |
ILINE void | SetExpSlerp (const Quat_tpl< F > &p, const Quat_tpl< F > &tq, F t) |
ILINE void | SetSquad (const Quat_tpl< F > &p, const Quat_tpl< F > &a, const Quat_tpl< F > &b, const Quat_tpl< F > &q, F t) |
squad(p,a,b,q,t) = slerp( slerp(p,q,t),slerp(a,b,t), 2(1-t)t). | |
ILINE Quat_tpl< F > | GetScaled (F scale) const |
Useless, please delete. | |
Static Public Member Functions | |
static ILINE Quat_tpl< F > | CreateIdentity (void) |
static ILINE Quat_tpl< F > | CreateRotationAA (F rad, const Vec3_tpl< F > &axis) |
static ILINE Quat_tpl< F > | CreateRotationAA (F cosha, F sinha, const Vec3_tpl< F > &axis) |
static Quat_tpl< F > | CreateRotationXYZ (const Ang3_tpl< F > &a) |
static ILINE Quat_tpl< F > | CreateRotationX (F r) |
static ILINE Quat_tpl< F > | CreateRotationY (F r) |
static ILINE Quat_tpl< F > | CreateRotationZ (F r) |
static Quat_tpl< F > | CreateRotationV0V1 (const Vec3_tpl< F > &v0, const Vec3_tpl< F > &v1) |
static Quat_tpl< F > | CreateRotationVDir (const Vec3_tpl< F > &vdir) |
static Quat_tpl< F > | CreateRotationVDir (const Vec3_tpl< F > &vdir, F roll) |
static ILINE bool | IsEquivalent (const Quat_tpl< F > &q1, const Quat_tpl< F > &q2, f32 qe=RAD_EPSILON) |
static ILINE Quat_tpl< F > | exp (const Vec3_tpl< F > &v) |
Exponent of a Quaternion. | |
static ILINE Vec3_tpl< F > | log (const Quat_tpl< F > &q) |
Logarithm of a quaternion, imaginary part (the real part of the logarithm is always 0). | |
static ILINE Quat_tpl< F > | LnDif (const Quat_tpl< F > &q1, const Quat_tpl< F > &q2) |
Logarithm of Quaternion difference. | |
static ILINE Quat_tpl< F > | CreateNlerp (const Quat_tpl< F > &p, const Quat_tpl< F > &tq, F t) |
static Quat_tpl< F > | CreateNlerpCubic (const Quat_tpl< F > &p, const Quat_tpl< F > &tq, F t) |
static Quat_tpl< F > | CreateSlerp (const Quat_tpl< F > &p, const Quat_tpl< F > &tq, F t) |
Create a quaternion by spherically interpolating between unit quaternions (geometrical slerp) | |
static ILINE Quat_tpl< F > | CreateExpSlerp (const Quat_tpl< F > &p, const Quat_tpl< F > &q, F t) |
static ILINE Quat_tpl< F > | CreateSquad (const Quat_tpl< F > &p, const Quat_tpl< F > &a, const Quat_tpl< F > &b, const Quat_tpl< F > &q, F t) |
Public Attributes | |
Vec3_tpl< F > | v |
F | w |
AUTO_STRUCT_INFO | |
General-purpose quaternion implementation
CONSTRUCTOR to initialize a Quat from 4 floats. Quat q(1,0,0,0);
CONSTRUCTOR to initialize a Quat with a scalar and a vector. Quat q(1,Vec3(0,0,0));
CONSTRUCTOR for different types. It converts a Euler Angle into a Quat. Needs to be 'explicit' because we loose fp-precision in the conversion process. Quat(Ang3(1,2,3));
CONSTRUCTOR for different types. It converts a Euler Angle into a Quat and converts between double/float. Needs to be 'explicit' because we loose fp-precision in the conversion process. Quat(Ang3r(1,2,3));
Invert quaternion. Example 1: Quat q=Quat::CreateRotationXYZ(Ang3(1,2,3)); Quat result = !q; Quat result = GetInverted(q); q.Invert();
Spherical-interpolation between unit quaternions (algebraic slerp_a). I have included this function just for the sake of completeness, because it is the only useful application to check if exp & log really work. Both slerp-functions return the same result. Example: Quat result,p,q; result.SetExpSlerp( p,q,0.3345f );
|
inline |
Set identity quaternion. Example: Quat q=Quat::CreateIdentity(); or q.SetIdentity(); or Quat p=Quat(IDENTITY);
Linear-interpolation between quaternions (lerp). Example: CQuaternion result,p,q; result=qlerp( p, q, 0.5f );
Linear-interpolation between unit quaternions (nlerp). In this case we convert the t-value into a 1d cubic spline to get closer to Slerp. Example: Quat result,p,q; result.SetNlerpCubic( p, q, 0.5f );
Create rotation-quaternion that rotates from one vector to another. Both vectors are assumed to be normalized. Example: Quat q=Quat::CreateRotationV0V1( v0,v1 ); q.SetRotationV0V1( v0,v1 );
vdir | Normalized view direction. |
roll | Radiant to rotate about Y-axis. Given a view-direction and a radiant to rotate about Y-axis, this function builds a 3x3 look-at quaternion using only simple vector arithmetic. This function is always using the implicit up-vector Vec3(0,0,1). The view-direction is always stored in column(1). IMPORTANT: The view-vector is assumed to be normalized, because all trig-values for the orientation are being extracted directly out of the vector. This function must NOT be called with a view-direction that is close to Vec3(0,0,1) or Vec3(0,0,-1). If one of these rules is broken, the function returns a quaternion with an undefined rotation about the Z-axis. Rotation order for the look-at-quaternion is Z-X-Y. (Zaxis=YAW / Xaxis=PITCH / Yaxis=ROLL) COORDINATE-SYSTEM z-axis ^ | | y-axis | / | / |/ +------------—> x-axis Example: Quat LookAtQuat=Quat::CreateRotationVDir( Vec3(0,1,0) ); or Quat LookAtQuat=Quat::CreateRotationVDir( Vec3(0,1,0), 0.333f ); |
|
inline |
Create rotation-quaternion that about the x-axis. Example: Quat q=Quat::CreateRotationX( radiant ); or q.SetRotationX( Ang3(1,2,3) );
Create rotation-quaternion that around the fixed coordinate axes. Example: Quat q=Quat::CreateRotationXYZ( Ang3(1,2,3) ); or q.SetRotationXYZ( Ang3(1,2,3) );
|
inline |
Create rotation-quaternion that about the y-axis. Example: Quat q=Quat::CreateRotationY( radiant ); or q.SetRotationY( radiant );
|
inline |
Create rotation-quaternion that about the z-axis. Example: Quat q=Quat::CreateRotationZ( radiant ); or q.SetRotationZ( radiant );