Honeycomb
0.1
Component-Model Framework
|
Quaternion rotation class. Represents a counter-clockwise rotation of an angle about its axis. More...
#include <Matrix4.h>
Public Types | |
enum | EulerOrder { EulerOrder::xyz_s = _ORD(eulAxX, eulParEven, eulRepNo, eulFrmS), EulerOrder::xyx_s = _ORD(eulAxX, eulParEven, eulRepYes, eulFrmS), EulerOrder::xzy_s = _ORD(eulAxX, eulParOdd, eulRepNo, eulFrmS), EulerOrder::xzx_s = _ORD(eulAxX, eulParOdd, eulRepYes, eulFrmS), EulerOrder::yzx_s = _ORD(eulAxY, eulParEven, eulRepNo, eulFrmS), EulerOrder::yzy_s = _ORD(eulAxY, eulParEven, eulRepYes, eulFrmS), EulerOrder::yxz_s = _ORD(eulAxY, eulParOdd, eulRepNo, eulFrmS), EulerOrder::yxy_s = _ORD(eulAxY, eulParOdd, eulRepYes, eulFrmS), EulerOrder::zxy_s = _ORD(eulAxZ, eulParEven, eulRepNo, eulFrmS), EulerOrder::zxz_s = _ORD(eulAxZ, eulParEven, eulRepYes, eulFrmS), EulerOrder::zyx_s = _ORD(eulAxZ, eulParOdd, eulRepNo, eulFrmS), EulerOrder::zyz_s = _ORD(eulAxZ, eulParOdd, eulRepYes, eulFrmS), EulerOrder::zyx_r = _ORD(eulAxX, eulParEven, eulRepNo, eulFrmR), EulerOrder::xyx_r = _ORD(eulAxX, eulParEven, eulRepYes, eulFrmR), EulerOrder::yzx_r = _ORD(eulAxX, eulParOdd, eulRepNo, eulFrmR), EulerOrder::xzx_r = _ORD(eulAxX, eulParOdd, eulRepYes, eulFrmR), EulerOrder::xzy_r = _ORD(eulAxY, eulParEven, eulRepNo, eulFrmR), EulerOrder::yzy_r = _ORD(eulAxY, eulParEven, eulRepYes, eulFrmR), EulerOrder::zxy_r = _ORD(eulAxY, eulParOdd, eulRepNo, eulFrmR), EulerOrder::yxy_r = _ORD(eulAxY, eulParOdd, eulRepYes, eulFrmR), EulerOrder::yxz_r = _ORD(eulAxZ, eulParEven, eulRepNo, eulFrmR), EulerOrder::zxz_r = _ORD(eulAxZ, eulParEven, eulRepYes, eulFrmR), EulerOrder::xyz_r = _ORD(eulAxZ, eulParOdd, eulRepNo, eulFrmR), EulerOrder::zyz_r = _ORD(eulAxZ, eulParOdd, eulRepYes, eulFrmR) } |
Euler angle order. More... | |
typedef Real__ | Real |
Public Member Functions | |
Quat_ () | |
Construct with identity. More... | |
Quat_ (Real x, Real y, Real z, Real w) | |
Construct with imaginary vector components x,y,z and real scalar component w. More... | |
Quat_ (const Vec3 &axis, Real angle) | |
Construct from axis and angle in radians. More... | |
Quat_ (const Vec3 &axisX, const Vec3 &axisY, const Vec3 &axisZ) | |
Construct from 3 unit vectors. More... | |
Quat_ (const Vec3 &from, const Vec3 &to) | |
Construct a quaternion that rotates unit vector from towards unit vector to. More... | |
Quat_ (const Vec3 &eulerAngles) | |
Construct from euler angles in radians and order xyz_s More... | |
Quat_ (const Vec3 &eulerAngles, EulerOrder order) | |
Construct from euler angles in order. More... | |
Quat_ (const Matrix4 &rot) | |
Construct from 4x4 homogeneous matrix. Rotation is extracted from upper-left 3x3 submatrix. More... | |
Quat_ & | fromZero () |
Set quaternion to zero. More... | |
Quat_ & | fromIdentity () |
Set quaternion to identity. More... | |
Quat_ & | fromAxisAngle (const Vec3 &axis, Real angle) |
Construct from axis and angle in radians. More... | |
Quat_ & | fromEulerAngles (const Vec3 &eulerAngles) |
Construct from euler angles in radians and order xyz_s More... | |
Quat_ & | fromEulerAngles (const Vec3 &eulerAngles, EulerOrder order) |
Construct from euler angles in order. More... | |
Quat_ & | fromMatrix (const Matrix4 &rot) |
Construct from 4x4 homogeneous matrix. Rotation is extracted from upper-left 3x3 submatrix. More... | |
Quat_ & | fromAlign (const Vec3 &v1, const Vec3 &v2) |
Construct a quaternion that rotates unit vector v1 towards unit vector v2. The resulting quat's axis is perpendicular to v1 and v2. More... | |
Quat_ & | fromAxes (const Vec3 &axisX, const Vec3 &axisY, const Vec3 &axisZ) |
Construct from 3 unit vectors. More... | |
bool | operator== (const Quat_ &rhs) const |
bool | operator!= (const Quat_ &rhs) const |
Quat_ | operator+ () const |
Quat_ | operator+ (const Quat_ &rhs) const |
Quat_ & | operator+= (const Quat_ &rhs) |
Quat_ | operator- () const |
Quat_ | operator- (const Quat_ &rhs) const |
Quat_ & | operator-= (const Quat_ &rhs) |
Quat_ | operator* (const Quat_ &rhs) const |
Vec3 | operator* (const Vec3 &rhs) const |
Quat_ | operator* (Real rhs) const |
Quat_ & | operator*= (const Quat_ &rhs) |
Quat_ & | operator*= (Real rhs) |
Quat_ | operator/ (const Quat_ &rhs) const |
Quat_ | operator/ (Real rhs) const |
Quat_ & | operator/= (const Quat_ &rhs) |
Quat_ & | operator/= (Real rhs) |
const Real & | operator[] (int i) const |
Access quaternion components. More... | |
Real & | operator[] (int i) |
operator Real * () | |
Cast to array of quaternion components. More... | |
operator const Real * () const | |
Real | dot (const Quat_ &q) const |
Quat_ | conjugate () const |
Quat_ | inverse () const |
Assumes that quaternion is unit length, same as conjugate() More... | |
Quat_ | inverseNonUnit () const |
Proper quaternion inverse. Only use if quaternion is expected to be non-unit length. More... | |
Quat_ | exp () const |
Quat_ | ln () const |
Quat_ | sqrt () const |
Real | lengthSqr () const |
Square of the length. More... | |
Real | length () const |
Quat_ | normalize (optional< Real & > len=optnull) const |
Get unit quaternion. The pre-normalized length will be returned in len if specified. More... | |
Quat_ | normalize_fast () const |
Fast normalization, only accurate when quaternion is close to unit length. More... | |
void | axisAngle (Vec3 &axis, Real &angle) const |
Get quaternion axis and angle in radians. More... | |
Vec3 | axisX () const |
Get quaternion's rotated unit axis. More... | |
Vec3 | axisY () const |
Vec3 | axisZ () const |
void | axes (Vec3 &axisX, Vec3 &axisY, Vec3 &axisZ) const |
Get unit axes that represent this quaternion. More... | |
Vec3 | eulerAngles () const |
Get euler angles in radians and order xyz_s More... | |
Vec3 | eulerAngles (EulerOrder order) const |
Get euler angles in order. More... | |
Matrix4 & | toMatrix (Matrix4 &rot, bool b3x3=false) const |
Convert quaternion to 4x4 homogeneous rotation matrix. Set b3x3 to true to store the result only in the upper-left 3x3 submatrix of rot , leaving rest of matrix unchanged. More... | |
Static Public Member Functions | |
static Quat_ | slerp (Real t, const Quat_ &q0, const Quat_ &q1) |
Spherical linear interpolation from q0 to q1. t ranges from [0,1]. More... | |
static void | squadSetup (const Quat_ &q0, const Quat_ &q1, const Quat_ &q2, const Quat_ &q3, Quat_ &a, Quat_ &b, Quat_ &c) |
Calc intermediate quats required for Squad. Ex. To interpolate between q1 and q2: setup(q0,q1,q2,q3,a,b,c) -> squad(q1,a,b,c) More... | |
static Quat_ | squad (Real t, const Quat_ &q1, const Quat_ &a, const Quat_ &b, const Quat_ &c) |
Spherical quadratic interpolation between q1 and c. t ranges from [0,1]. More... | |
static Quat_ | baryCentric (Real f, Real g, const Quat_ &q0, const Quat_ &q1, const Quat_ &q2) |
Triangular bary-centric interpolation. More... | |
Public Attributes | |
Real | x |
Real | y |
Real | z |
Real | w |
Static Public Attributes | |
static const int | dim = 4 |
static const Quat_ | zero |
static const Quat_ | identity |
Friends | |
Quat_ | operator* (Real lhs, const Quat_ &rhs) |
ostream & | operator<< (ostream &os, const Quat_ &val) |
Quaternion rotation class. Represents a counter-clockwise rotation of an angle about its axis.
Quaternion concatenation, like matrices, follows a right-to-left ordering.
ie. To rotate a vector first by q0
, followed by a rotation of q1
, apply
typedef Real__ honey::Quat_< Real__ >::Real |
|
strong |
Euler angle order.
The default order xyz_s
represents a rotation of z radians around the z-axis, followed by a rotation around the y-axis then x-axis. All axes are from the static (initial) frame.
(axes)_s | Static (initial) frame axes |
(axes)_r | Rotating frame axes |
Enumerator | |
---|---|
xyz_s | |
xyx_s | |
xzy_s | |
xzx_s | |
yzx_s | |
yzy_s | |
yxz_s | |
yxy_s | |
zxy_s | |
zxz_s | |
zyx_s | |
zyz_s | |
zyx_r | |
xyx_r | |
yzx_r | |
xzx_r | |
xzy_r | |
yzy_r | |
zxy_r | |
yxy_r | |
yxz_r | |
zxz_r | |
xyz_r | |
zyz_r |
|
inline |
Construct with identity.
Construct with imaginary vector components x,y,z and real scalar component w.
|
inline |
Construct from axis and angle in radians.
|
inline |
Construct from 3 unit vectors.
|
inline |
Construct a quaternion that rotates unit vector from towards unit vector to.
|
inlineexplicit |
Construct from euler angles in radians and order xyz_s
|
inline |
Construct from euler angles in order.
|
inline |
Construct from 4x4 homogeneous matrix. Rotation is extracted from upper-left 3x3 submatrix.
void honey::Quat_< Real >::axes | ( | Vec3 & | axisX, |
Vec3 & | axisY, | ||
Vec3 & | axisZ | ||
) | const |
Get unit axes that represent this quaternion.
void honey::Quat_< Real >::axisAngle | ( | Vec3 & | axis, |
Real & | angle | ||
) | const |
Get quaternion axis and angle in radians.
Quat_< Real >::Vec3 honey::Quat_< Real >::axisX | ( | ) | const |
Get quaternion's rotated unit axis.
Quat_< Real >::Vec3 honey::Quat_< Real >::axisY | ( | ) | const |
Quat_< Real >::Vec3 honey::Quat_< Real >::axisZ | ( | ) | const |
|
static |
Triangular bary-centric interpolation.
Input -> Output:
(0,0) -> q0 (1,0) -> q1 (0,1) -> q2 1-f-g==0 -> line q1,q2 (f,0) -> line q0,q1 (0,g) -> line q0,q2
|
inline |
|
inline |
Quat_< Real >::Vec3 honey::Quat_< Real >::eulerAngles | ( | ) | const |
Get euler angles in radians and order xyz_s
Quat_< Real >::Vec3 honey::Quat_< Real >::eulerAngles | ( | EulerOrder | order | ) | const |
Get euler angles in order.
Quat_< Real > honey::Quat_< Real >::exp | ( | ) | const |
Quat_< Real > & honey::Quat_< Real >::fromAlign | ( | const Vec3 & | v1, |
const Vec3 & | v2 | ||
) |
Construct a quaternion that rotates unit vector v1 towards unit vector v2. The resulting quat's axis is perpendicular to v1 and v2.
Quat_< Real > & honey::Quat_< Real >::fromAxes | ( | const Vec3 & | axisX, |
const Vec3 & | axisY, | ||
const Vec3 & | axisZ | ||
) |
Construct from 3 unit vectors.
Quat_< Real > & honey::Quat_< Real >::fromAxisAngle | ( | const Vec3 & | axis, |
Real | angle | ||
) |
Construct from axis and angle in radians.
Quat_< Real > & honey::Quat_< Real >::fromEulerAngles | ( | const Vec3 & | eulerAngles | ) |
Construct from euler angles in radians and order xyz_s
Quat_< Real > & honey::Quat_< Real >::fromEulerAngles | ( | const Vec3 & | eulerAngles, |
EulerOrder | order | ||
) |
Construct from euler angles in order.
|
inline |
Set quaternion to identity.
Quat_< Real > & honey::Quat_< Real >::fromMatrix | ( | const Matrix4 & | rot | ) |
Construct from 4x4 homogeneous matrix. Rotation is extracted from upper-left 3x3 submatrix.
|
inline |
Set quaternion to zero.
|
inline |
Assumes that quaternion is unit length, same as conjugate()
|
inline |
Proper quaternion inverse. Only use if quaternion is expected to be non-unit length.
|
inline |
|
inline |
Square of the length.
Quat_< Real > honey::Quat_< Real >::ln | ( | ) | const |
|
inline |
Get unit quaternion. The pre-normalized length will be returned in len if specified.
|
inline |
Fast normalization, only accurate when quaternion is close to unit length.
|
inline |
|
inline |
Cast to array of quaternion components.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Access quaternion components.
|
inline |
|
inlinestatic |
Spherical linear interpolation from q0 to q1. t ranges from [0,1].
|
inline |
|
static |
Spherical quadratic interpolation between q1 and c. t ranges from [0,1].
|
static |
Calc intermediate quats required for Squad. Ex. To interpolate between q1 and q2: setup(q0,q1,q2,q3,a,b,c) -> squad(q1,a,b,c)
Quat_< Real >::Matrix4 & honey::Quat_< Real >::toMatrix | ( | Matrix4 & | rot, |
bool | b3x3 = false |
||
) | const |
Convert quaternion to 4x4 homogeneous rotation matrix. Set b3x3 to true to store the result only in the upper-left 3x3 submatrix of rot
, leaving rest of matrix unchanged.
|
friend |
|
static |
|
static |
Real honey::Quat_< Real__ >::w |
Real honey::Quat_< Real__ >::x |
Real honey::Quat_< Real__ >::y |
Real honey::Quat_< Real__ >::z |
|
static |